public ForecastController(ForecastContext context) { _context = context; //Don't return anything yet... I don't know what to do with this context. // _context.ForecastItems.ToList(); }
public async Task <City> GetCityAsync(string name) { using (var context = new ForecastContext(_connectionString)) { return(await context.Cities.SingleOrDefaultAsync(city => city.Name.ToLower() == name.ToLower())); } }
public IList <Schedule> GetAllSchedules() { using (var context = new ForecastContext()) { return(context.Schedules.ToList()); } }
public Schedule GetSchedule(int scheduleId) { using (var context = new ForecastContext()) { return(context.Schedules.Find(scheduleId)); } }
public async Task <IEnumerable <City> > GetCitiesAsync() { using (var context = new ForecastContext(_connectionString)) { return(await context.Cities.ToArrayAsync()); } }
public Schedule UpdateSchedule(int scheduleId, Schedule schedule) { using (var context = new ForecastContext()) { var origSchedule = context.Schedules.Find(scheduleId); if (origSchedule.Name != schedule.Name) { origSchedule.Name = schedule.Name; } if (origSchedule.Amount != schedule.Amount) { origSchedule.Amount = schedule.Amount; } if (origSchedule.ScheduleType != schedule.ScheduleType) { origSchedule.ScheduleType = schedule.ScheduleType; } if (origSchedule.Value != schedule.Value) { origSchedule.Value = schedule.Value; } if (origSchedule.Begin != schedule.Begin) { origSchedule.Begin = schedule.Begin; } if (origSchedule.End != schedule.End) { origSchedule.End = schedule.End; } context.SaveChanges(); return(origSchedule); } }
public async Task AddForecastAsync(Context.Models.Forecast forecast) { using (var context = new ForecastContext(_connectionString)) { context.Forecasts.Add(forecast); await context.SaveChangesAsync(); } }
public Schedule AddSchedule(Schedule schedule) { using (var context = new ForecastContext()) { context.Schedules.Add(schedule); context.SaveChanges(); } return(schedule); }
public void DeleteSchedule(int scheduleId) { using (var context = new ForecastContext()) { var schedule = context.Schedules.Find(scheduleId); context.Schedules.Remove(schedule); context.SaveChanges(); } }
public async Task <DayForecast> GetDayForecastAsync(int cityId, DateTime date) { using (var context = new ForecastContext(_connectionString)) { return(await context.DayForecasts .Where(df => df.Date == date.Date && df.CityForecast.City.Id == cityId) .OrderByDescending(df => df.Id) .FirstOrDefaultAsync()); } }
private void PullDataFromDb() { using (var db = new ForecastContext()) { db.Database.EnsureCreated(); foreach (var item in db.Items) { Items.Add(new ForecastItem(_forecastService, item)); } } }
public IList <Schedule> GetActiveSchedules() { var now = DateTime.UtcNow; using (var context = new ForecastContext()) { return(context.Schedules .Where(s => (s.Begin == null || s.Begin <= now) && (s.End == null || s.End >= now)) .ToList()); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ForecastContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } //var context = app.ApplicationServices.GetService<ForecastContext>(); //GenerateTestData(context); app.UseHttpsRedirection(); app.UseMvc(); app.UseDefaultFiles(); app.UseStaticFiles(); }
private void GenerateTestData(ForecastContext context) { //var sweden = new Country //{ // CountryId = 1, // Name = "Sverige", // CountryCode = "SV" //}; //var stockholm = new City //{ // CityId = 2673730, // Name = "Stockholm", // CountryId = 1 //}; //context.Countries.Add(sweden); //context.Cities.Add(stockholm); //context.SaveChanges(); }
public GenericRepository(ForecastContext context) { Context = context; Set = Context.Set <T>(); }
public WeatherForecastController(ILogger <WeatherForecastController> logger, ForecastContext ctx) { _logger = logger; _ctx = ctx; }
public ValorForecastRepository(ForecastContext context, IVariablesToken variables) { _context = context; _variables = variables; DbSet = _context.Set <ValorForecast>(); }
public GismeteoService() { _context = new ForecastContext(); _gismeteoParser = new GismeteoParser(); }
public ForecastController(ForecastContext context) { Context = context; }
public CityRepository(ForecastContext context) : base(context) { }
public ForecastTransferService() { _context = new ForecastContext(); }
public HistoryRepository(ForecastContext context) { _context = context; }
public UnitOfWork(ForecastContext context) { _context = context; }
public CityRepository(ForecastContext context) { _context = context; }
public BaseRepository(ForecastContext context, IVariablesToken variables) { _context = context; _variables = variables; DbSet = _context.Set <TEntity>(); }
public ForecastController(IForecastService forecastService, ForecastContext context) { _forecastService = forecastService; _context = context; }