public void DeleteWaiter(Waiters item) { using (RestaurantContext context = new RestaurantContext()) { var existing = context.Waiters.Find(item.WaiterID); context.Waiters.Remove(existing); context.SaveChanges(); } }
public void UpdateWaiter(Waiters item) { using (RestaurantContext context = new RestaurantContext()) { var attached = context.Waiters.Attach(item); var existing = context.Entry<Waiters>(attached); existing.State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public int AddWaiter(Waiters item) { using (RestaurantContext context = new RestaurantContext()) { // todo validation rules... var added = context.Waiters.Add(item); context.SaveChanges(); return added.WaiterID; } }