public Result <int> Patch(int id, [FromBody] SpecialistForUpdateModel specialistUpdateModel) { if (specialistUpdateModel == null) { return(Result <int> .InvalidData); } SpecialistDTO foundSpecialist = specialistManagementService.GetById(id); if (foundSpecialist == null) { return new Result <int>() { MessageType = MessageType.NotFound, MessageText = $"Specialist with id {id} was not found" } } ; if (!ModelState.IsValid) { string errors = string.Join(" | ", ModelState.Values .SelectMany(v => v.Errors) .Select(e => e.ErrorMessage)); return(new Result <int>() { MessageType = MessageType.InvalidData, MessageText = errors }); } specialistUpdateModel.Id = id; specialistManagementService.Update(specialistUpdateMapper.MapFrom(specialistUpdateModel)); return(new Result <int>(id) { MessageType = MessageType.Ok, MessageText = $"Specialist with ID {id} was successfully updated" }); }
public IActionResult EditSpecialist(SpecialistViewModel specialist) { specialistManagementService.Update(specialistMapper.MapFrom(specialist)); return(RedirectToAction("Specialists")); }