Пример #1
0
        // GET: ReservationApprove
        public ActionResult Index(int?pageRes, int?pageSub, int?pageAllRes, int?pageAllSub, int?selectedTab)
        {
            string role = new Business.AccountBusiness().currentMember();

            if (role == "U")
            {
                return(RedirectToAction("Login", "Account"));
            }
            if (selectedTab != null)
            {
                TempData["selectedTab"] = selectedTab;
            }

            int pageSize         = 10;
            int pageNumberRes    = (pageRes ?? 1);
            int pageNumberSub    = (pageSub ?? 1);
            int pageNumberAllRes = (pageAllRes ?? 1);
            int pageNumberAllSub = (pageAllSub ?? 1);

            TempData["selectedTab"] = TempData["selectedTab"] == null ? 1 : TempData["selectedTab"];
            string     cookieName            = FormsAuthentication.FormsCookieName;           //Find cookie name
            HttpCookie authCookie            = HttpContext.Request.Cookies[cookieName];       //Get the cookie by it's name
            FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); //Decrypt it
            string UserName = ticket.Name;                                                    //You have the UserName!
            var    user     = webApi.GetUser(UserName);

            ApproveModel model = new ApproveModel();

            model.Reservations    = webApi.GetReservationsForApprove(user.USER_ID).ToPagedList(pageNumberRes, pageSize);
            model.Subscribers     = webApi.GetSubscribersForApprove(user.USER_ID).ToPagedList(pageNumberSub, pageSize);
            model.AllReservations = webApi.GetAllReservationsForFacilityOwner(user.USER_ID).ToPagedList(pageNumberAllRes, pageSize);
            model.AllSubscibers   = webApi.GetAllSubscribersForFacilityOwner(user.USER_ID).ToPagedList(pageNumberAllSub, pageSize);
            model.selectedTab     = TempData["selectedTab"].ToString();

            return(View(model));
        }