示例#1
0
 public ActionResult Delete(int id, string type)
 {
     dc = new DevicesContext();
     if (typeof(Lamp).ToString() == type)
     {
         d = dc.lamps.Find(id);
         dc.lamps.Remove((Lamp)d);
     }
     else if (typeof(Heating).ToString() == type)
     {
         d = dc.heatings.Find(id);
         dc.heatings.Remove((Heating)d);
     }
     else if (typeof(TV).ToString() == type)
     {
         d = dc.tvsets.Find(id);
         dc.tvsets.Remove((TV)d);
     }
     else if (typeof(Boiler).ToString() == type)
     {
         d = dc.boilers.Find(id);
         dc.boilers.Remove((Boiler)d);
     }
     else if (typeof(Louvers).ToString() == type)
     {
         d = dc.louvers.Find(id);
         dc.louvers.Remove((Louvers)d);
     }
     dc.SaveChanges();
     return Redirect("Index");
 }
示例#2
0
 public ActionResult Edit(int id, string type)
 {
     dc = new DevicesContext();
     if (typeof(Heating).ToString() == type)
     {
         d = dc.heatings.Find(id);
     }
     else if (typeof(TV).ToString() == type)
     {
         d = dc.tvsets.Find(id);
     }
     else if (typeof(Boiler).ToString() == type)
     {
         d = dc.boilers.Find(id);
     }
     else if (typeof(Louvers).ToString() == type)
     {
         d = dc.louvers.Find(id);
     }
     else
     {
         d = dc.lamps.Find(id);
     }
     return View(d);
 }
 public ActionResult OnOff(int id, string type, Device d)
 {
     //  dc = new DevicesContext();
     if (typeof(Lamp).ToString() == type)
     {
         dc.lamps.Find(id).OnOff();
     }
     else if (typeof(Heating).ToString() == type)
     {
         dc.heatings.Find(id).OnOff();
     }
     else if (typeof(TV).ToString() == type)
     {
         dc.tvsets.Find(id).OnOff();
     }
     else if (typeof(Boiler).ToString() == type)
     {
         dc.boilers.Find(id).OnOff();
     }
     else if (typeof(Louvers).ToString() == type)
     {
         dc.louvers.Find(id).OnOff();
     }
     dc.SaveChanges();
     return RedirectToAction("Index");// Redirect("~/Device/Index");
 }