public async Task <ActionResult <CreateInstrumentDto> > PostAsync(CreateInstrumentDto item) { try { var result = await _service.CreateAndSaveAsync(item); //NOTE: to get this to work you MUST set the name of the HttpGet, e.g. [HttpGet("{id}", Name= "GetSingleTodo")], //on the Get you want to call, then then use the Name value in the Response. //Otherwise you get a "No route matches the supplied values" error. //see https://stackoverflow.com/questions/36560239/asp-net-core-createdatroute-failure for more on this return(_service.Response(this, "GetSingleInstrument", new { id = result.Id }, result)); } catch (DbUpdateException ex) { return(BadRequest(ex.InnerException.Message)); } }
public async Task <ActionResult <WebApiMessageOnly> > Name(CreateInstrumentDto dto) { await _service.UpdateAndSaveAsync(dto); return(_service.Response()); }