public async Task <IActionResult> PutEswitch(short id, Eswitch eswitch) { if (id != eswitch.EswitchId) { return(BadRequest()); } _context.Entry(eswitch).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EswitchExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Eswitch> > PostEswitch(Eswitch eswitch) { _context.Eswitch.Add(eswitch); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (EswitchExists(eswitch.EswitchId)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetEswitch", new { id = eswitch.EswitchId }, eswitch)); }