/** * @brief assign all Model to local variables in controller * */ public EditController(ApplicationDbContext db) { _widgetsSettings = new Dal(db); _ytModel = new YoutubeModel(); _sModel = new SteamModel(); _wModel = new WeatherModel(); }
public string GetCurrentTemp(IWeatherModel model) { string result; Model.CurrentWeather weather; if (model is Model.CurrentWeather) { weather = model as Model.CurrentWeather; } else { return(null); } result = $"\"{weather.Name}\" - {weather.Main.Temp} \u2103, {weather.Weather[0].Description}"; return(result); }
public IWeatherModel GetWeather(int id, ModeType mode = ModeType.json, string units = null, string lang = null) { Model.CurrentWeather currentWeather; string str; string sUrl = $"https://api.openweathermap.org/data/2.5/weather?appid={apiKey}&id={id}"; if (mode != ModeType.json) { sUrl = String.Join("&", sUrl, $"mode={mode}"); } if (units != null) { sUrl = String.Join("&", sUrl, $"units={units}"); } if (lang != null) { sUrl = String.Join("&", sUrl, $"lang={lang}"); } if (mode == ModeType.json) { str = GetString(sUrl); currentWeather = JsonConvert.DeserializeObject <Model.CurrentWeather>(str); weatherModel = currentWeather; return(currentWeather); } else if (mode == ModeType.xml) { throw new Exception("Нет реализации xml"); } else if (mode == ModeType.html) { throw new Exception("Нет реализации html"); } else { throw new Exception("Нет реализации"); } }
public CityController(IWeatherModel model) { _model = model; }
public WeatherController(IWeatherModel model) { _model = model; }