public ActionResult Index(RepositoryModelTicket ticket) { var isValidFromStation = false; var isValidToStation = false; if (ModelState.IsValid) { foreach (var station in _stationBll.GetAllStations()) { if (ticket.FromStation == station.StationName) { isValidFromStation = true; } if (ticket.ToStation == station.StationName) { isValidToStation = true; } } if (isValidToStation && isValidFromStation) { var departures = _departureBll.GetDeparturesLater(ticket.ValidFromTime); ViewBag.ticket = ticket; return(View("SelectTrip", departures)); } } //TODO This should be displayed in the same fashion as the error message for choosing the same to and from station! //If the user inputs a station that does not exist, show an error message ModelState.AddModelError("Stations", "En av stasjonene du har skrevet inn finnes ikke"); return(View()); }
public ActionResult Admin() { var model = new AdminModel() { Stations = _stationBll.GetAllStations(), Departures = _departureBll.GetAllDepartures(), Lines = _lineBll.GetAllLines() }; return(View(model)); }