Exemplo n.º 1
0
        public ActionResult Put(Guid id, [FromBody] Reason reason)
        {
            if (id != reason.Id)
            {
                return(BadRequest(
                           new ErrorData(StatusCodes.Status400BadRequest, "There was an error in your request",
                                         new List <string> {
                    "Ids should be the same in the route and the payload"
                })));
            }

            var model = _reasonService.GetReasonById(id);

            if (model == null)
            {
                return(NotFound(new ErrorData(StatusCodes.Status404NotFound, "Not found", null)));
            }
            _mapper.Map(reason, model);
            _reasonService.UpdateReason(model);
            return(NoContent());
        }