/************************************************************************************ * Description: This function handles logic behind retrieve latest weather forecast * * (Validate and return weather based on category) * * * Developer: Elson * * * * Date: 02/04/2016 * ************************************************************************************/ public IEnumerable <Weather> validateCategoryWeatherData(string category) { LogWriter.Instance.LogInfo("HomeController / validateCategoryWeatherData"); IEnumerable <Weather> enumerableAllWeather = homeMapper.getAllLocationWeather(category, false); // If not updated weather forecast if (enumerableAllWeather.Count() == 0) { // Update database with lastest forecast weatherService.GetNowcast(); // Retrieve from database again enumerableAllWeather = homeMapper.getAllLocationWeather(category, false); if (enumerableAllWeather.Count() == 0) { // Delete Duplicate weather forecast in database (a job for mapper or service) weatherGateway.removeDuplicateWeatherData(); // Update database with lastest forecast weatherService.GetNowcast(); // Retrieve from database again enumerableAllWeather = homeMapper.getAllLocationWeather(category, true); } } return(enumerableAllWeather); }
/************************************************************************************ * Description: This function handles logic behind retrieve latest weather forecast * * (Validate and return weather based on Trail ID) * * * Developer: Elson * * * * Date: 02/04/2016 * ************************************************************************************/ public IEnumerable <Weather> validateTrailWeatherData(int trailID) { LogWriter.Instance.LogInfo("TrailMeetupController / validateTrailWeatherData"); IEnumerable <Weather> enumerableAllWeather = trailMeetupMapper.getAllWeatherInfoFromTrail(trailID, false); // If not updated weather forecast if (enumerableAllWeather.Count() == 0) { // Update database with lastest forecast weatherService.GetNowcast(); // Retrieve from database again enumerableAllWeather = trailMeetupMapper.getAllWeatherInfoFromTrail(trailID, false); if (enumerableAllWeather.Count() == 0) { // Delete Duplicate weather forecast in database (a job for mapper or service) weatherGateway.removeDuplicateWeatherData(); // Update database with lastest forecast weatherService.GetNowcast(); // Retrieve from database again enumerableAllWeather = trailMeetupMapper.getAllWeatherInfoFromTrail(trailID, true); } } return(enumerableAllWeather); }