Beispiel #1
0
        public async Task <IActionResult> PutFacturaAlmacen([FromBody] FacturaAlmacenVM FacturaVM)
        {
            try
            {
                var resultado = await _AlmacenService.PutFacturaAlmacen(FacturaVM);

                return(Ok(resultado));
            }
            catch (Exception ex)
            {
                var mensaje = ex.Message.ToString();
                return(BadRequest());
            }
        }
        public async Task <ResultViewModel> PutFacturaAlmacen(FacturaAlmacenVM facturaVM)
        {
            using (var Conexion = new SqlConnection(Helpers.ContextConfiguration.ConexionString))
            {
                var resultado = new ResultViewModel();
                try
                {
                    var     comando = new SqlCommand();
                    decimal Costo   = decimal.Parse(facturaVM.CostoNeto.ToString().Trim());
                    comando.Connection  = Conexion;
                    comando.CommandText = "[Almacen].[EntradasAlmacen]";
                    comando.CommandType = System.Data.CommandType.StoredProcedure;
                    /*Agregando los parametros*/
                    comando.Parameters.AddWithValue("@Opcion", "AgregarFactura");
                    comando.Parameters.AddWithValue("@CostoNeto", Costo);
                    comando.Parameters.AddWithValue("@FechaFactura", facturaVM.Fecha);
                    comando.Parameters.AddWithValue("@Id", facturaVM.IdProveedor);
                    comando.Parameters.AddWithValue("@NoDocumento", facturaVM.NoFactura);
                    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;
                }
            }
        }