예제 #1
0
        public ActionResult UpdatePathology([FromQuery] int Id, JsonPatchDocument <StatusUpdateDTO> patchDoc)
        {
            // Check if exists
            var statusFromRepo = _repository.Exist(Id);

            if (statusFromRepo == null)
            {
                return(NotFound());
            }

            var statusToPatch = _mapper.Map <StatusUpdateDTO>(statusFromRepo);

            patchDoc.ApplyTo(statusToPatch, ModelState);

            if (!TryValidateModel(statusToPatch))
            {
                return(ValidationProblem(ModelState));
            }

            _mapper.Map(statusToPatch, statusFromRepo);

            _repository.Update(statusFromRepo);
            _repository.SaveChanges();

            return(NoContent());
        }