// GET: Sauna public ActionResult Index() { List <SaunaViewModel> model = new List <SaunaViewModel>(); AlytaloEntities entities = new AlytaloEntities(); try { List <Saunat> saunat = entities.Saunat.ToList(); foreach (Saunat talosauna in saunat) { SaunaViewModel sauna = new SaunaViewModel(); sauna.SaunaId = talosauna.SaunaId; sauna.SaunaNimi = talosauna.SaunaNimi; sauna.SaunanTila = talosauna.SaunanTila; sauna.SaunaNykyLampotila = talosauna.SaunaNykyLampotila; sauna.SaunaTavoiteLampotila = talosauna.SaunaTavoiteLampotila; model.Add(sauna); } } finally { entities.Dispose(); } return(View(model)); }
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*/;
// GET: Sauna/Details/5 public ActionResult Details(int?id) { SaunaViewModel model = new SaunaViewModel(); AlytaloEntities entities = new AlytaloEntities(); try { Saunat taloSauna = db.Saunat.Find(id); if (taloSauna == null) { return(HttpNotFound()); } Saunat saunadetail = entities.Saunat.Find(taloSauna.SaunaId); SaunaViewModel sauna = new SaunaViewModel(); sauna.SaunaId = saunadetail.SaunaId; sauna.SaunaNimi = saunadetail.SaunaNimi; sauna.SaunaTavoiteLampotila = saunadetail.SaunaTavoiteLampotila; sauna.SaunaNykyLampotila = saunadetail.SaunaNykyLampotila; sauna.SaunanTila = saunadetail.SaunanTila; model = sauna; } finally { entities.Dispose(); } return(View(model)); }
// GET: Talo/Create public ActionResult Create() { AlytaloEntities db = new AlytaloEntities(); TaloViewModel model = new TaloViewModel(); return(View(model)); }
// GET: Talo public ActionResult Index() { List <TaloViewModel> model = new List <TaloViewModel>(); AlytaloEntities entities = new AlytaloEntities(); try { List <Talot> lammot = entities.Talot.ToList(); foreach (Talot talolampo in lammot) { TaloViewModel lampo = new TaloViewModel(); lampo.TaloId = talolampo.TaloId; lampo.TaloNimi = talolampo.TaloNimi; lampo.TaloTavoiteLampotila = talolampo.TaloTavoiteLampotila; lampo.TaloNykyLampotila = talolampo.TaloNykyLampotila; lampo.LampoOff = talolampo.LampoOff; lampo.LampoOn = talolampo.LampoOn; model.Add(lampo); } } finally { entities.Dispose(); } return(View(model)); }
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 public ActionResult Index() { List <ValoViewModel> model = new List <ValoViewModel>(); AlytaloEntities entities = new AlytaloEntities(); try { List <Valot> valot = entities.Valot.ToList(); foreach (Valot talovalo in valot) { ValoViewModel valo = new ValoViewModel(); valo.ValoId = talovalo.ValoId; valo.Huone = talovalo.Huone; valo.ValoOff = talovalo.ValoOff; valo.ValoOn33 = talovalo.ValoOn33; valo.ValoOn66 = talovalo.ValoOn66; valo.ValoOn100 = talovalo.ValoOn100; model.Add(valo); } } finally { entities.Dispose(); } return(View(model)); }
// GET: Sauna/Create public ActionResult Create() { AlytaloEntities db = new AlytaloEntities(); SaunaViewModel model = new SaunaViewModel(); //ViewBag.SaunanNimi = new SelectList((from ts in db.Saunat select new { SaunaId = ts.SaunaId, SaunaNimi = ts.SaunaNimi }), "SaunaId", "SaunaNimi", null); return(View(model)); }
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")); }