public async Task <WeatherInfoModel> CreateWeatherInfo([Service] SqlLiteDataContext dataContext, string city, float minTemp, float maxTemp, DateTime dateTime) { Console.WriteLine(minTemp); WeatherInfoModel weatherInfo = new WeatherInfoModel { date = dateTime, City = city, MinTemp = minTemp, MaxTemp = maxTemp }; await dataContext.WeatherInfos.AddAsync(weatherInfo); await dataContext.SaveChangesAsync(); return(weatherInfo); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, SqlLiteDataContext dbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } // migrate any database changes on startup (includes initial database creation) dbContext.Database.Migrate(); app.UseHttpsRedirection(); app.UseStaticFiles(); if (!env.IsDevelopment()) { app.UseSpaStaticFiles(); } app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller}/{action=Index}/{id?}"); }); app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseAngularCliServer(npmScript: "start"); } }); }
public CommentService(SqlLiteDataContext context) { _context = context; }
public async Task <List <WeatherInfoModel> > GetWeatherInfoByCity([Service] SqlLiteDataContext dataContext, string cityName) => await dataContext.WeatherInfos.AsNoTracking().Where(x => x.City == cityName).ToListAsync();
public async Task <List <WeatherInfoModel> > GetWeatherInfos([Service] SqlLiteDataContext dataContext) => await dataContext.WeatherInfos.AsNoTracking().OrderBy(o => o.City).ToListAsync();
public UserService(SqlLiteDataContext context) { _context = context; }
public PostService(SqlLiteDataContext context) { _context = context; }