public ActionResult CityPreview(int Cityid) { City city = db.Cities.Include("Country") .Include("Images") .SingleOrDefault(x => x.Id == Cityid); List <Flight> flights = db.Flights.Include("SourceCity").Include("DestinationCity") .Where(x => x.DestinationCity.Id == Cityid && x.Date > DateTime.Now) .ToList(); List <Hotel> hotels = db.Hotels.Include("City") .Include("Images") .Where(x => x.City.Id == Cityid) .ToList(); CityPreviewViewModel cp = new CityPreviewViewModel() { City = city, Flights = flights, Hotels = hotels }; switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-us": ViewBag.SourceCity = new SelectList(db.Cities.Where(x => x.Id != Cityid).ToList(), "Id", "Name_En"); break; case "ar-SA": ViewBag.SourceCity = new SelectList(db.Cities.Where(x => x.Id != Cityid).ToList(), "Id", "Name_Ar"); break; default: ViewBag.SourceCity = new SelectList(db.Cities.Where(x => x.Id != Cityid).ToList(), "Id", "Name_En"); break; } List <string> stars = new List <string>(); stars.Add("*"); stars.Add("**"); stars.Add("***"); stars.Add("****"); stars.Add("*****"); stars.Add("******"); stars.Add("*******"); ViewBag.Stars = new SelectList(stars); ViewBag.Airline = new SelectList(db.Flights.Select(x => x.Airline).Distinct().ToList()); return(View(cp)); }
public PartialViewResult GetFlightsToCity(int Cityid, int SourceCity, string Airline) { List <Flight> flights = db.Flights.Include("SourceCity").Include("DestinationCity") .Where(x => x.DestinationCity.Id == Cityid && (x.SourceCity.Id == SourceCity || SourceCity == null) && (x.Airline == Airline || string.IsNullOrEmpty(Airline))) .ToList(); City city = db.Cities.Include("Country") .Include("Images") .SingleOrDefault(x => x.Id == Cityid); CityPreviewViewModel cp = new CityPreviewViewModel() { City = city, Flights = flights }; return(PartialView("_CityFlightsPartial", cp)); }
public PartialViewResult GetCityHotels(int Cityid, string Stars, string HotelName) { List <Hotel> hotels = db.Hotels.Include("Images") .Where(x => (x.Stars == Stars.Length || string.IsNullOrEmpty(Stars)) && x.City.Id == Cityid) .ToList(); switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": hotels = hotels.Where(x => x.Name_En.ToLower().Contains(HotelName.ToLower()) || string.IsNullOrEmpty(HotelName)) .OrderBy(x => x.Name_En) .ToList(); break; case "ar-SA": hotels = hotels.Where(x => x.Name_Ar.Contains(HotelName) || string.IsNullOrEmpty(HotelName)) .OrderBy(x => x.Name_Ar) .ToList(); break; default: hotels = hotels.Where(x => x.Name_En.ToLower().Contains(HotelName.ToLower()) || string.IsNullOrEmpty(HotelName)) .OrderBy(x => x.Name_En) .ToList(); break; } City city = db.Cities.Include("Country") .Include("Images") .SingleOrDefault(x => x.Id == Cityid); CityPreviewViewModel cp = new CityPreviewViewModel() { City = city, Hotels = hotels }; return(PartialView("_CityHotelsPartial", cp)); }