diff --git a/Controllers/DetallesController.cs b/Controllers/DetallesController.cs index 987fe4d..bfcacac 100644 --- a/Controllers/DetallesController.cs +++ b/Controllers/DetallesController.cs @@ -1,5 +1,6 @@ using System.ComponentModel; using System.Security.Cryptography; +using Azure.Messaging; using Microsoft.AspNetCore.Components.Forms; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Formatters; @@ -17,38 +18,24 @@ namespace MyFirstAPI.Controllers private readonly Repositoriooo repositoriooo; public DetallesController() { - repositoriooo = new Repositoriooo(); - } - - //GET PARA LEER LA TABLA DETALLES - [HttpGet] [ProducesResponseType(StatusCodes.Status200OK)] public async Task Get() { - var lista = await repositoriooo.GetDetalles(); - - return Ok(lista.ToList()); - - - } // ENVIAR DATOS EN LA TABLA DETALLES [HttpPost] [ProducesResponseType(StatusCodes.Status200OK)] public async Task Create(Detalles deta) { - await repositoriooo.Create(deta); return Ok(); - } - // ACTUALIZAR DATOS EN LA TABLA DETALLES [HttpPut] [ProducesResponseType(StatusCodes.Status200OK)] @@ -59,19 +46,15 @@ namespace MyFirstAPI.Controllers return Ok(); } - - // Elimar datos de la tabla detalles [HttpDelete] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] public async Task Delete( int id ) { - - await repositoriooo.Delete(id ); - return Ok(); - - + await repositoriooo.Delete(id); + return Ok(); } - } + + } } diff --git a/Controllers/FacturaController.cs b/Controllers/FacturaController.cs index dd026e2..b11c84f 100644 --- a/Controllers/FacturaController.cs +++ b/Controllers/FacturaController.cs @@ -9,7 +9,6 @@ namespace MyFirstAPI.Controllers [Route("Api/Factura")] public class FacturaController : ControllerBase { - // crud para la tabla factura private readonly Repositoriooo repositoriooo; public FacturaController() @@ -21,7 +20,6 @@ namespace MyFirstAPI.Controllers /// get para leer la tabla factura [HttpGet] - [ProducesResponseType(StatusCodes.Status200OK)] public async Task Getf() { @@ -34,7 +32,7 @@ namespace MyFirstAPI.Controllers [ProducesResponseType(StatusCodes.Status200OK)] public async Task Create(Factura fac) { - + await repositoriooo.CreateF (fac); return Ok(); @@ -43,6 +41,7 @@ namespace MyFirstAPI.Controllers // ACTUALIZAR DATOS EN LA TABLA Factura [HttpPut] [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] public async Task Put(Factura fac) { @@ -51,7 +50,6 @@ namespace MyFirstAPI.Controllers } - // Elimar datos de la tabla factura [HttpDelete] [ProducesResponseType(StatusCodes.Status200OK)] diff --git a/Models/Detalles.cs b/Models/Detalles.cs index 017961a..0c87855 100644 --- a/Models/Detalles.cs +++ b/Models/Detalles.cs @@ -16,16 +16,6 @@ - //private string? _strNfactura; public string Nfactura { get => _strNfactura; set { _strNfactura = value; } } - //private string? _strArticuloNumber; public string ArticuloNumber { get { return _strArticuloNumber; } set { _strArticuloNumber = value; } } - - //private int _intCantidad; public int Cantidad { get { return _intCantidad; } set { _dblPrecio = value; } } - //private double _dblPrecio; public double dblPrecio { get { return dblPrecio; } set { _dblPrecio = value; } } - - //private double _dblTotalId; public double dblTotalId { get { return dblTotalId; } set { dblTotalId = value; } } - - //private string _strArticulo; public string strArticulo { get { return _strArticulo; } set { _strArticulo = value; } } - //private byte _byteActivo; public byte Activo { get { return _byteActivo; } set { _byteActivo = value; } } } diff --git a/Repositorio/Repositoriooo.cs b/Repositorio/Repositoriooo.cs index 2e280fd..4182c2a 100644 --- a/Repositorio/Repositoriooo.cs +++ b/Repositorio/Repositoriooo.cs @@ -15,9 +15,8 @@ namespace MyFirstAPI.Repositorio public class Repositoriooo : DateTimeConverter { SqlConexion cn = new SqlConexion(); - - ///Repositorio / - // dapper para leer detalles + + #region "LEER TABLA DETALLES " public async Task> GetDetalles() { using (var connection = new SqlConnection(cn.CadenaSQL())) @@ -30,7 +29,9 @@ namespace MyFirstAPI.Repositorio } } - // dapper para leer factura + #endregion + + #region "LEER TABLA FACTURA" public async Task> GetFactura() { using (var connection = new SqlConnection(cn.CadenaSQL())) @@ -42,28 +43,35 @@ namespace MyFirstAPI.Repositorio } } - /// METODO POST PARA ENVIAR DATOS EN DETALLES + #endregion + + #region "METODO POST PARA ENVIAR DATOS EN LA TABLA DETALLES" + public async Task Create (Detalles deta) { - //Detalles D = new Detalles(); - var ProcedimientoalmacenadoInser = "SpInsert"; - using (var connection = new SqlConnection(cn.CadenaSQL())) - { - var detalles = await connection.ExecuteAsync(ProcedimientoalmacenadoInser, - new - { - Idfactura = deta.IdFactura, - Nfactura = deta.Nfactura, - ArticuloNumber = deta.ArticuloNumber, - Articulo = deta.Articulo, - Cantidad = deta.Cantidad, - Precio = deta.Precio - }, commandType: CommandType.StoredProcedure); - - } + + + var ProcedimientoalmacenadoInser = "SpInsert"; + using (var connection = new SqlConnection(cn.CadenaSQL())) + { + var detalles = await connection.ExecuteAsync(ProcedimientoalmacenadoInser, + new + { + Idfactura = deta.IdFactura, + Nfactura = deta.Nfactura, + ArticuloNumber = deta.ArticuloNumber, + Articulo = deta.Articulo, + Cantidad = deta.Cantidad, + Precio = deta.Precio + },commandType: CommandType.StoredProcedure); + + } + + } - // METODO PARA ENVIAR FACTURA + #endregion + #region "METODO POST PARA EBVIAR DATOS EN LA TABLA FACTURA" public async Task CreateF(Factura fac) { @@ -84,10 +92,9 @@ namespace MyFirstAPI.Repositorio }, commandType: CommandType.StoredProcedure); } } + #endregion - - //METODO PARA ACTUALIZAR DETALLES - + #region"METODO PUT PARA ACTUALIZAR TABLA DETALLES" public async Task UPDATED (Detalles deta) { var ProcedimientoAlmacenadoUpdate = "SpUpdateDetalles"; @@ -107,10 +114,10 @@ namespace MyFirstAPI.Repositorio } } + #endregion - - - //Metodo Para Actualizar Factura + #region "METODO PUT PARA ACTUALIZAR LA TABLA FACTURA" + public async Task UpdateF (Factura fac) { var ProcedimientoAlmacendadoUpdateF = "SpUpdateFactura"; @@ -126,17 +133,15 @@ namespace MyFirstAPI.Repositorio Empresa = fac.Empresa, Subtotal = fac.Subtotal, TotalF = fac.Total - + }, commandType: CommandType.StoredProcedure); } } + #endregion - - - // METODO PARA ELIMINAR DETALLES - + #region "METODO DELETE PARA ELIMNAR DETALLES EN LA TABLA " public async Task Delete (int id) { @@ -153,8 +158,9 @@ namespace MyFirstAPI.Repositorio } } + #endregion - // metodo para eliminar facturas + #region"METODO PARA ELIMNAR FACTURA EN LA TABLA" public async Task DeleteF (int Idff) { var procedimientoAlmacenadoDeleteF = "SpEliminarFactura"; @@ -165,10 +171,10 @@ namespace MyFirstAPI.Repositorio new { Idf = Idff }, commandType: CommandType.StoredProcedure); } } - + #endregion } - + } diff --git a/bin/Debug/net6.0/MyFirstAPI.dll b/bin/Debug/net6.0/MyFirstAPI.dll index a4acd5b..0a5b810 100644 Binary files a/bin/Debug/net6.0/MyFirstAPI.dll and b/bin/Debug/net6.0/MyFirstAPI.dll differ diff --git a/bin/Debug/net6.0/MyFirstAPI.pdb b/bin/Debug/net6.0/MyFirstAPI.pdb index fc710ae..1b7451a 100644 Binary files a/bin/Debug/net6.0/MyFirstAPI.pdb and b/bin/Debug/net6.0/MyFirstAPI.pdb differ diff --git a/obj/Debug/net6.0/MyFirstAPI.dll b/obj/Debug/net6.0/MyFirstAPI.dll index a4acd5b..0a5b810 100644 Binary files a/obj/Debug/net6.0/MyFirstAPI.dll and b/obj/Debug/net6.0/MyFirstAPI.dll differ diff --git a/obj/Debug/net6.0/MyFirstAPI.pdb b/obj/Debug/net6.0/MyFirstAPI.pdb index fc710ae..1b7451a 100644 Binary files a/obj/Debug/net6.0/MyFirstAPI.pdb and b/obj/Debug/net6.0/MyFirstAPI.pdb differ diff --git a/obj/Debug/net6.0/ref/MyFirstAPI.dll b/obj/Debug/net6.0/ref/MyFirstAPI.dll index e76a7fd..ffd842d 100644 Binary files a/obj/Debug/net6.0/ref/MyFirstAPI.dll and b/obj/Debug/net6.0/ref/MyFirstAPI.dll differ diff --git a/obj/Debug/net6.0/refint/MyFirstAPI.dll b/obj/Debug/net6.0/refint/MyFirstAPI.dll index e76a7fd..ffd842d 100644 Binary files a/obj/Debug/net6.0/refint/MyFirstAPI.dll and b/obj/Debug/net6.0/refint/MyFirstAPI.dll differ