public IActionResult Post([FromBody] ServiceUpdateDto create) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Service item = _mapper.Map <ServiceUpdateDto, Service>(create); return(Created(_mapper.Map <Service, ServiceViewDto>(item))); }
public IActionResult Patch(ushort id, [FromBody] Delta <ServiceUpdateDto> delta) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Service item = _data.FirstOrDefault(e => e.Id == id); if (item == null) { return(NotFound()); } ServiceUpdateDto update = _mapper.Map <Service, ServiceUpdateDto>(item); delta.Patch(update); _mapper.Map(update, item); return(Updated(_mapper.Map <Service, ServiceViewDto>(item))); }