public ActionResult Search(SearchViewModel model) { var errorString = string.Empty; if (model.DepartureCityId == -1) { errorString += "Выберите город отправки "; } if (model.ArrivalCityId == -1) { errorString += "Выберите город прибытия"; } if (model.DepartureDate == null) { errorString += "Выберите дату"; } if (errorString != string.Empty) { ViewBag.Error = errorString; return(View()); } else { var fligths = _airportService.FindFlights(model.DepartureCityId, model.ArrivalCityId, model.DepartureDate.Value); return(View(fligths)); } }
public ActionResult Search(SearchInputViewModel model) { var errorString = string.Empty; if (model.DepartureCityId == Guid.Empty) { errorString += "Select departure city. "; } if (model.ArrivalCityId == Guid.Empty) { errorString += "Select arrival city. "; } if (model.DepartureDate == null) { errorString += "Select date "; } if (errorString != string.Empty) { ViewBag.Error = errorString; return(View()); } else { var fligths = _airportService.FindFlights(model.DepartureCityId, model.ArrivalCityId, model.DepartureDate.Value); return(View("SearchResult", fligths)); } }
public void FindFlights_NoExsistingFlights_ReturnsEmptyCollection() { var service = new AirportService(stub); var flights = service.FindFlights(-1, -1, DateTime.Now); var flightsCount = flights.Count; Assert.AreEqual(0, flightsCount); }
public void FindFlights_OneFlightAvailable_ReturnsCollectionWithOneItem() { var service = new AirportService(stub); var flights = service.FindFlights(1, 2, DateTime.Now); var flightsCount = flights.Count; Assert.AreEqual(1, flightsCount); }