public async Task <ActionResult <BabyUnit> > PostBabyUnit(BabyUnit babyUnit) { _context.babyUnits.Add(babyUnit); await _context.SaveChangesAsync(); return(CreatedAtAction("GetBabyUnit", new { id = babyUnit.Id }, babyUnit)); }
public async Task <IActionResult> PutBabyUnit(int id, BabyUnit babyUnit) { if (id != babyUnit.Id) { return(BadRequest()); } _context.Entry(babyUnit).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BabyUnitExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }