//Changing website language public ActionResult ChangeLanguage(string lang) { new SiteLanguages().SetLanguage(lang); ApplicationDbContext db = new ApplicationDbContext(); if (User.Identity.IsAuthenticated) { var user = db.Users.Find(User.Identity.GetUserId()); switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": user.PreferredInterfaceLanguage = "English"; break; case "ar-SA": user.PreferredInterfaceLanguage = "Arabic"; break; default: user.PreferredInterfaceLanguage = "English"; break; } db.SaveChanges(); } return(Redirect(Request.UrlReferrer.PathAndQuery)); }
protected override IAsyncResult BeginExecuteCore(AsyncCallback callback, object state) { string lang = null; HttpCookie langCookie = Request.Cookies["culture"]; if (langCookie != null) { lang = langCookie.Value; } else { var userLanguage = Request.UserLanguages; var userLang = userLanguage != null ? userLanguage[0] : ""; if (userLang != "") { lang = userLang; } else { lang = SiteLanguages.GetDefaultLanguage(); } } new SiteLanguages().SetLanguage(lang); return(base.BeginExecuteCore(callback, state)); }
public ActionResult HotelRoomsManagement(int?page, int HotelId) { List <HotelRoom> hotelRooms = db.HotelRooms.Include("Hotel") .Include("Room") .Where(x => x.Hotel.Id == HotelId) .ToList(); switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": ViewBag.HotelName = db.Hotels.Find(HotelId).Name_En; break; case "ar-SA": ViewBag.HotelName = db.Hotels.Find(HotelId).Name_Ar; break; default: ViewBag.HotelName = db.Hotels.Find(HotelId).Name_En; break; } ViewBag.HotelId = HotelId; return(View(hotelRooms.ToPagedList(page ?? 1, 10))); }
public ActionResult Categories(int?page, string Search) { //Getting list of categories IEnumerable <Category> categories = db.Categories.Where(x => x.Category_Name.Contains(Search.Trim()) || x.Category_Name_Ar.Contains(Search.Trim()) || String.IsNullOrEmpty(Search)); IPagedList <Category> ordered = null; //Ordering the categories switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": ordered = categories.OrderBy(x => x.Category_Name).ToList().ToPagedList(page ?? 1, 6); break; case "ar-SA": ordered = categories.OrderBy(x => x.Category_Name_Ar).ToList().ToPagedList(page ?? 1, 6); break; default: ordered = categories.OrderBy(x => x.Category_Name).ToList().ToPagedList(page ?? 1, 6); break; } return(View(ordered)); }
public ActionResult Flights(int?page, int?SourceCity, int?DestinationCity, DateTime?Date) { IPagedList <Flight> flights = db.Flights.Include("SourceCity") .Include("DestinationCity") .Where(x => (x.SourceCity.Id == SourceCity || SourceCity == null) && (x.DestinationCity.Id == DestinationCity || DestinationCity == null) && (x.Date > DateTime.Now) && (x.Date == Date || Date == null)) .ToList() .ToPagedList(page ?? 1, 15); switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-us": ViewBag.SourceCity = new SelectList(db.Cities.OrderBy(x => x.Name_En).ToList(), "ID", "Name_En"); ViewBag.DestinationCity = new SelectList(db.Cities.OrderBy(x => x.Name_En).ToList(), "ID", "Name_En"); break; case "ar-SA": ViewBag.SourceCity = new SelectList(db.Cities.OrderBy(x => x.Name_Ar).ToList(), "ID", "Name_Ar"); ViewBag.DestinationCity = new SelectList(db.Cities.OrderBy(x => x.Name_Ar).ToList(), "ID", "Name_Ar"); break; default: ViewBag.SourceCity = new SelectList(db.Cities.OrderBy(x => x.Name_En).ToList(), "ID", "Name_En"); ViewBag.DestinationCity = new SelectList(db.Cities.OrderBy(x => x.Name_En).ToList(), "ID", "Name_En"); break; } return(View(flights)); }
/* * Edit a flight */ public ActionResult EditFlight(int id) { Flight flight = db.Flights.Include("SourceCity") .Include("DestinationCity") .SingleOrDefault(x => x.ID == id); switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": ViewBag.SourceCity = new SelectList(db.Cities.OrderBy(x => x.Name_En).ToList(), "Id", "Name_En", flight.SourceCity.Id); ViewBag.DestinationCity = new SelectList(db.Cities.OrderBy(x => x.Name_En).ToList(), "Id", "Name_En", flight.DestinationCity.Id); break; case "ar-SA": ViewBag.SourceCity = new SelectList(db.Cities.OrderBy(x => x.Name_Ar).ToList(), "Id", "Name_Ar", flight.SourceCity.Id); ViewBag.DestinationCity = new SelectList(db.Cities.OrderBy(x => x.Name_Ar).ToList(), "Id", "Name_Ar", flight.DestinationCity.Id); break; default: ViewBag.SourceCity = new SelectList(db.Cities.OrderBy(x => x.Name_En).ToList(), "Id", "Name_En", flight.SourceCity.Id); ViewBag.DestinationCity = new SelectList(db.Cities.OrderBy(x => x.Name_En).ToList(), "Id", "Name_En", flight.DestinationCity.Id); break; } return(View(flight)); }
public ActionResult MessageReply(string Email, string Subject) { ReplyMessageViewModel rp = new ReplyMessageViewModel() { Email = Email, Subject = Subject }; switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": rp.MessageText = "\n\n\n\n\n\n\n\n\n\n" + "-------------------------------------------\n" + "Travel And Tourism website\n" + "Admin: " + User.Identity.GetUserName().ToString(); break; case "ar-SA": rp.MessageText = "\n\n\n\n\n\n\n\n\n\n" + "-------------------------------------------\n" + "موقع السياحة والسفر\n" + "المنظم: " + User.Identity.GetUserName().ToString(); break; default: rp.MessageText = "\n\n\n\n\n\n\n\n\n\n" + "-------------------------------------------\n" + "Travel And Tourism website\n" + "Admin: " + User.Identity.GetUserName().ToString(); break; } return(View(rp)); }
public ActionResult Countries(int?page, string Search) { List <Country> countries; switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": countries = db.Countries.Where(x => x.Name_En.Contains(Search) || String.IsNullOrEmpty(Search) && x.Visible == true) .OrderBy(x => x.Name_En) .ToList(); break; case "ar-SA": countries = db.Countries.Where(x => x.Name_Ar.Contains(Search) || String.IsNullOrEmpty(Search) && x.Visible == true) .OrderBy(x => x.Name_Ar) .ToList(); break; default: countries = db.Countries.Where(x => x.Name_En.Contains(Search) || String.IsNullOrEmpty(Search) && x.Visible == true) .OrderBy(x => x.Name_En) .ToList(); break; } if (Session["NoCities"] != null) { ViewBag.NoCities = Session["NoCities"].ToString(); } return(View(countries.ToPagedList(page ?? 1, 12))); }
public JsonResult Citylist(int id) { List <SelectListItem> li = new List <SelectListItem>(); List <City> cities = db.Cities.Where(x => x.Country.Id == id).ToList(); foreach (City c in cities) { switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": li.Add(new SelectListItem() { Text = c.Name_En, Value = c.Id.ToString() }); break; case "ar-SA": li.Add(new SelectListItem() { Text = c.Name_Ar, Value = c.Id.ToString() }); break; default: li.Add(new SelectListItem() { Text = c.Name_En, Value = c.Id.ToString() }); break; } } return(Json(li, JsonRequestBehavior.AllowGet)); }
public ActionResult CreateOffer1() { switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": ViewBag.SourceCountry = new SelectList(db.Countries.OrderBy(x => x.Name_En).ToList(), "Id", "Name_En"); ViewBag.DestinationCountry = new SelectList(db.Countries.OrderBy(x => x.Name_En).ToList(), "Id", "Name_En"); ViewBag.SourceCity = new SelectList(db.Cities.OrderBy(x => x.Name_En).ToList(), "Id", "Name_En"); ViewBag.DestinationCity = new SelectList(db.Cities.OrderBy(x => x.Name_En).ToList(), "Id", "Name_En"); break; case "ar-SA": ViewBag.SourceCountry = new SelectList(db.Countries.OrderBy(x => x.Name_Ar).ToList(), "Id", "Name_Ar"); ViewBag.DestinationCountry = new SelectList(db.Countries.OrderBy(x => x.Name_Ar).ToList(), "Id", "Name_Ar"); ViewBag.SourceCity = new SelectList(db.Cities.OrderBy(x => x.Name_Ar).ToList(), "Id", "Name_Ar"); ViewBag.DestinationCity = new SelectList(db.Cities.OrderBy(x => x.Name_Ar).ToList(), "Id", "Name_Ar"); break; default: ViewBag.SourceCountry = new SelectList(db.Countries.OrderBy(x => x.Name_En).ToList(), "Id", "Name_En"); ViewBag.DestinationCountry = new SelectList(db.Countries.OrderBy(x => x.Name_En).ToList(), "Id", "Name_En"); ViewBag.SourceCity = new SelectList(db.Cities.OrderBy(x => x.Name_En).ToList(), "Id", "Name_En"); ViewBag.DestinationCity = new SelectList(db.Cities.OrderBy(x => x.Name_En).ToList(), "Id", "Name_En"); break; } return(View()); }
public ActionResult Index(int?page, string Search = "") { //Get list of visible categories IEnumerable <Category> categories = db.Categories.Where(x => x.Visible) .ToList(); IPagedList <Category> orderedCategories = null; //Display and order categories according to current website language switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": orderedCategories = categories.Where(x => x.Category_Name.ToLower().Contains(Search.ToLower())) .OrderBy(x => x.Category_Name).ToPagedList(page ?? 1, 12); break; case "ar-SA": orderedCategories = categories.Where(x => x.Category_Name_Ar.Contains(Search)) .OrderBy(x => x.Category_Name_Ar).ToPagedList(page ?? 1, 12); break; default: orderedCategories = categories.Where(x => x.Category_Name.ToLower().Contains(Search.ToLower())) .OrderBy(x => x.Category_Name).ToPagedList(page ?? 1, 12); break; } return(View(orderedCategories)); }
public ActionResult BidsDetails(int Id) { //Getting auction Auction auction = db.Auctions.Include("Product") .Include("Product.Currency") .Include("Product.Category") .Include("Seller") .Include("Buyer") .Include("Bids") .Include("Bids.Bidder") .SingleOrDefault(x => x.Id == Id); switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": ViewBag.Category = new SelectList(db.Categories.OrderBy(x => x.Category_Name).ToList(), "Id", "Category_Name", auction.Product.Category.Id); break; case "ar-SA": ViewBag.Category = new SelectList(db.Categories.OrderBy(x => x.Category_Name_Ar).ToList(), "Id", "Category_Name_Ar", auction.Product.Category.Id); break; default: ViewBag.Category = new SelectList(db.Categories.OrderBy(x => x.Category_Name).ToList(), "Id", "Category_Name", auction.Product.Category.Id); break; } return(View(auction)); }
public ActionResult AuctionsManagement(int?page, int?Category, string Search) { IEnumerable <Auction> auctions = db.Auctions.Include("Product") .Where(x => (x.Product.Category.Id == Category || Category == null) && (x.Product.Name.Contains(Search) || String.IsNullOrEmpty(Search)) ) .OrderBy(x => (x.Finish_Date > DateTime.Now ? "A" : "B")) .ToList(); switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": ViewBag.Category = new SelectList(db.Categories.Where(x => x.Visible).OrderBy(x => x.Category_Name).ToList(), "Id", "Category_Name"); break; case "ar-SA": ViewBag.Category = new SelectList(db.Categories.Where(x => x.Visible).OrderBy(x => x.Category_Name_Ar).ToList(), "Id", "Category_Name_Ar"); break; default: ViewBag.Category = new SelectList(db.Categories.Where(x => x.Visible).OrderBy(x => x.Category_Name).ToList(), "Id", "Category_Name"); break; } ViewBag.AuctionsCount = auctions.Count(); return(View(auctions.ToPagedList(page ?? 1, 12))); }
public ActionResult Register(string returnUrl) { try { //Getting list of countries List <Country> countries = db.Countries.Where(x => x.Visible).ToList(); //Displaying countries in current website language switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": ViewBag.Country = new SelectList(countries, "Name", "Name"); break; case "ar-SA": ViewBag.Country = new SelectList(countries, "Name", "Name_Ar"); break; default: ViewBag.Country = new SelectList(countries, "Name", "Name"); break; } ViewBag.ReturnUrl = returnUrl; } catch { } return(View()); }
public ActionResult Countries(int?page, string Search) { IPagedList <Country> countries; switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": countries = db.Countries.Where(x => x.Name_En.Contains(Search) || string.IsNullOrEmpty(Search)) .ToList() .ToPagedList(page ?? 1, 15); break; case "ar-SA": countries = db.Countries.Where(x => x.Name_Ar.Contains(Search) || string.IsNullOrEmpty(Search)) .ToList() .ToPagedList(page ?? 1, 15); break; default: countries = db.Countries.Where(x => x.Name_En.Contains(Search) || string.IsNullOrEmpty(Search)) .ToList() .ToPagedList(page ?? 1, 15); break; } return(View(countries)); }
public string GetAdditionalChargeName(int chargeId) { var languageId = SiteLanguages.CurrentLanguageId(); var chargeName = _db.additional_charge_name.Where(x => x.additional_charge_id == chargeId && x.language_id == languageId).FirstOrDefault(); return(chargeName != null ? chargeName.name : null); }
public ActionResult EditHotel(int Id) { Hotel hotel = db.Hotels.Include("City") .Include("City.Country") .Include("Images") .Include("HotelRooms") .SingleOrDefault(x => x.Id == Id); switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": ViewBag.city = new SelectList(db.Cities.Where(x => x.Country.Id == hotel.City.Country.Id).ToList(), "Id", "Name_En", hotel.City.Id); ViewBag.Country = new SelectList(db.Countries.ToList(), "Id", "Name_En", hotel.City.Country.Id); break; case "ar-SA": ViewBag.city = new SelectList(db.Cities.Where(x => x.Country.Id == hotel.City.Country.Id).ToList(), "Id", "Name_Ar", hotel.City.Id); ViewBag.Country = new SelectList(db.Countries.ToList(), "Id", "Name_Ar", hotel.City.Country.Id); break; default: ViewBag.city = new SelectList(db.Cities.Where(x => x.Country.Id == hotel.City.Country.Id).ToList(), "Id", "Name_En", hotel.City.Id); ViewBag.Country = new SelectList(db.Countries.ToList(), "Id", "Name_En", hotel.City.Country.Id); break; } return(View(hotel)); }
public ActionResult AddNewAuction() { //Getting list of categories List <Category> categories = db.Categories.Where(x => x.Visible).ToList(); //Getting list of currencies List <Currency> currencies = db.Currencies.Where(x => x.Visible).ToList(); ViewBag.Currency = new SelectList(currencies, "Id", "Name"); //Displaying categories according to current website language switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": ViewBag.Category = new SelectList(categories.OrderBy(x => x.Category_Name).ToList(), "Id", "Category_Name"); break; case "ar-SA": ViewBag.Category = new SelectList(categories.OrderBy(x => x.Category_Name_Ar).ToList(), "Id", "Category_Name_Ar"); break; default: ViewBag.Category = new SelectList(categories.OrderBy(x => x.Category_Name).ToList(), "Id", "Category_Name"); break; } AddAuctionModel model = new AddAuctionModel() { AccountNumber = db.Users.Find(User.Identity.GetUserId()).AccountNumber }; return(View(model)); }
public ActionResult AllHotels(int?page, string HotelName, int?Country, int?City, string Stars) { //HotelName = ""; List <Hotel> hotels = db.Hotels.Include("City") .Include("City.Country") .Include("Images") .Include("HotelRooms") .Where(x => (x.City.Country.Id == Country || Country == null) && (x.City.Id == City || City == null) && (x.Stars == Stars.Length || string.IsNullOrEmpty(Stars)) && ( (x.Name_En.ToLower().Contains(HotelName.ToLower()) || string.IsNullOrEmpty(HotelName)) || (x.Name_Ar.Contains(HotelName) || string.IsNullOrEmpty(HotelName)) )) .ToList(); switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": ViewBag.City = new SelectList(db.Cities.ToList(), "Id", "Name_En"); ViewBag.Country = new SelectList(db.Countries.ToList(), "Id", "Name_En"); hotels = hotels.OrderBy(x => x.Name_En).ToList(); break; case "ar-SA": ViewBag.City = new SelectList(db.Cities.ToList(), "Id", "Name_Ar"); ViewBag.Country = new SelectList(db.Countries.ToList(), "Id", "Name_Ar"); hotels = hotels.OrderBy(x => x.Name_Ar).ToList(); break; default: ViewBag.City = new SelectList(db.Cities.ToList(), "Id", "Name_En"); ViewBag.Country = new SelectList(db.Countries.ToList(), "Id", "Name_En"); hotels = hotels.OrderBy(x => x.Name_En).ToList(); 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); return(View(hotels.ToPagedList(page ?? 1, 10))); }
public ActionResult Index(int?page, int Id, string ProductStatus, int?Currency) { //Getting current user ApplicationUser user = db.Users.Find(User.Identity.GetUserId()); //getting list of ongoing auctions IEnumerable <Auction> auctions = db.Auctions.Include("Seller") .Include("Buyer") .Include("Product") .Include("Product.Currency") .Include("Product.Images") .Include("Product.Images.Product") .Where(x => x.Product.Category.Id == Id && x.Finish_Date > DateTime.Now && !x.IsPaid && (x.Product.Status == ProductStatus || ProductStatus == "All" || String.IsNullOrEmpty(ProductStatus))) .ToList(); if (User.Identity.IsAuthenticated) { auctions = auctions.Where(x => x.Seller.Id != user.Id).ToList(); } ViewBag.AuctionsCount = auctions.Count(); auctions = auctions.ToPagedList(page ?? 1, 12); //Filtering by currency if (Currency != null) { auctions = auctions.Where(x => x.Product.Currency.Id == Currency).ToList().ToPagedList(page ?? 1, 12); } //Displaying category switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": ViewBag.CategoryName = db.Categories.Find(Id).Category_Name.ToString(); break; case "ar-SA": ViewBag.CategoryName = db.Categories.Find(Id).Category_Name_Ar.ToString(); break; default: ViewBag.CategoryName = db.Categories.Find(Id).Category_Name.ToString(); break; } //Getting list of currencies ViewBag.Currency = new SelectList(db.Currencies.Where(x => x.Visible).ToList(), "Id", "Name"); return(View(auctions)); }
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 ActionResult UpdateAccount(UpdateAccountViewModel model) { ApplicationUser user = db.Users.Find(User.Identity.GetUserId()); List <Country> countries = db.Countries.Where(x => x.Visible).ToList(); Country country = db.Countries.SingleOrDefault(x => x.Name_En == user.Country); List <City> cities = db.Cities.Where(x => x.Country.Id == country.Id).ToList(); City city = db.Cities.SingleOrDefault(x => x.Name_En == user.City); switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": ViewBag.Country = new SelectList(countries, "Id", "Name_En", country.Id); ViewBag.city = new SelectList(cities, "Id", "Name_En", city.Id); break; case "ar-SA": ViewBag.Country = new SelectList(countries, "Id", "Name_Ar", country.Id); ViewBag.city = new SelectList(cities, "Id", "Name_Ar", city.Id); break; default: ViewBag.Country = new SelectList(countries, "Id", "Name_En", country.Id); ViewBag.city = new SelectList(cities, "Id", "Name_En", city.Id); break; } try { user.FirstName = model.FirstName; user.LastName = model.LastName; user.Email = model.Email; user.PhoneNumber = model.PhoneNumber; user.Gender = model.Gender; user.Country = db.Countries.Find(int.Parse(model.Country)).Name_En; user.City = db.Cities.Find(int.Parse(model.City)).Name_En; db.SaveChanges(); ViewBag.Message = Resource.AccountUpdated; ViewBag.Alert = "alert alert-success"; return(View(model)); } catch { } ViewBag.Message = Resource.ErrorUpdateAccount; ViewBag.Alert = "alert alert-danger"; return(View(model)); }
public IQueryable <SelectListItem> GetAll() { var languageId = SiteLanguages.CurrentLanguageId(); var countries = _db.countries_name.Where(x => x.language_id == languageId).Select(p => new SelectListItem { Text = p.name, Value = p.countries_id.ToString() }); return(countries); }
public IQueryable <SelectListItem> GetAll() { var languageId = SiteLanguages.CurrentLanguageId(); var additionalCharges = _db.additional_charge_name.Where(x => x.language_id == languageId).Select(p => new SelectListItem { Text = p.name, Value = p.additional_charge_id.ToString() }); return(additionalCharges); }
public IQueryable <SelectListItem> GetAll() { var languageId = SiteLanguages.CurrentLanguageId(); var franchise = _db.retaining_risk_name.Where(x => x.language_id == languageId).Select(p => new SelectListItem { Text = p.name, Value = p.retaining_risk_id.ToString() }); return(franchise); }
public ActionResult Cities(int?page, int CountryId, string Search) { List <City> cities; switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": cities = db.Cities.Include("Country") .Include("Images") .Where(x => x.Country.Id == CountryId && (x.Name_En.Contains(Search) || string.IsNullOrEmpty(Search))) .OrderBy(x => x.Name_En) .ToList(); break; case "ar-SA": cities = db.Cities.Include("Country") .Include("Images") .Where(x => x.Country.Id == CountryId && (x.Name_Ar.Contains(Search) || string.IsNullOrEmpty(Search))) .OrderBy(x => x.Name_Ar) .ToList(); break; default: cities = db.Cities.Include("Country") .Include("Images") .Where(x => x.Country.Id == CountryId && (x.Name_En.Contains(Search) || string.IsNullOrEmpty(Search))) .OrderBy(x => x.Name_En) .ToList(); break; } if (cities.Count == 0) { Session.Add("NoCities", "No Cities"); return(RedirectToAction("Countries")); } Session.Remove("NoCities"); Country c = db.Countries.Find(CountryId); c.Rate++; db.SaveChanges(); return(View(cities.ToPagedList(page ?? 1, 12))); }
public ActionResult AddFlight(Flight model) { City s = db.Cities.Find(int.Parse(Request["SourceCity"].ToString())); City d = db.Cities.Find(int.Parse(Request["DestinationCity"].ToString())); try { Flight f = new Flight() { SourceCity = s, DestinationCity = d, EcoSeatsCount = model.EcoSeatsCount, FrstSeatsCount = model.FrstSeatsCount, Date = Convert.ToDateTime(model.Date), DisplayDate = Convert.ToDateTime(model.Date).ToShortDateString(), Time = model.Time, FlightDuration = model.FlightDuration, EconomyTicketPrice = model.EconomyTicketPrice, FirstClassTicketPrice = model.FirstClassTicketPrice, Airline = model.Airline }; db.Flights.Add(f); db.SaveChanges(); return(RedirectToAction("Flights", "Admin")); } catch { } switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": ViewBag.SourceCity = new SelectList(db.Cities.OrderBy(x => x.Name_En).ToList(), "Id", "Name_En"); ViewBag.DestinationCity = new SelectList(db.Cities.OrderBy(x => x.Name_En).ToList(), "Id", "Name_En"); break; case "ar-SA": ViewBag.SourceCity = new SelectList(db.Cities.OrderBy(x => x.Name_Ar).ToList(), "Id", "Name_Ar"); ViewBag.DestinationCity = new SelectList(db.Cities.OrderBy(x => x.Name_Ar).ToList(), "Id", "Name_Ar"); break; default: ViewBag.SourceCity = new SelectList(db.Cities.OrderBy(x => x.Name_En).ToList(), "Id", "Name_En"); ViewBag.DestinationCity = new SelectList(db.Cities.OrderBy(x => x.Name_En).ToList(), "Id", "Name_En"); break; } return(View(model)); }
public ActionResult EditFlight(Flight model) { Flight flight = db.Flights.Include("SourceCity") .Include("DestinationCity") .SingleOrDefault(x => x.ID == model.ID); try { flight.SourceCity = db.Cities.Find(int.Parse(Request["SourceCity"].ToString())); flight.DestinationCity = db.Cities.Find(int.Parse(Request["DestinationCity"].ToString())); flight.Date = model.Date; flight.DisplayDate = flight.Date.ToShortDateString(); flight.EconomyTicketPrice = model.EconomyTicketPrice; flight.FirstClassTicketPrice = model.FirstClassTicketPrice; flight.FlightDuration = model.FlightDuration; flight.EcoSeatsCount = model.EcoSeatsCount; flight.FrstSeatsCount = model.FrstSeatsCount; flight.Time = model.Time; db.SaveChanges(); return(RedirectToAction("Flights", "Admin")); } catch { } switch (SiteLanguages.GetCurrentLanguageCulture()) { case "en-US": ViewBag.SourceCity = new SelectList(db.Cities.OrderBy(x => x.Name_En).ToList(), "Id", "Name_En", flight.SourceCity.Id); ViewBag.DestinationCity = new SelectList(db.Cities.OrderBy(x => x.Name_En).ToList(), "Id", "Name_En", flight.DestinationCity.Id); break; case "ar-SA": ViewBag.SourceCity = new SelectList(db.Cities.OrderBy(x => x.Name_Ar).ToList(), "Id", "Name_Ar", flight.SourceCity.Id); ViewBag.DestinationCity = new SelectList(db.Cities.OrderBy(x => x.Name_Ar).ToList(), "Id", "Name_Ar", flight.DestinationCity.Id); break; default: ViewBag.SourceCity = new SelectList(db.Cities.OrderBy(x => x.Name_En).ToList(), "Id", "Name_En", flight.SourceCity.Id); ViewBag.DestinationCity = new SelectList(db.Cities.OrderBy(x => x.Name_En).ToList(), "Id", "Name_En", flight.DestinationCity.Id); break; } return(View(model)); }
protected void Application_BeginRequest(object sender, EventArgs e) { string lang = null; HttpCookie langCookie = Request.Cookies["culture"]; if (langCookie != null) { lang = langCookie.Value; var cultureInfo = new CultureInfo(lang); Thread.CurrentThread.CurrentUICulture = cultureInfo; Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cultureInfo.Name); } else { lang = SiteLanguages.GetDefaultLanguage(); new SiteLanguages().SetLanguage(lang); } }
public async override void OnActionExecuted(ActionExecutedContext context) { string lang = null; var langCookie = Request.Cookies["c"]; if (langCookie != null) { lang = langCookie; } else { lang = SiteLanguages.GetDefaultLanguage(); } //SetLanguage(lang); await SetCultureActionFilter(lang); base.OnActionExecuted(context); }