Example #1
0
        /* * * * * * * * * * * * * * * * * * * * * * * * * * *
        *
        *          Create/get all settings section
        *
        * * * * * * * * * * * * * * * * * * * * * * * * * * */

        public void InitializeSettings(SettingsTable st)
        {
            try
            {
                using (var db = new DefaultContext())
                {
                    db.SettingsTable.Add(st);
                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #2
0
        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();
            }
        }
Example #3
0
        /* * * * * * * * * * * * * * * * * * * * * * * * * * *
        *
        *          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();
            }
        }
Example #4
0
        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();
            }
        }