public ActionResult <InstrumentModel> CreateInstrument([FromBody] InstrumentModel instrument) { try { var newInstrument = service.CreateInstrument(instrument); return(Created($"/api/Instruments/{newInstrument.Id}", newInstrument)); } catch (NotFoundException ex) { return(NotFound(ex.Message)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
public async Task CreateInstrument([FromBody] Instrument instrument) { await _instrumentService.CreateInstrument(instrument); }
public async Task <IActionResult> GetFactoryGuitar(CancellationToken cancellationToken) { var instrument = _instrumentService.CreateInstrument(InstrumentType.Guitar); return(Ok(instrument)); }