public static void EnsureDataForContext(this SmogInfoContext context) { if (context.Cities.Any()) { return; } var Cities = new List <City>() { new City() { CityName = "Warszawa", StationPoints = { new StationPoint { StreetName = "Aleje Jerozolimskie", SmogLevels = { new SmogLevel { DateTime = new DateTime(2018, 6, 16, 17, 20, 10), PM10Concentration = 26.5m }, } } } } }; context.Cities.AddRange(Cities); context.SaveChanges(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, SmogInfoContext smogInfoContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseHttpsRedirection().UseStaticFiles().UseSpaStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action=Index}/{id?}"); }); app.UseSpa(spa => { // To learn more about options for serving an Angular SPA from ASP.NET Core, // see https://go.microsoft.com/fwlink/?linkid=864501 spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseAngularCliServer(npmScript: "start"); } }); smogInfoContext.EnsureDataForContext(); app.UseStatusCodePages(); AutoMapper.Mapper.Initialize(cfg => { cfg.CreateMap <Entities.City, Model.CitiesWithoutStationsDto>(); cfg.CreateMap <Entities.City, Model.CitiesDto>(); cfg.CreateMap <Entities.StationPoint, Model.StationPointDto>(); cfg.CreateMap <Entities.SmogLevel, Model.SmogLevelDto>(); cfg.CreateMap <Model.SmogLevelForCreateDto, Entities.SmogLevel>(); }); var c = new ReccuringTasks(); c.Task(smogInfoContext, "http://api.gios.gov.pl/pjp-api/rest/data/getData/3584", 1, 1); }
public DummyController(SmogInfoContext ctx) { _ctx = ctx; }
public SmogInfoRepository(SmogInfoContext context) { _context = context; }
public void Task(SmogInfoContext smogInfoContext, string url, int city, int station) { var a = new DataOperator(smogInfoContext); a.StartFrequentDataOperating(url, 1, 1); }
public DataOperator(SmogInfoContext smogInfoContext) { _smogInfoContext = smogInfoContext; }