public ActionResult Edit([Bind(Include = "TaloId,TaloNimi,TaloTavoiteLampotila,TaloNykyLampotila,LampoOff,LampoOn")] Talot talot) { if (ModelState.IsValid) { db.Entry(talot).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(talot)); }
public ActionResult Edit(SaunaViewModel model) { Saunat sauna = db.Saunat.Find(model.SaunaId); sauna.SaunaNimi = model.SaunaNimi; sauna.SaunaTavoiteLampotila = model.SaunaTavoiteLampotila; sauna.SaunaNykyLampotila = model.SaunaNykyLampotila; ViewBag.SaunanNimi = new SelectList((from ts in db.Saunat select new { SaunaId = ts.SaunaId, SaunaNimi = ts.SaunaNimi }), "SaunaId", "SaunaNimi", sauna.SaunaId); db.SaveChanges(); return(RedirectToAction("Index")); }//edit
public ActionResult Create(SaunaViewModel model) { AlytaloEntities db = new AlytaloEntities(); Saunat sauna = new Saunat(); sauna.SaunaNimi = model.SaunaNimi; sauna.SaunaTavoiteLampotila = model.SaunaTavoiteLampotila; sauna.SaunaNykyLampotila = model.SaunaNykyLampotila; sauna.SaunanTila = model.SaunanTila; db.Saunat.Add(sauna); //ViewBag.SaunanNimi = new SelectList((from ts in db.Saunat select new { SaunaId = ts.SaunaId, SaunaNimi = ts.SaunaNimi }), "SaunaId", "SaunaNimi", null); try { db.SaveChanges(); } catch (Exception ex) { } return(RedirectToAction("Index")); }//create*/;
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")); }
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
public ActionResult Create(TaloViewModel model) { AlytaloEntities db = new AlytaloEntities(); Talot lampo = new Talot(); lampo.TaloNimi = model.TaloNimi; lampo.TaloNykyLampotila = lampo.TaloNykyLampotila; lampo.TaloTavoiteLampotila = lampo.TaloTavoiteLampotila; lampo.LampoOff = lampo.LampoOff; lampo.LampoOn = lampo.LampoOn; db.Talot.Add(lampo); try { db.SaveChanges(); } catch (Exception ex) { } return(RedirectToAction("Index")); }