コード例 #1
0
        public IActionResult HostManage()
        {
            LogRestaurant();
            ClaimsPrincipal cp       = this.User;
            var             claims   = cp.Claims.ToList();
            var             restId   = Convert.ToInt32(claims.SingleOrDefault(p => p.Type == "RestaurantID").Value);
            var             waitlist = RestaurantsManager.GetWaitlistByRestaurantID(restId);
            List <WaitCustomerModelView> viewWaitlist = new List <WaitCustomerModelView>();

            foreach (WaitlistEntry waitAux in waitlist)
            {
                var customer          = CustomersManager.GetCustomerByCustomerId(waitAux.CustomerId);
                var viewWaitlistEntry = new WaitCustomerModelView
                {
                    RestaurantID     = (int)waitAux.RestaurantId,
                    CustomerId       = (int)waitAux.CustomerId,
                    CustomerName     = $"{customer.User.FirstName} {customer.User.LastName}",
                    Restaurant       = waitAux.Restaurant.RestaurantName,
                    WaitlistEntryId  = waitAux.WaitlistEntryId,
                    PartySizew       = waitAux.PartySize,
                    WaitlistStatus   = waitAux.WaitlistStatus,
                    EntryOriginw     = waitAux.EntryOrigin,
                    WaitlistPosition = Convert.ToString(RestaurantsManager.GetWaitlistPosition(restId, waitAux.WaitlistEntryId))
                };
                viewWaitlist.Add(viewWaitlistEntry);
            }
            var orderViewWaitlist = viewWaitlist.OrderBy(w => w.WaitlistPosition);

            ViewBag.RestaurantID = restId;
            return(View(orderViewWaitlist));
        }
コード例 #2
0
        //Edit Waitlist Party
        public IActionResult WaitlistEditParty(int id)
        {
            LogRestaurant();
            if (TempData["ErrorMessage"] != null)
            {
                ViewBag.ErrorMessage = TempData["ErrorMessage"];
            }
            if (TempData["Message"] != null)
            {
                ViewBag.Message = TempData["Message"];
            }
            var waitlist = RestaurantsManager.GetWaitlistById(id);
            var viewWait = new WaitCustomerModelView
            {
                CustomerId       = (int)waitlist.CustomerId,
                Restaurant       = waitlist.Restaurant.RestaurantName,
                WaitlistEntryId  = waitlist.WaitlistEntryId,
                PartySizew       = waitlist.PartySize,
                WaitlistStatus   = waitlist.WaitlistStatus,
                EntryOriginw     = waitlist.EntryOrigin,
                WaitlistPosition = "-"
            };

            if (waitlist.WaitlistStatus == "active")
            {
                int waitPos = RestaurantsManager.GetWaitlistPosition((int)waitlist.RestaurantId, waitlist.WaitlistEntryId);
                viewWait.WaitlistPosition = Convert.ToString(waitPos);
            }
            return(View(viewWait));
        }
コード例 #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"));
                    }
                }
            }
        }
コード例 #4
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));
             }
         }
     }
 }
コード例 #5
0
        //Add Waitlist Entry
        public IActionResult WaitlistCreate()
        {
            LogRestaurant();
            if (TempData["ErrorMessage"] != null)
            {
                ViewBag.ErrorMessage = TempData["ErrorMessage"];
            }
            if (TempData["Message"] != null)
            {
                ViewBag.Message = TempData["Message"];
            }
            ViewBag.Restaurants = BasicGetRestaurants();

            var viewWaitlist = new WaitCustomerModelView
            {
                PartySizew = 1
            };

            return(View(viewWaitlist));
        }
コード例 #6
0
        //Customer's Waitlist entry details from Waitlist
        public IActionResult WaitlistDetails(int id)
        {
            LogRestaurant();
            var waitlist = RestaurantsManager.GetWaitlistById(id);
            var viewWait = new WaitCustomerModelView
            {
                CustomerId       = (int)waitlist.CustomerId,
                Restaurant       = waitlist.Restaurant.RestaurantName,
                WaitlistEntryId  = waitlist.WaitlistEntryId,
                PartySizew       = waitlist.PartySize,
                WaitlistStatus   = waitlist.WaitlistStatus,
                EntryOriginw     = waitlist.EntryOrigin,
                WaitlistPosition = "-"
            };

            if (waitlist.WaitlistStatus == "active")
            {
                int waitPos = RestaurantsManager.GetWaitlistPosition((int)waitlist.RestaurantId, waitlist.WaitlistEntryId);
                viewWait.WaitlistPosition = Convert.ToString(waitPos);
            }
            return(View(viewWait));
        }