public IActionResult Create(AchCustomer newCustomer) { var newId = _context.AchCustomer.OrderByDescending(i => i.IdCustomer).FirstOrDefault().IdCustomer + 1; newCustomer.IdCustomer = newId; _context.AchCustomer.Add(newCustomer); _context.SaveChanges(); return(StatusCode(201, newCustomer)); }
public IActionResult Update(int id, AchCustomer updatedCustomer) { if (_context.AchCustomer.Count(e => e.IdCustomer == id) == 0) { return(NotFound()); } _context.AchCustomer.Attach(updatedCustomer); _context.Entry(updatedCustomer).State = EntityState.Modified; _context.SaveChanges(); return(Ok(updatedCustomer)); }