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