public IActionResult Create(AchCustomerAlergen newItem) { var newId = _context.AchCustomerAlergen.OrderByDescending(i => i.CustomerAlergenId).FirstOrDefault().CustomerAlergenId + 1; newItem.CustomerAlergenId = newId; _context.AchCustomerAlergen.Add(newItem); _context.SaveChanges(); return(StatusCode(201, newItem)); }
public IActionResult Update(int item_id, AchCustomerAlergen updated_item) { var item = _context.AchCustomerAlergen.Count(e => e.CustomerAlergenId == item_id); if (item == 0) { return(NotFound()); } _context.AchCustomerAlergen.Attach(updated_item); _context.Entry(updated_item).State = EntityState.Modified; _context.SaveChanges(); return(Ok(updated_item)); }