public async Task <ActionResult <Instrument> > PostInstrument(Instrument instrument) { this.db.Instruments.Add(instrument); await this.db.SaveChangesAsync(); return(CreatedAtAction("GetInstrument", new { id = instrument.Id }, instrument)); }
public async Task <IActionResult> PutInstrument(int id, Instrument instrument) { if (id != instrument.Id) { return(BadRequest()); } this.db.Entry(instrument).State = EntityState.Modified; try { await this.db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InstrumentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }