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