Esempio n. 1
0
        public static void CreateWaitlist(WaitlistEntry waitlist)
        {
            var context = new TableReadyContext();

            context.WaitlistEntry.Add(waitlist);
            context.SaveChanges();
        }
Esempio n. 2
0
        public static void UpdatePartySizeWaitlist(WaitlistEntry waitlist)
        {
            var context          = new TableReadyContext();
            var originalWaitlist = context.WaitlistEntry.SingleOrDefault(p => p.WaitlistEntryId == waitlist.WaitlistEntryId);

            originalWaitlist.PartySize = waitlist.PartySize;
            context.SaveChanges();
        }
Esempio n. 3
0
        public IActionResult WaitlistCreate(WaitCustomerModelView viewWaitlist)
        {
            LogRestaurant();
            ClaimsPrincipal cp     = this.User;
            var             claims = cp.Claims.ToList();
            var             custId = Convert.ToInt32(claims.SingleOrDefault(p => p.Type == "CustomerID").Value);

            if (viewWaitlist.PartySizew <= 0)
            {
                TempData["Message"]      = null;
                TempData["ErrorMessage"] = "Sorry!!! Your Waitlist entry couldn't be created. Party size must be a non-zero positive number";

                return(RedirectToAction("WaitlistCreate"));
            }
            else
            {
                if (viewWaitlist.PartySizew >= 100)
                {
                    TempData["Message"]      = null;
                    TempData["ErrorMessage"] = "Sorry!!! Your Waitlist entry couldn't be created. Party size not supported by the Restaurant.";
                    return(RedirectToAction("WaitlistCreate"));
                }
                else
                {
                    if (RestaurantsManager.RestaurantActiveWaitlistByCustomer(viewWaitlist.RestaurantID, custId) == false)
                    {
                        var waitlist = new WaitlistEntry
                        {
                            EntryOrigin    = "app",
                            PartySize      = viewWaitlist.PartySizew,
                            CustomerId     = custId,
                            RestaurantId   = viewWaitlist.RestaurantID,
                            WaitlistStatus = "active",
                        };
                        try
                        {
                            RestaurantsManager.CreateWaitlist(waitlist);
                            TempData["Message"]      = "Your NEW Waitlist entry is Active!!!";
                            TempData["ErrorMessage"] = null;
                            return(RedirectToAction(nameof(WaitlistShow)));
                        }
                        catch
                        {
                            return(View());
                        }
                    }
                    else
                    {
                        TempData["Message"]      = null;
                        TempData["ErrorMessage"] = "Sorry!!! Each customer can have only one active Waitlist entry per Restaurant.";
                        ViewBag.Restaurants      = BasicGetRestaurants();
                        return(RedirectToAction("WaitlistCreate"));
                    }
                }
            }
        }
Esempio n. 4
0
        public static void UpdateWaitlist(WaitlistEntry waitlist)
        {
            var context          = new TableReadyContext();
            var originalWaitlist = context.WaitlistEntry.SingleOrDefault(we => we.WaitlistEntryId == waitlist.WaitlistEntryId);

            originalWaitlist.EntryOrigin    = waitlist.EntryOrigin;
            originalWaitlist.PartySize      = waitlist.PartySize;
            originalWaitlist.WaitlistStatus = waitlist.WaitlistStatus;
            context.SaveChanges();
        }
Esempio n. 5
0
        public static void UpdateWaitlist(WaitlistEntry waitEntry)
        {
            var context = new TableReadyContext();
            var originalWailisttEntry = context.WaitlistEntry.SingleOrDefault(p => p.WaitlistEntryId == waitEntry.WaitlistEntryId);

            originalWailisttEntry.PartySize      = waitEntry.PartySize;
            originalWailisttEntry.WaitlistStatus = waitEntry.WaitlistStatus;
            originalWailisttEntry.EntryOrigin    = waitEntry.EntryOrigin;
            originalWailisttEntry.CheckinDate    = waitEntry.CheckinDate;
            context.SaveChanges();
        }
Esempio n. 6
0
 public ActionResult WaitlistEditParty(WaitCustomerModelView viewWaitlist)
 {
     LogRestaurant();
     if (viewWaitlist.PartySizew <= 0)
     {
         TempData["Message"]      = null;
         TempData["ErrorMessage"] = "Sorry!!! Your Waitlist entry couldn't be updated. PartySize must be a non-zero positive integer";
         var waitlist = RestaurantsManager.GetWaitlistById(viewWaitlist.WaitlistEntryId);
         viewWaitlist.PartySizew = waitlist.PartySize;
         return(RedirectToAction("WaitlistEditParty", waitlist.WaitlistEntryTable));
     }
     else
     {
         if (viewWaitlist.PartySizew >= 100)
         {
             TempData["Message"]      = null;
             TempData["ErrorMessage"] = "Sorry!!! Your Waitlist entry couldn't be updated. Party size not supported by the Restaurant.";
             var waitlist = RestaurantsManager.GetWaitlistById(viewWaitlist.WaitlistEntryId);
             viewWaitlist.PartySizew = waitlist.PartySize;
             return(RedirectToAction("WaitlistEditParty", waitlist.WaitlistEntryTable));
         }
         else
         {
             var waitlist = new WaitlistEntry
             {
                 WaitlistEntryId = viewWaitlist.WaitlistEntryId,
                 PartySize       = viewWaitlist.PartySizew
             };
             try
             {
                 RestaurantsManager.UpdatePartySizeWaitlist(waitlist);
                 TempData["Message"]      = "Your Waitlist entry was updated.";
                 TempData["ErrorMessage"] = null;
                 return(RedirectToAction(nameof(WaitlistShow)));
             }
             catch
             {
                 TempData["Message"]      = null;
                 TempData["ErrorMessage"] = "Sorry!! It was not possible to Update your party size. Try again later!!!";
                 waitlist = RestaurantsManager.GetWaitlistById(viewWaitlist.WaitlistEntryId);
                 viewWaitlist.PartySizew = waitlist.PartySize;
                 return(RedirectToAction("WaitlistEditParty", waitlist.WaitlistEntryTable));
             }
         }
     }
 }