コード例 #1
0
        public ActionResult <ProductoViewModel> ActualizarCantidad(int cantidad, string codigo)
        {
            var response = _serviceProducto.ActualizarCantidad(cantidad, codigo);

            if (response.Error)
            {
                ModelState.AddModelError("Error al editar el producto", response.Mensaje);
                var detallesproblemas = new ValidationProblemDetails(ModelState);

                if (response.Estado == "Error")
                {
                    detallesproblemas.Status = StatusCodes.Status500InternalServerError;
                }
                if (response.Estado == "NoExiste")
                {
                    detallesproblemas.Status = StatusCodes.Status404NotFound;
                }
                return(BadRequest(detallesproblemas));
            }
            return(Ok(new ProductoViewModel(response.Producto)));
        }