A dining room is divided into zones, each zones containing seats and tables which are placed under the responsibility of a waiter.
 public ActionResult Create(Zone zone)
 {
     if (ModelState.IsValid) {
         zoneRepository.InsertOrUpdate(zone);
         zoneRepository.Save();
         return RedirectToAction("Index");
     } else {
         ViewBag.PossibleWaiters = waiterRepository.All;
         ViewBag.PossibleRestaurants = restaurantRepository.All;
         return View();
     }
 }
Example #2
0
 public void InsertOrUpdate(Zone zone)
 {
     if (zone.Id == default(System.Guid)) {
         // New entity
         zone.Id = Guid.NewGuid();
         context.Zones.Add(zone);
     } else {
         // Existing entity
         context.Entry(zone).State = EntityState.Modified;
     }
 }