Example #1
0
 // write MednaNet Settings object to DB
 public static void SetGlobals(MednaNetSettings gs)
 {
     using (var context = new MyDbContext())
     {
         context.MednaNetSettings.Attach(gs);
         var entry = context.Entry(gs);
         entry.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Example #2
0
        public static MednaNetSettings GetMednaNetDefaults()
        {
            MednaNetSettings ms = new MednaNetSettings
            {
                Id                         = 1,
                InstallKey                 = "",
                ChatHistoryInMinutes       = 600,
                PollTimerIntervalInSeconds = 3
            };

            return(ms);
        }
Example #3
0
        // get install key
        public static string GetInstallKey()
        {
            MednaNetSettings gs = new MednaNetSettings();

            using (var context = new MyDbContext())
            {
                var query = from s in context.MednaNetSettings
                            where s.Id == 1
                            select s;
                gs = query.FirstOrDefault();
            }
            return(gs.InstallKey);
        }
Example #4
0
        // return MednaNet Settings entry from DB
        public static MednaNetSettings GetGlobals()
        {
            MednaNetSettings gs = new MednaNetSettings();

            using (var context = new MyDbContext())
            {
                var query = from s in context.MednaNetSettings
                            where s.Id == 1
                            select s;
                gs = query.FirstOrDefault();
            }
            return(gs);
        }
Example #5
0
        // get poll timer interval (seconds)
        public static int GetPollTimerInterval()
        {
            MednaNetSettings gs = new MednaNetSettings();

            using (var context = new MyDbContext())
            {
                var query = from s in context.MednaNetSettings
                            where s.Id == 1
                            select s;
                gs = query.FirstOrDefault();
            }
            return(gs.PollTimerIntervalInSeconds);
        }
Example #6
0
        // get chat history time
        public static int GetChatHistoryInMinutes()
        {
            MednaNetSettings gs = new MednaNetSettings();

            using (var context = new MyDbContext())
            {
                var query = from s in context.MednaNetSettings
                            where s.Id == 1
                            select s;
                gs = query.FirstOrDefault();
            }
            return(gs.ChatHistoryInMinutes * -1);
        }
Example #7
0
        // set poll timer interval (seconds)
        public static void SetPollTimerInterval(int pollInSeconds)
        {
            MednaNetSettings gs = MednaNetSettings.GetGlobals();

            gs.PollTimerIntervalInSeconds = pollInSeconds;

            using (var context = new MyDbContext())
            {
                context.MednaNetSettings.Attach(gs);
                var entry = context.Entry(gs);
                entry.State = EntityState.Modified;
                context.SaveChanges();
            }
        }
Example #8
0
        // set chat history time
        public static void SetChatHistoryInMinutes(int historyInMinutes)
        {
            MednaNetSettings gs = MednaNetSettings.GetGlobals();

            gs.ChatHistoryInMinutes = historyInMinutes;

            using (var context = new MyDbContext())
            {
                context.MednaNetSettings.Attach(gs);
                var entry = context.Entry(gs);
                entry.State = EntityState.Modified;
                context.SaveChanges();
            }
        }
Example #9
0
        // set install key
        public static void SetInstallKey(string installKey)
        {
            if (installKey == null)
            {
                return;
            }

            MednaNetSettings gs = MednaNetSettings.GetGlobals();

            gs.InstallKey = installKey;

            using (var context = new MyDbContext())
            {
                context.MednaNetSettings.Attach(gs);
                var entry = context.Entry(gs);
                entry.State = EntityState.Modified;
                context.SaveChanges();
            }
        }
Example #10
0
        // set install key
        public static void SetUsername(string username)
        {
            if (username == null)
            {
                return;
            }

            MednaNetSettings gs = MednaNetSettings.GetGlobals();

            gs.LastUsername = username;

            using (var context = new MyDbContext())
            {
                context.MednaNetSettings.Attach(gs);
                var entry = context.Entry(gs);
                entry.State = EntityState.Modified;
                context.SaveChanges();
            }
        }