public async Task <IActionResult> UpdateInventarioAlmacen([FromBody] ArticulosInventarioVM ArticuloInventario) { try { var resultado = await _AlmacenService.UpdateInventarioAlmacen(ArticuloInventario); return(Ok(resultado)); } catch (Exception ex) { var mensaje = ex.Message.ToString(); return(BadRequest()); } }
public async Task <List <ArticulosInventarioVM> > BuscarArticuloInventario(string tipo, string valor) { using (var Conexion = new SqlConnection(Helpers.ContextConfiguration.ConexionString)) { //var resultado = new FacturasAlmacenVM() { Exito = false, Mensaje = "Existe un error en Servidor" }; try { var listaEntradas = new List <ArticulosInventarioVM>(); var comando = new SqlCommand(); comando.Connection = Conexion; comando.CommandText = "[Almacen].[InventariodeAlmacen]"; comando.CommandType = System.Data.CommandType.StoredProcedure; /*Agregando los parametros*/ comando.Parameters.AddWithValue("@Opcion", "BuscarInventario"); comando.Parameters.AddWithValue("@Tipo", tipo.Trim()); comando.Parameters.AddWithValue("@Valor", valor.Trim()); Conexion.Open(); var Lectura = await comando.ExecuteReaderAsync(); if (Lectura.HasRows) { while (Lectura.Read()) { ArticulosInventarioVM resultado = new ArticulosInventarioVM(); resultado.IdInventario = Lectura.GetGuid(0); resultado.IdArticulo = Lectura.GetGuid(1); resultado.ClaveProducto = Lectura.GetString(2); resultado.Descripcion = Lectura.GetString(3); resultado.CodigoBarras = Lectura.GetString(4); resultado.PrecioCompra = Lectura.GetDecimal(5); resultado.ExistenciasUnidad = Lectura.GetInt32(6); resultado.Estado = Lectura.GetInt32(7); resultado.TipoArticulo = Lectura.GetString(8); resultado.PrecioVenta = Lectura.GetDecimal(9); resultado.Unidad = Lectura.GetString(10); resultado.TipoUnidad = Lectura.GetInt32(11); listaEntradas.Add(resultado); } } Conexion.Close(); return(listaEntradas); } catch (Exception e) { var m = e.Message.ToString(); throw e; } } }
public async Task <ArticulosInventarioVM> BuscarArticuloInventario(string tipo, string valor) { using (var Conexion = new SqlConnection(Helpers.ContextConfiguration.ConexionString)) { var resultado = new ArticulosInventarioVM(); try { var comando = new SqlCommand(); comando.Connection = Conexion; comando.CommandText = "[Almacen].[BuscarArticuloInventario]"; comando.CommandType = System.Data.CommandType.StoredProcedure; /*Agregando los parametros*/ comando.Parameters.AddWithValue("@Valor", valor.Trim()); comando.Parameters.AddWithValue("@TipoBusqueda", tipo.Trim()); Conexion.Open(); var Lectura = await comando.ExecuteReaderAsync(); if (Lectura.HasRows) { while (Lectura.Read()) { resultado.IdArticulo = Lectura.GetGuid(1); resultado.ClaveProducto = Lectura.GetString(2); resultado.CodigoBarras = Lectura.GetString(3); resultado.Descripcion = Lectura.GetString(4); resultado.ExistenciasUnidad = Lectura.GetInt32(8); resultado.Estado = Lectura.GetInt32(11); } } Conexion.Close(); return(resultado); } catch (Exception e) { var m = e.Message.ToString(); throw e; } } }
public async Task <ResultViewModel> UpdateInventarioAlmacen(ArticulosInventarioVM articuloInventario) { using (var Conexion = new SqlConnection(Helpers.ContextConfiguration.ConexionString)) { var resultado = new ResultViewModel(); try { var comando = new SqlCommand(); comando.Connection = Conexion; comando.CommandText = "[Almacen].[InventariodeAlmacen]"; comando.CommandType = System.Data.CommandType.StoredProcedure; /*Agregando los parametros*/ comando.Parameters.AddWithValue("@Opcion", "Modificar"); comando.Parameters.AddWithValue("@IdArticulo", articuloInventario.IdArticulo); comando.Parameters.AddWithValue("@Precio", articuloInventario.PrecioCompra); comando.Parameters.AddWithValue("@PrecioOriginal", articuloInventario.PrecioCompraOriginal); comando.Parameters.AddWithValue("@PrecioVenta", articuloInventario.PrecioVenta); comando.Parameters.AddWithValue("@Existencias", articuloInventario.ExistenciasUnidad); comando.Parameters.AddWithValue("@Duplicado", articuloInventario.Duplicado); Conexion.Open(); var Lectura = await comando.ExecuteReaderAsync(); if (Lectura.HasRows) { while (Lectura.Read()) { resultado.Exito = Lectura.GetBoolean(0); resultado.Mensaje = Lectura.GetString(1); } } Conexion.Close(); return(resultado); } catch (Exception e) { var m = e.Message.ToString(); throw e; } } }