Example #1
0
        //Customer's Waitlist
        public IActionResult WaitlistShow()
        {
            LogRestaurant();
            if (TempData["ErrorMessage"] != null)
            {
                ViewBag.ErrorMessage = TempData["ErrorMessage"];
            }
            if (TempData["Message"] != null)
            {
                ViewBag.Message = TempData["Message"];
            }
            ClaimsPrincipal cp           = this.User;
            var             claims       = cp.Claims.ToList();
            var             custId       = Convert.ToInt32(claims.SingleOrDefault(p => p.Type == "CustomerID").Value);
            var             waitlist     = CustomersManager.GetActiveWaitlist(custId);
            var             viewWaitlist = waitlist.Select(r => new WaitCustomerModelView
            {
                RestaurantID     = (int)r.RestaurantId,
                CustomerId       = (int)r.CustomerId,
                Restaurant       = r.Restaurant.RestaurantName,
                WaitlistEntryId  = r.WaitlistEntryId,
                PartySizew       = r.PartySize,
                WaitlistStatus   = r.WaitlistStatus,
                EntryOriginw     = r.EntryOrigin,
                WaitlistPosition = "-"
            }).ToList();

            foreach (WaitCustomerModelView viewaux in viewWaitlist)
            {
                if (viewaux.WaitlistStatus == "active")
                {
                    int waitPos = RestaurantsManager.GetWaitlistPosition(viewaux.RestaurantID, viewaux.WaitlistEntryId);
                    viewaux.WaitlistPosition = Convert.ToString(waitPos);
                }
            }
            return(View(viewWaitlist));
        }