public bool MuutaValonTilaa(Valot uusi) { bool OK = false; MobiilikantaContext db = new MobiilikantaContext(); Valot valo = db.Valot.FirstOrDefault((v) => v.ValoId == uusi.ValoId); valo.ValonMaara = uusi.ValonMaara; valo.ValonTila = true; if (uusi.ValonMaara == 0) { valo.ValonTila = false; } try { db.Entry(valo).State = EntityState.Modified; db.SaveChanges(); OK = true; } finally { db.Dispose(); } return(OK); }
}// // GET: TaloValo/Light100/5 public ActionResult Light100(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Valot talovalo = db.Valot.Find(id); if (talovalo == null) { return(HttpNotFound()); } ValoViewModel valo = new ValoViewModel(); valo.ValoId = talovalo.ValoId; valo.ValoOn33 = false; valo.ValoOn66 = false; valo.ValoOn100 = true; valo.ValoOff = false; // ViewBag.Huone = new SelectList((from tv in db.Valot select new { ValoId = tv.ValoId, Huone = tv.Huone }), "ValoId", "Huone", null); // ViewBag.ValaisinTYpe = new SelectList((from tv in db.TaloValo select new { Valo_ID = tv.Valo_ID, Huone = tv.Huone }), "Valo_ID", "ValaisinType", null); return(View(valo)); }
public ActionResult Create(ValoViewModel model) { AlytaloEntities db = new AlytaloEntities(); Valot valo = new Valot(); valo.Huone = model.Huone; valo.ValoOff = model.ValoOff; valo.ValoOn33 = model.ValoOn33; valo.ValoOn66 = model.ValoOn66; valo.ValoOn100 = model.ValoOn100; db.Valot.Add(valo); try { db.SaveChanges(); } catch (Exception ex) { } return(RedirectToAction("Index")); }
//GET: Valo/Valo100 //näkymän luonti: template:edit ja model class: Valot(Alytalo...) public ActionResult Valo100(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Valot val = db.Valot.Find(id); if (val == null) { return(HttpNotFound()); } ValoViewModel va = new ValoViewModel(); va.ValoID = val.ValoID; va.Valot0 = false; va.Valot33 = false; va.Valot66 = false; va.Valot100 = true; va.ValoHuone = val.ValoHuone; //va.ValoTime0 = val.ValoTime0; //va.ValoTime33 = val.ValoTime33; //va.ValoTime66 = val.ValoTime66; va.ValoTime100 = val.ValoTime100; return(View(va)); }
public ActionResult NewValot(Valot pro) { AlyTaloEntities entities = new AlyTaloEntities(); int id = pro.ValoID; bool OK = false; if (pro.ValoID == 0) { // kyseessä on uuden asiakkaan lisääminen, kopioidaan kentät Valot dbItem = new Valot() { ValoID = pro.ValoID, Huone = pro.Huone, }; // tallennus tietokantaan entities.Valot.Add(dbItem); entities.SaveChanges(); OK = true; } ModelState.Clear(); entities.Dispose(); return(Json(OK, JsonRequestBehavior.AllowGet)); }
// GET: ValoTila/valo100/5 public ActionResult Valo100(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Valot valot = db.Valot.Find(id); if (valot == null) { return(HttpNotFound()); } ValoViewModel view = new ValoViewModel(); view.ValoId = valot.ValoId; view.HuoneValo = valot.HuoneValo; view.Valo33 = false; view.Valo66 = false; view.Valo100 = true; view.ValoOff = false; return(View(view)); }
// GET: ValoTila/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Valot valo = db.Valot.Find(id); if (valo == null) { return(HttpNotFound()); } ValoViewModel view = new ValoViewModel(); view.ValoId = valo.ValoId; view.Valo33 = valo.Valo33; view.Valo66 = valo.Valo66; view.Valo100 = valo.Valo100; view.Valo33Aika = valo.Valo33Aika; view.Valo66AIka = valo.Valo66AIka; view.valo100Aika = valo.valo100Aika; view.ValoOff = valo.ValoOff; view.HuoneValo = valo.HuoneValo; view.ValoOffAika = valo.ValoOffAika; return(View(view)); }
public ActionResult DeleteConfirmed(int id) { Valot valot = db.Valot.Find(id); db.Valot.Remove(valot); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(ValoViewModel model) { Valot view = db.Valot.Find(model.ValoId); view.HuoneValo = model.HuoneValo; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(ValoViewModel model) { Valot va = db.Valot.Find(model.ValoID); va.ValoHuone = model.ValoHuone; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ValoID,ValonSijainti")] Valot valot) { if (ModelState.IsValid) { db.Entry(valot).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(valot)); }
public ActionResult Create([Bind(Include = "ValoID,HuoneValo,ValoOff,Valo33,Valo66,Valo100")] Valot valot) { if (ModelState.IsValid) { db.Valot.Add(valot); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(valot)); }
public ActionResult Create([Bind(Include = "ValoID,ValonSijainti")] Valot valot) { if (ModelState.IsValid) { db.Valot.Add(valot); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(valot)); }
public ActionResult Edit([Bind(Include = "Valo_id,Huone,Valaisin,ValonTila,ValonMaara")] Valot valot) { if (ModelState.IsValid) { db.Entry(valot).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Huone = new SelectList(db.Huoneet, "Huone_id", "Huone", valot.Huone); return(View(valot)); }
public ActionResult Create([Bind(Include = "ValoID,ValonSijainti,ValoPaalla,ValonMaara,PVM")] Valot valot) { if (ModelState.IsValid) { db.Valot.Add(valot); valot.PVM = DateTime.Now; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(valot)); }
public ActionResult Valo100(ValoViewModel model) { Valot view = db.Valot.Find(model.ValoId); view.HuoneValo = model.HuoneValo; view.Valo33 = false; view.Valo66 = false; view.Valo100 = true; view.ValoOff = false; view.valo100Aika = DateTime.Now; db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: Valo/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Valot valot = db.Valot.Find(id); if (valot == null) { return(HttpNotFound()); } return(View(valot)); }
// GET: Valots/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Valot valot = db.Valot.Find(id); if (valot == null) { return(HttpNotFound()); } ViewBag.Huone = new SelectList(db.Huoneet, "Huone_id", "Huone", valot.Huone); return(View(valot)); }
public ActionResult Edit(ValoViewModel model) { Valot valo = db.Valot.Find(model.ValoId); //valo.Valo_ID = model.Valo_ID; valo.Huone = model.Huone; // ViewBag.Huone = new SelectList((from tv in db.Valot select new { ValoId = tv.ValoId, Huone = tv.Huone }), "ValoId", "Huone", null); db.SaveChanges(); return(RedirectToAction("Index")); }//edit
// GET: Valo/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Valot valot = db.Valot.Find(id); valot.PVM = DateTime.Now; if (valot == null) { return(HttpNotFound()); } return(View(valot)); }
public ActionResult Valo100(ValoViewModel model) { Valot va = db.Valot.Find(model.ValoID); va.Valot0 = false; va.Valot33 = false; va.Valot66 = false; va.Valot100 = true; va.ValoHuone = model.ValoHuone; //va.ValoTime0 = DateTime.Now; //va.ValoTime33 = DateTime.Now; //va.ValoTime66 = DateTime.Now; va.ValoTime100 = DateTime.Now; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Light66(ValoViewModel model) { Valot valo = db.Valot.Find(model.ValoId); valo.ValoOn33 = false; valo.ValoOn66 = true; valo.ValoOn100 = false; // ViewBag.Huone = new SelectList((from tv in db.Valot select new { ValoId = tv.ValoId, Huone = tv.Huone }), "ValoId", "Huone", null); db.SaveChanges(); return(RedirectToAction("Index")); }//
public ActionResult Create(ValoViewModel model) { Valot view = new Valot(); view.ValoId = model.ValoId; view.HuoneValo = model.HuoneValo; db.Valot.Add(view); try { db.SaveChanges(); } catch (Exception ex) { } return(RedirectToAction("Index")); }
public ActionResult Create(ValoViewModel model) { Valot va = new Valot(); va.ValoID = model.ValoID; va.ValoHuone = model.ValoHuone; db.Valot.Add(va); try { db.SaveChanges(); } catch (Exception ex) { } return(RedirectToAction("Index")); }
public ActionResult DeleteValot(Valot pro) { AlyTaloEntities entities = new AlyTaloEntities(); //haetaan id:n perusteella rivi SQL tietokannasta Valot dbItem = (from p in entities.Valot where p.ValoID == pro.ValoID select p).FirstOrDefault(); { // tietokannasta poisto entities.Valot.Remove(dbItem); entities.SaveChanges(); OK = true; } entities.Dispose(); return(Json(OK, JsonRequestBehavior.AllowGet)); }
public ActionResult Valot66(string id) { AlyTaloEntities entities = new AlyTaloEntities(); bool OK = false; Valot dbItem = (from v in entities.Valot where v.ValoID.ToString() == id select v).FirstOrDefault(); if (dbItem != null) { dbItem.Tila = "Tavallinen"; entities.SaveChanges(); OK = true; } //entiteettiolion vapauttaminen entities.Dispose(); // palautetaan 'json' muodossa return(Json(OK, JsonRequestBehavior.AllowGet)); }
// GET: Valo/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Valot talovalo = db.Valot.Find(id); if (talovalo == null) { return(HttpNotFound()); } ValoViewModel valo = new ValoViewModel(); valo.ValoId = talovalo.ValoId; valo.Huone = talovalo.Huone; // ViewBag.Huone = new SelectList((from tv in db.Valot select new { Valo_ID = tv.ValoId, Huone = tv.Huone }), "ValoId", "Huone", null); return(View(valo)); }
}//edit // GET: TaloValo/LightsOff/5 public ActionResult LightsOff(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Valot Valot = db.Valot.Find(id); if (Valot == null) { return(HttpNotFound()); } ValoViewModel valo = new ValoViewModel(); valo.ValoId = Valot.ValoId; valo.ValoOn33 = false; valo.ValoOn66 = false; valo.ValoOn100 = false; valo.ValoOff = true; return(View(valo)); }