public WeatherSummaryViewModel UpdateWeather(WeatherSummary weatherSummary) { OpenWeatherIcon = OpenWeatherConfiguration.GetIconURL(weatherSummary.OpenWeatherIcon); Temperature = GetShortTemperature(weatherSummary.Temperature); Time = ToTimeAtLocation(weatherSummary); return(this); }
public WeatherSummaryViewModel(WeatherSummary weatherSummary, int ordering) { Name = weatherSummary.Location; Temperature = GetShortTemperature(weatherSummary.Temperature); OpenWeatherIcon = OpenWeatherConfiguration.GetIconURL(weatherSummary.OpenWeatherIcon); Id = weatherSummary.Id; Ordering = ordering; Time = ToTimeAtLocation(weatherSummary); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); OpenWeatherConfiguration openWeatherConfig = Configuration.GetSection("OpenWeatherConfiguration").Get <OpenWeatherConfiguration>(); services.AddSingleton(openWeatherConfig); services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddHttpContextAccessor(); }
static void Main(string[] args) { WeatherProvidersCollection providers = new WeatherProvidersCollection(); var configuration = BuildConfiguration(); var openWeatherConfiguration = new OpenWeatherConfiguration(); configuration.GetSection("OpenWeather").Bind(openWeatherConfiguration); providers.Add(new OpenWeatherProvider(openWeatherConfiguration)); var weatherBitMapConfig = new WeatherBitConfiguration(); configuration.GetSection("WeatherBit").Bind(weatherBitMapConfig); providers.Add(new WeatherBitProvider(weatherBitMapConfig)); var cityName = args.Length > 0 ? args[0] : "Kyiv"; WeatherData response = providers.GetCurrentWeatherData(cityName).GetAwaiter().GetResult(); WriteToFile("weather.txt", response); Console.WriteLine(response); }
public WeatherService(OpenWeatherConfiguration openWeather) { _openWeather = openWeather; }
public WeatherController(ILogger <WeatherController> logger, OpenWeatherConfiguration openWeatherconfiguration, IHttpContextAccessor httpContextAccessor) { _openWeatherconfiguration = openWeatherconfiguration; _logger = logger; _httpContextAccessor = httpContextAccessor; }