public async Task <IActionResult> PutEtrainGroup(short id, EtrainGroup etrainGroup) { if (id != etrainGroup.EtrainGroupId) { return(BadRequest()); } _context.Entry(etrainGroup).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EtrainGroupExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <EtrainGroup> > PostEtrainGroup(EtrainGroup etrainGroup) { _context.EtrainGroup.Add(etrainGroup); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (EtrainGroupExists(etrainGroup.EtrainGroupId)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetEtrainGroup", new { id = etrainGroup.EtrainGroupId }, etrainGroup)); }