Exemplo n.º 1
0
        public static void SetAlarm(int id)
        {
            using (var db = new AlarmDbContext())
            {
                int counter = 1;

                foreach (var alarm in db.Alarms)
                {
                    if (counter == id)
                    {
                        int hour, minutes;

                        hour = alarm.AlarmTime.Hour;

                        minutes = alarm.AlarmTime.Minute;

                        string godz, min;

                        godz = hour.ToString();

                        min = minutes.ToString();

                        new Alarms(godz, min, "00");

                        break;
                    }
                    ++counter;
                }
            }
        }
Exemplo n.º 2
0
 public static void AddAlarm(DateTime czas, string nazwa)
 {
     using (var db = new AlarmDbContext())
     {
         var alarm = new Alarm
         {
             Name      = nazwa,
             AlarmTime = czas
         };
         db.Alarms.Add(alarm);
         db.SaveChanges();
     }
 }
Exemplo n.º 3
0
        public static List <Alarm> AlarmList2()
        {
            using (var db = new AlarmDbContext())
            {
                List <Alarm> Alarms = new List <Alarm>();

                foreach (var alarm in db.Alarms)
                {
                    Alarms.Add(alarm);
                }
                return(Alarms);
            }
        }
Exemplo n.º 4
0
        public static List <String> AlarmList()
        {
            using (var db = new AlarmDbContext())
            {
                List <String> Alarms = new List <String>();

                foreach (var alarm in db.Alarms)
                {
                    string temp, date, time;
                    time = alarm.AlarmTime.ToShortTimeString();
                    date = alarm.AlarmTime.ToShortDateString();
                    temp = "Nazwa alarmu: " + alarm.Name + " Data: " + date + " Czas: " + time;
                    Alarms.Add(temp);
                }
                return(Alarms);
            }
        }
Exemplo n.º 5
0
        public static void DeleteAlarms(int id)
        {
            using (var db = new AlarmDbContext())
            {
                int counter = 1;

                foreach (var alarm in db.Alarms)
                {
                    if (counter == id)
                    {
                        db.Alarms.Remove(alarm);
                        break;
                    }
                    ++counter;
                }
                db.SaveChanges();
            }
        }