public async Task <IActionResult> PutEmechanicalCoupler(short id, EmechanicalCoupler emechanicalCoupler) { if (id != emechanicalCoupler.EmechanicalCouplerId) { return(BadRequest()); } _context.Entry(emechanicalCoupler).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmechanicalCouplerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <EmechanicalCoupler> > PostEmechanicalCoupler(EmechanicalCoupler emechanicalCoupler) { _context.EmechanicalCoupler.Add(emechanicalCoupler); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (EmechanicalCouplerExists(emechanicalCoupler.EmechanicalCouplerId)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetEmechanicalCoupler", new { id = emechanicalCoupler.EmechanicalCouplerId }, emechanicalCoupler)); }