コード例 #1
0
        public ActionResult UpdateRequestStatus([FromBody] ProjectRequestPayload payload)
        {
            var modelFromRepo = _repo.GetProjectRequest(payload.UserId, payload.SlotId);

            if (modelFromRepo == null)
            {
                return(NotFound());
            }
            var prToPatch = _mapper.Map <ProjectRequestUpdateDto>(modelFromRepo);

            payload.PatchDocument.ApplyTo(prToPatch, ModelState);
            if (!TryValidateModel(prToPatch))
            {
                return(ValidationProblem(ModelState));
            }
            _mapper.Map(prToPatch, modelFromRepo);
            _repo.UpdateProjectRequest(modelFromRepo, payload.ProjectId);
            _repo.SaveChanges();
            return(NoContent());
        }