Пример #1
0
        public IActionResult PutIngrediente(int id, [FromBody] ReceitaIngrediente ingrediente)
        {
            if (id != ingrediente.Id)
            {
                return(BadRequest());
            }

            try
            {
                ingredienteService.Atualizar(ingrediente);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ReceitaExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #2
0
        public HttpResponseMessage Editar([FromBody] IngredienteAtualizarViewModel viewModel)
        {
            if (viewModel == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "Json inválido."));
            }

            var dtoReturn = _service.Atualizar(viewModel);

            if (dtoReturn.Erros.Count > 0)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, dtoReturn.Erros));
            }

            return(Request.CreateResponse(HttpStatusCode.Created, dtoReturn.Ingrediente));
        }