public void SaveWeatherSettings(WeatherSettings ws) { using (var db = new DefaultContext()) { WeatherSettings currentWeatherSettings = db.WeatherSettings.SingleOrDefault(x => x.Pk_WeatherId == ws.Pk_WeatherId); currentWeatherSettings.Enabled = ws.Enabled; currentWeatherSettings.Farenheit = ws.Farenheit; currentWeatherSettings.Cloudiness = ws.Cloudiness; currentWeatherSettings.Humidity = ws.Humidity; currentWeatherSettings.WindSpeed = ws.WindSpeed; currentWeatherSettings.Location = ws.Location; db.WeatherSettings.Attach(currentWeatherSettings); db.Entry(currentWeatherSettings).State = EntityState.Modified; db.SaveChanges(); } }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * Save individual settings section * * * * * * * * * * * * * * * * * * * * * * * * * * * */ public void SaveNewsSettings(NewsSettings ns) { using (var db = new DefaultContext()) { NewsSettings currentNewsSettings = db.NewsSettings.SingleOrDefault(x => x.Pk_NewsId == ns.Pk_NewsId); currentNewsSettings.Enabled = ns.Enabled; currentNewsSettings.Domains = ns.Domains; currentNewsSettings.Sources = ns.Sources; currentNewsSettings.Queries = ns.Queries; currentNewsSettings.OldestDate = ns.OldestDate; currentNewsSettings.NewestDate = ns.NewestDate; currentNewsSettings.Language = ns.Language; currentNewsSettings.PageSize = ns.PageSize; db.NewsSettings.Attach(currentNewsSettings); db.Entry(currentNewsSettings).State = EntityState.Modified; db.SaveChanges(); } }
public void SaveTrafficSettings(TrafficSettings ts) { using (var db = new DefaultContext()) { TrafficSettings currentTrafficSettings = db.TrafficSettings.SingleOrDefault(x => x.Pk_TrafficId == ts.Pk_TrafficId); currentTrafficSettings.Enabled = ts.Enabled; currentTrafficSettings.Address = ts.Address; currentTrafficSettings.WorkAddress = ts.WorkAddress; currentTrafficSettings.Driving = ts.Driving; currentTrafficSettings.AddressPlaceId = ts.AddressPlaceId; currentTrafficSettings.WorkAddressPlaceId = ts.WorkAddressPlaceId; currentTrafficSettings.LatLng = ts.LatLng; db.TrafficSettings.Attach(currentTrafficSettings); db.Entry(currentTrafficSettings).State = EntityState.Modified; db.SaveChanges(); } }
public TrafficSettings GetTrafficSettings(int trafficSettingsId) { using (var db = new DefaultContext()) return(db.TrafficSettings.SingleOrDefault(x => x.Pk_TrafficId == trafficSettingsId)); }
public WeatherSettings GetWeatherSettings(int weatherSettingsId) { using (var db = new DefaultContext()) return(db.WeatherSettings.SingleOrDefault(x => x.Pk_WeatherId == weatherSettingsId)); }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * Get individual settings section * * * * * * * * * * * * * * * * * * * * * * * * * * * */ public NewsSettings GetNewsSettings(int newsSettingsId) { using (var db = new DefaultContext()) return(db.NewsSettings.SingleOrDefault(x => x.Pk_NewsId == newsSettingsId)); }
public int GetWeatherId(string userId) { using (var db = new DefaultContext()) return(db.SettingsTable.SingleOrDefault(x => x.Pk_Email == userId).Fk_WeatherId); }