Exemple #1
0
        public ActionResult FiltrRoomAndHolidayHome(string country, string city, int guestnumber = 0, int bednumber = 0, DateTime?bookfrom = null, DateTime?bookto = null)
        {
            if (string.IsNullOrEmpty(country))
            {
                ModelState.AddModelError("country", "Country is Required");
            }

            if (string.IsNullOrEmpty(city))
            {
                ModelState.AddModelError("city", "City is Required");
            }


            if (bookfrom > bookto)
            {
                ModelState.AddModelError("bookfrom", "Book From is Later than Book To");
            }

            if (bookfrom == bookto && bookto != null)
            {
                ModelState.AddModelError("bookfrom", "Book From is equal Book To");
            }


            if (bookfrom <= DateTime.Now)
            {
                ModelState.AddModelError("bookfrom", "Book From should be later than today");
            }

            if (bookto <= DateTime.Now)
            {
                ModelState.AddModelError("bookto", "Book to should be later than today");
            }

            if (!ModelState.IsValid)
            {
                HolidayViewModel model = new HolidayViewModel();
                model = repository.GetRandomPlaces();


                return(View("Index", model));
            }


            return(RedirectToAction("FiltrResortHotel", new { country = country, city = city, guestnumber = guestnumber, bednumber = bednumber, bookfrom = bookfrom, bookto = bookto }));
        }