public ActionResult GetWeather(Position position) { string data = String.Empty; try { string[] DBResult = _repository.Get(position); if (DBResult.Count() == 0) { var weather = new OpenWeather(); data = weather.getData(position); } else { data = DBResult.First(); } } catch (Exception) { ModelState.AddModelError("CustomError", "Fel vid hämtning av data."); } try { var parse = new ParseWeather(); var parsedData = parse.getData(data); _repository.Add(position, data); var viewModel = new WeatherData(parsedData, position); return View("Weather", viewModel); } catch (Exception) { ModelState.AddModelError("CustomError", "Fel vid parsning av data."); } return View("Error"); }
public void Add(Position positon, String data) { _entities.usp_AddCache(positon.Latitude, positon.Longitude, data); }
public WeatherData(IEnumerable<Models.Weather> data, Position position) { _data = data; _address = position.Address; }
public string[] Get(Position position) { return _entities.usp_GetCache(position.Latitude, position.Longitude).ToArray(); }