Exemplo n.º 1
0
        public ActionResult Index(UserReservationSearch search, int?page, string offerName, string hotelName, string dateFrom,
                                  string dateTo, string peopleFrom, string peopleTo, string priceFrom, string priceTo)
        {
            ViewBag.CurrentSearch = new UserReservationSearch();
            ViewBag.empty         = null;
            if (search != null)
            {
                page = 1;
                ViewBag.CurrentSearch = search;
            }
            else
            {
                ViewBag.CurrentSearch.offerName  = offerName;
                ViewBag.CurrentSearch.hotelName  = hotelName;
                ViewBag.CurrentSearch.dateFrom   = dateFrom;
                ViewBag.CurrentSearch.dateTo     = dateTo;
                ViewBag.CurrentSearch.peopleFrom = peopleFrom;
                ViewBag.CurrentSearch.peopleTo   = peopleTo;
                ViewBag.CurrentSearch.priceFrom  = priceFrom;
                ViewBag.CurrentSearch.priceTo    = priceTo;
                search = ViewBag.CurrentSearch;
            }

            int pageSize   = 10;
            int pageNumber = (page ?? 1);
            var user       = HttpContext.User.Identity;
            var idUser     = _accountSqlExecutor.GetUserId(user.Name);

            var reservations           = _reservationsSqlExecutor.FilterUserReservations(idUser, search);
            UserReservationModel model = new UserReservationModel {
                Reservations = reservations.ToPagedList <UserReservationFullData>(pageNumber, pageSize), Search = search
            };

            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult Index(HotelsSearch search, string name, string address, string userRateFrom, string userRateTo,
                                  string yourRateFrom, string yourRateTo, string distance, string lat, string lng, int?page)
        {
            ViewBag.CurrentSearch = new HotelsSearch();
            ViewBag.Empty         = null;
            if (search != null)
            {
                page = 1;
                ViewBag.CurrentSearch = search;
                search.lat            = lat;
                search.lng            = lng;
            }
            else
            {
                ViewBag.CurrentSearch.nameSearch    = name;
                ViewBag.CurrentSearch.addressSearch = address;
                ViewBag.CurrentSearch.usersRateFrom = userRateFrom;
                ViewBag.CurrentSearch.usersRateTo   = userRateTo;
                ViewBag.CurrentSearch.yourRateFrom  = yourRateFrom;
                ViewBag.CurrentSearch.yourRateTo    = yourRateTo;
                ViewBag.CurrentSearch.distance      = distance;
                ViewBag.CurrentSearch.lat           = lat;
                ViewBag.CurrentSearch.lng           = lng;
                search = ViewBag.CurrentSearch;
            }
            int  pageSize   = 10;
            int  pageNumber = (page ?? 1);
            bool canRate    = User.Identity.IsAuthenticated;
            var  user       = HttpContext.User.Identity;
            var  idUser     = _accountSqlExecutor.GetUserId(user.Name);
            var  canEdit    = false;

            if (user.Name == "Admin")
            {
                canEdit = true;
            }
            var         hotels = _hotelsSqlExecutor.FilterHotels(search, canRate, idUser);
            HotelsModel model  = new HotelsModel {
                Hotels = hotels.ToPagedList <Hotel>(pageNumber, pageSize), CanEdit = canEdit, CanRate = canRate, Search = search
            };

            return(View(model));
        }