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

            var dtoReturn = _service.Inserir(viewModel);

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

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