Example #1
0
        public ActionResult Search(string phrase)
        {
            HotelDao      hd        = new HotelDao();
            IList <Hotel> hotels    = hd.searchHotel(phrase);
            ZajezdDao     zajezdDao = new ZajezdDao();

            foreach (Hotel hotel in hotels)
            {
                hotel.nejlevnejsiZajezd = zajezdDao.GetNejlevnejsiZajezd(hotel.Id);
            }
            if (Request.IsAjaxRequest())
            {
                return(PartialView("Index", hotels));
            }
            return(View("Index", hotels));
        }
Example #2
0
        public ActionResult Destinace(int id)
        {
            if (id == 0)
            {
                return(View("Index", new HotelDao().GetAll()));
            }
            IList <Hotel> hotels = new HotelDao().GetHotelsInDestination(id);

            ViewBag.Destinace = new DestinaceDao().GetDestinationByState(id);
            ViewBag.Staty     = new StatDao().GetAll();
            ZajezdDao zajezdDao = new ZajezdDao();

            foreach (Hotel hotel in hotels)
            {
                hotel.nejlevnejsiZajezd = zajezdDao.GetNejlevnejsiZajezd(hotel.Id);
            }
            return(View("Index", hotels));
        }
Example #3
0
        // GET: Zajezdy
        public ActionResult Index(int?page, int?view, DateTime?datumOd, DateTime?datumDo)
        {
            int           totalPages;
            int           totalHotels;
            int           pg          = 1;
            int           itemsOnPage = 5;
            IList <Hotel> hotels;

            if (page.HasValue)
            {
                pg = page.Value;
            }
            pg = (pg <= 0) ? 1 : pg;

            totalHotels = GetHotelCount(view, datumOd, datumDo);
            totalPages  = totalHotels / itemsOnPage;

            if (totalPages == 0)
            {
                totalPages = 1;
            }
            if (pg > totalPages)
            {
                pg = totalPages;
            }

            hotels = GetHotels(itemsOnPage, pg, view, datumOd, datumDo);

            ViewBag.Pages = (int)Math.Ceiling((double)totalHotels / (double)itemsOnPage);

            if (view.HasValue)
            {
                ViewBag.ViewMode = view.Value;
            }
            if (datumOd.HasValue)
            {
                ViewBag.DatumOd = datumOd.Value;
            }
            if (datumDo.HasValue)
            {
                ViewBag.DatumDo = datumDo.Value;
            }

            ViewBag.CurrentPage = pg;

            if (pg < 3)
            {
                ViewBag.FirstPage = 1;
                ViewBag.LastPage  = 5;
            }
            else
            {
                ViewBag.FirstPage = pg - 2;
                ViewBag.LastPage  = pg + 2;
            }

            if (ViewBag.LastPage > totalPages)
            {
                ViewBag.LastPage = totalPages;
            }

            ViewBag.Staty = new StatDao().GetAll();
            ZajezdDao zajezdDao = new ZajezdDao();

            foreach (Hotel hotel in hotels)
            {
                hotel.nejlevnejsiZajezd = zajezdDao.GetNejlevnejsiZajezd(hotel.Id);
            }

            if (Request.IsAjaxRequest())
            {
                return(PartialView(hotels));
            }

            return(View(hotels));
        }