parent
616956b19b
commit
debd07084a
@ -0,0 +1,12 @@ |
|||||||
|
using AOLBackend.Models.Catalogos; |
||||||
|
using AOLBackend.DTO.Catalogos; |
||||||
|
|
||||||
|
namespace AOLBackend.Contracts.Catalogos |
||||||
|
{ |
||||||
|
public interface ICatRutasRepository |
||||||
|
{ |
||||||
|
public Task<ICatRutas> Append(ICatRutas data); |
||||||
|
public Task<IEnumerable<DTOCatRutas>> GetAll(); |
||||||
|
public Task<Boolean> Delete(int id); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
using AOLBackend.Models.Catalogos; |
||||||
|
|
||||||
|
namespace AOLBackend.Contracts.Catalogos |
||||||
|
{ |
||||||
|
public interface ICatServiciosRepository |
||||||
|
{ |
||||||
|
public Task<ICatServicios> Append(ICatServicios data); |
||||||
|
public Task<IEnumerable<ICatServicios>> GetAll(); |
||||||
|
public Task<Boolean> Delete(int id); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,42 @@ |
|||||||
|
using AOLBackend.Contracts.Catalogos; |
||||||
|
using AOLBackend.Models.Catalogos; |
||||||
|
using AOLBackend.DTO.Catalogos; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
|
||||||
|
namespace AOLBackend.Controllers.Catalogos |
||||||
|
{ |
||||||
|
[ApiController] |
||||||
|
[Route("api/Catalogos/[controller]")]
|
||||||
|
public class CatRutasController : ControllerBase |
||||||
|
{ |
||||||
|
private readonly ICatRutasRepository _Repo; |
||||||
|
|
||||||
|
public CatRutasController(ICatRutasRepository Repo) |
||||||
|
{ |
||||||
|
_Repo = Repo; |
||||||
|
} |
||||||
|
|
||||||
|
[HttpPost] |
||||||
|
[Route("Append")] |
||||||
|
public async Task<ICatRutas> Append([FromBody] ICatRutas data) |
||||||
|
{ |
||||||
|
var entrada = await _Repo.Append(data); |
||||||
|
return entrada; |
||||||
|
} |
||||||
|
|
||||||
|
[HttpGet] |
||||||
|
[Route("Get")] |
||||||
|
public async Task<IEnumerable<DTOCatRutas>> GetAll() |
||||||
|
{ |
||||||
|
var entrada = await _Repo.GetAll(); |
||||||
|
return entrada; |
||||||
|
} |
||||||
|
|
||||||
|
[HttpDelete("Delete/{id}")] |
||||||
|
public async Task<IActionResult> Delete(int id) |
||||||
|
{ |
||||||
|
await _Repo.Delete(id); |
||||||
|
return new OkObjectResult(new { respuesta = "Se elimino el registro" }); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,42 @@ |
|||||||
|
using AOLBackend.Contracts.Catalogos; |
||||||
|
using AOLBackend.Models.Catalogos; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
|
||||||
|
|
||||||
|
namespace AOLBackend.Controllers.Catalogos |
||||||
|
{ |
||||||
|
[ApiController] |
||||||
|
[Route("api/Catalogos/[controller]")]
|
||||||
|
public class CatServiciosController : ControllerBase |
||||||
|
{ |
||||||
|
private readonly ICatServiciosRepository _Repo; |
||||||
|
|
||||||
|
public CatServiciosController(ICatServiciosRepository Repo) |
||||||
|
{ |
||||||
|
_Repo = Repo; |
||||||
|
} |
||||||
|
|
||||||
|
[HttpPost] |
||||||
|
[Route("Append")] |
||||||
|
public async Task<ICatServicios> Append([FromBody] ICatServicios data) |
||||||
|
{ |
||||||
|
var entrada = await _Repo.Append(data); |
||||||
|
return entrada; |
||||||
|
} |
||||||
|
|
||||||
|
[HttpGet] |
||||||
|
[Route("Get")] |
||||||
|
public async Task<IEnumerable<ICatServicios>> GetAll() |
||||||
|
{ |
||||||
|
var entrada = await _Repo.GetAll(); |
||||||
|
return entrada; |
||||||
|
} |
||||||
|
|
||||||
|
[HttpDelete("Delete/{id}")] |
||||||
|
public async Task<IActionResult> Delete(int id) |
||||||
|
{ |
||||||
|
await _Repo.Delete(id); |
||||||
|
return new OkObjectResult(new { respuesta = "Se elimino el registro" }); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
namespace AOLBackend.DTO.Catalogos |
||||||
|
{ |
||||||
|
public class DTOCatRutas |
||||||
|
{ |
||||||
|
public int id { get; set; } |
||||||
|
public int Cliente { get; set; } = 0; |
||||||
|
public string sCliente { get; set; } = null!; |
||||||
|
public int Servicio { get; set; } = 0; |
||||||
|
public string sServicio { get; set; } = null!; |
||||||
|
public double Precio { get; set; } = 0; |
||||||
|
public int Proveedor { get; set; } = 0; |
||||||
|
public string sProveedor { get; set; } = null!; |
||||||
|
public double Costo { get; set; } = 0; |
||||||
|
public int Origen { get; set; } = 0; |
||||||
|
public string sOrigen { get; set; } = null!; |
||||||
|
public int Destino { get; set; } = 0; |
||||||
|
public string sDestino { get; set; } = null!; |
||||||
|
public int TipoUnidad { get; set; } = 0; |
||||||
|
public string sTipoUnidad { get; set; } = null!; |
||||||
|
public string FCreacion { get; set; } = null!; |
||||||
|
public string FActualizacion { get; set; } = null!; |
||||||
|
public Byte Activo { get; set; } = 0!; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
namespace AOLBackend.Models.Catalogos |
||||||
|
{ |
||||||
|
public class ICatRutas |
||||||
|
{ |
||||||
|
public int id { get; set; } |
||||||
|
public int Cliente { get; set; } = 0; |
||||||
|
public int Servicio { get; set; } = 0; |
||||||
|
public double Precio { get; set; } = 0; |
||||||
|
public int Proveedor { get; set; } = 0; |
||||||
|
public double Costo { get; set; } = 0; |
||||||
|
public int Origen { get; set; } = 0; |
||||||
|
public int Destino { get; set; } = 0; |
||||||
|
public int TipoUnidad { get; set; } = 0; |
||||||
|
public string? FCreacion { get; set; } = null!; |
||||||
|
public string? FActualizacion { get; set; } = null!; |
||||||
|
public Byte Activo { get; set; } = 0!; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
|
||||||
|
namespace AOLBackend.Models.Catalogos |
||||||
|
{ |
||||||
|
public class ICatServicios |
||||||
|
{ |
||||||
|
public int id { get; set; } |
||||||
|
public string Servicio { get; set; } = null!; |
||||||
|
public decimal Precio { get; set; } = 0; |
||||||
|
public Byte Activo { get; set; } = 0!; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,55 @@ |
|||||||
|
using AOLBackend.Context; |
||||||
|
using AOLBackend.Contracts.Catalogos; |
||||||
|
using AOLBackend.Models.Catalogos; |
||||||
|
using AOLBackend.DTO.Catalogos; |
||||||
|
using Dapper; |
||||||
|
using System.Data; |
||||||
|
|
||||||
|
namespace AOLBackend.Repository.Catalogos |
||||||
|
{ |
||||||
|
public class CatRutasRepository : ICatRutasRepository |
||||||
|
{ |
||||||
|
private readonly DapperContext _context; |
||||||
|
private readonly IConfiguration _config; |
||||||
|
public CatRutasRepository(DapperContext context, IConfiguration config) |
||||||
|
{ |
||||||
|
_context = context; |
||||||
|
_config = config; |
||||||
|
} |
||||||
|
|
||||||
|
public async Task<ICatRutas> Append(ICatRutas data) |
||||||
|
{ |
||||||
|
var query = "[Catalogo.CatRutas.Append]"; |
||||||
|
using var connection = _context.CreateConnection(); |
||||||
|
var entrada = await connection.QueryAsync<ICatRutas>(query, new |
||||||
|
{ |
||||||
|
@id = data.id, |
||||||
|
@Cliente = data.Cliente, |
||||||
|
@Servicio = data.Servicio, |
||||||
|
@Precio = data.Precio, |
||||||
|
@Proveedor = data.Proveedor, |
||||||
|
@Costo = data.Costo, |
||||||
|
@Origen = data.Origen, |
||||||
|
@Destino = data.Destino, |
||||||
|
@TipoUnidad = data.TipoUnidad, |
||||||
|
@Activo = data.Activo |
||||||
|
}, commandType: CommandType.StoredProcedure); |
||||||
|
return entrada.First(); |
||||||
|
} |
||||||
|
public async Task<IEnumerable<DTOCatRutas>> GetAll() |
||||||
|
{ |
||||||
|
var query = "[Catalogo.CatRutas.Get]"; |
||||||
|
using var connection = _context.CreateConnection(); |
||||||
|
var entrada = await connection.QueryAsync<DTOCatRutas>(query, new { }, commandType: CommandType.StoredProcedure); |
||||||
|
return entrada; |
||||||
|
} |
||||||
|
|
||||||
|
public async Task<Boolean> Delete(int id) |
||||||
|
{ |
||||||
|
var query = "[Catalogo.CatRutas.Delete]"; |
||||||
|
using var connection = _context.CreateConnection(); |
||||||
|
var entrada = await connection.QueryAsync<ICatRutas>(query, new { @id }, commandType: CommandType.StoredProcedure); |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
using AOLBackend.Context; |
||||||
|
using AOLBackend.Contracts.Catalogos; |
||||||
|
using AOLBackend.Models.Catalogos; |
||||||
|
using Dapper; |
||||||
|
using System.Data; |
||||||
|
|
||||||
|
namespace AOLBackend.Repository.Catalogos |
||||||
|
{ |
||||||
|
public class CatServiciosRepository : ICatServiciosRepository |
||||||
|
{ |
||||||
|
private readonly DapperContext _context; |
||||||
|
private readonly IConfiguration _config; |
||||||
|
public CatServiciosRepository(DapperContext context, IConfiguration config) |
||||||
|
{ |
||||||
|
_context = context; |
||||||
|
_config = config; |
||||||
|
} |
||||||
|
|
||||||
|
public async Task<ICatServicios> Append(ICatServicios data) |
||||||
|
{ |
||||||
|
var query = "[Catalogo.CatServicios.Append]"; |
||||||
|
using var connection = _context.CreateConnection(); |
||||||
|
var entrada = await connection.QueryAsync<ICatServicios>(query, new |
||||||
|
{ |
||||||
|
@id = data.id, |
||||||
|
@Servicios = data.Servicio, |
||||||
|
@Precio = data.Precio, |
||||||
|
}, commandType: CommandType.StoredProcedure); |
||||||
|
return entrada.First(); |
||||||
|
} |
||||||
|
public async Task<IEnumerable<ICatServicios>> GetAll() |
||||||
|
{ |
||||||
|
var query = "[Catalogo.CatServicios.Get]"; |
||||||
|
using var connection = _context.CreateConnection(); |
||||||
|
var entrada = await connection.QueryAsync<ICatServicios>(query, new { }, commandType: CommandType.StoredProcedure); |
||||||
|
return entrada; |
||||||
|
} |
||||||
|
|
||||||
|
public async Task<Boolean> Delete(int id) |
||||||
|
{ |
||||||
|
var query = "[Catalogo.CatServicios.Delete]"; |
||||||
|
using var connection = _context.CreateConnection(); |
||||||
|
var entrada = await connection.QueryAsync<ICatServicios>(query, new { @id }, commandType: CommandType.StoredProcedure); |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +1 @@ |
|||||||
4d7d0b7fb49ca16452b034f5986c30e9a38fc20a |
2042434c554652c90861df655d8b5f920355c627 |
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue