public ActionResult Data(WeatherSearchModel model) { var weatherSearchCriteria = new WeatherSearchCriteria { CityName = model.CityName, Date = model.Date, TemperatureFrom = model.TemperatureFrom, TemperatureTo = model.TemperatureTo, SunriseFrom = model.SunriseFrom, SunriseTo = model.SunriseTo }; var weatherData = _weatherService.FindWeatherData(weatherSearchCriteria); var mapper = new WeahterMapper(); var results = weatherData.Select(result => mapper.FromWeatherEntity(result)).ToList(); var resultModel = new WeatherResultsModel { Results = results }; return(View(resultModel)); }
public IEnumerable <Weather> FindWeatherData(WeatherSearchCriteria searchCriteria) { var spec = new WeatherSearchCriteriaSpecification(searchCriteria); return(Repository.FindAll().Where(spec.IsSatisfied())); }