Exemplo n.º 1
0
 public static void SaveAlarm(Alarm alarm)
 {
     using (var context = new AlarmDBContext())
     {
         context.Entry(alarm).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public static void AddAlarm(Alarm alarm)
 {
     using (var context = new AlarmDBContext())
     {
         context.Alarms.Add(alarm);
         context.SaveChanges();
     }
 }
Exemplo n.º 3
0
 public static void AddUser(User user)
 {
     using (var context = new AlarmDBContext())
     {
         context.Users.Add(user);
         context.SaveChanges();
     }
 }
Exemplo n.º 4
0
 public static void DeleteAlarm(Alarm alarm)
 {
     using (var context = new AlarmDBContext())
     {
         alarm.deleteDBValues();
         context.Alarms.Attach(alarm);
         context.Alarms.Remove(alarm);
         context.SaveChanges();
     }
 }
Exemplo n.º 5
0
 public static void UpdateAlarms()
 {
     using (var context = new AlarmDBContext())
     {
         foreach (Alarm al in context.Alarms)
         {
             al.BeginTime = al.CountDate(al.Hour, al.Minutes);
         }
         context.SaveChanges();
     }
 }
Exemplo n.º 6
0
 public static void EndAlarm(Alarm alarm, DateTime end)
 {
     using (var context = new AlarmDBContext())
     {
         Alarm al = context.Alarms.Where(u => u.Guid == alarm.Guid).First();
         if (al != null)
         {
             al.EndTime = end;
         }
         context.SaveChanges();
     }
 }
Exemplo n.º 7
0
 public static void UpdateAlarm(Alarm alarm, int h, int m)
 {
     using (var context = new AlarmDBContext())
     {
         if (context.Alarms.Any(u => u.Hour == h && u.Minutes == m && u.Guid != alarm.Guid))
         {
             throw new Exception("This alarm is already exists!");
         }
         Alarm al = context.Alarms.Where(u => u.Guid == alarm.Guid).First();
         al.Hour    = h;
         al.Minutes = m;
         context.SaveChanges();
     }
 }