public Result <int> Post([FromBody] SpecialistForAddModel specialist) { if (specialist == null) { return(Result <int> .InvalidData); } 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 }); } int specialistID = specialistManagementService.AddSpecialist(specialistAddMapper.MapFrom(specialist)); return(new Result <int>(specialistID) { MessageType = MessageType.Created, MessageText = $"Specialist was successfully created with id {specialistID}" }); // return CreatedAtRoute(nameof(GetByID), new { id = specialistID }, specialist); }
public IActionResult AddSpecialist(SpecialistDTO newSpecialist) { specialistManagementService.AddSpecialist(newSpecialist); return(RedirectToAction("Specialists")); }