Exemple #1
0
 public static List <settings> UpdateSettings(settings obj)
 {
     using (homeautomationDBEntities entity = new homeautomationDBEntities())
     {
         entity.settings.Remove(entity.settings.First(s => s.index == obj.index));
         entity.SaveChanges();
         entity.settings.Add(obj);
         entity.SaveChanges();
         return(entity.settings.OrderBy(e => e.name).ToList());
     }
 }
Exemple #2
0
 public static void saveUpdate(int listID, bool isOn, DateTime updatedTime)
 {
     using (homeautomationDBEntities entity = new homeautomationDBEntities())
     {
         list command = entity.list.ToList().Find(e => e.ListID == listID);
         entity.list.Remove(command);
         entity.SaveChanges();
         command.state = isOn;
         command.time  = updatedTime;
         entity.list.Add(command);
         entity.SaveChanges();
     }
 }
Exemple #3
0
 public static List <HouseApplianceList> deleteCommand(int id)
 {
     using (homeautomationDBEntities entity = new homeautomationDBEntities())
     {
         list command = entity.list.ToList().Find(e => e.ListID == id);
         entity.list.Remove(command);
         entity.SaveChanges();
         return(getHouseApplList(entity));
     }
 }
Exemple #4
0
 public static void updateAppliancesStatus(bool[,] status)
 {
     using (homeautomationDBEntities entity = new homeautomationDBEntities()){
         for (int i = 0; i < 4; i++)
         {
             for (int j = 0; j < 8; j++)
             {
                 appliances apl = (appliances)entity.appliances.Where(e => e.pin == i * 4 + j);
                 if (apl.state != status[i, j]) // reset! .. different
                 {
                     entity.appliances.Remove(apl);
                     entity.SaveChanges();
                     apl.state = status[i, j];
                     entity.appliances.Add(apl);
                     entity.SaveChanges();
                 }
                 else // same value
                 {
                 }
             }
         }
     }
 }
Exemple #5
0
 public static bool addCommand(Guid inputID, bool isOn, DateTime date, int inputPin)
 {
     try
     {
         using (homeautomationDBEntities entity = new homeautomationDBEntities())
         {
             entity.list.Add(new list
             {
                 pin   = inputPin,
                 state = isOn,
                 time  = date,
             });
             entity.SaveChanges();
         }
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Exemple #6
0
 public static void addMessage(string inName, string inEmail, string inPhoneNum, string inMsg)
 {
     // Guid idd = new Guid();
     try
     {
         using (homeautomationDBEntities entity = new homeautomationDBEntities())
         {
             entity.emails.Add(new emails
             {
                 email       = inEmail,
                 name        = inName,
                 phoneNumber = inPhoneNum,
                 message     = inMsg,
                 ID          = Guid.NewGuid()
             });
             entity.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }