public HomeController() { _ruterReiseFacade = new RuterReiseFacade(); _settings = new AppSettings(); _ruterStation = new RuterDataProvider(); _station = new Station(); }
public async Task <ActionResult> Stations() { var ruterReiseFacade = new RuterReiseFacade(); string selectedStation = Request["FromStation"]; var cookieValue = new CookieValues { StationId = selectedStation, MetroId = "" }; if (!CookieExists()) { if (String.IsNullOrEmpty(selectedStation)) { return(RedirectToAction("Index")); } SetCookie(cookieValue); } else { if (String.IsNullOrEmpty(selectedStation)) { cookieValue = GetCookieValues(); if (cookieValue == null) { return(RedirectToAction("Index")); } selectedStation = cookieValue.StationId; } else { OverWriteCookieValue(cookieValue); } } if (String.IsNullOrEmpty(selectedStation)) { if (TempData["CustomError"] != null) { ModelState.AddModelError("", TempData["CustomError"].ToString()); } } List <Tuple <int, string, int> > _stationNames = await ruterReiseFacade.GetAllStationsAndLines(); int fromStationId = _stationNames.Find(x => x.Item2.ToLower().Equals(selectedStation.ToLower())).Item3; Dictionary <string, string> linesServingStation = await ruterReiseFacade.GetLinesServingStop(fromStationId); string chooseAllStations = String.Empty; foreach (var lines in linesServingStation) { chooseAllStations = chooseAllStations + lines.Key + ","; } if (linesServingStation.Count > 1) { linesServingStation.Add(chooseAllStations.TrimEnd(','), "Velg alle"); } var viewModel = new PickLinesViewModel { LinesServingStation = linesServingStation }; return(View(viewModel)); }