// GET: SaunaTila
        public ActionResult Index()
        {
            List <SaunaVIewModel> model    = new List <SaunaVIewModel>();
            älytalodbEntities     entities = new älytalodbEntities();

            try
            {
                List <Sauna> sau = entities.Sauna.OrderByDescending(Sauna => Sauna.SaunaId).ToList();
                foreach (Sauna saun in sau)
                {
                    SaunaVIewModel view = new SaunaVIewModel();
                    view.SaunaId             = saun.SaunaId;
                    view.SaunanTila          = saun.SaunanTila;
                    view.SaunanNykyLampotila = saun.SaunanNykyLampotila;
                    view.SaunaStart          = saun.SaunaStart;
                    view.SaunaStop           = saun.SaunaStop;
                    view.SaunanNimi          = saun.SaunanNimi;
                    model.Add(view);
                }
            }
            finally
            {
                entities.Dispose();
            }
            return(View(model));
        }
Example #2
0
        public ActionResult Create()
        {
            älytalodbEntities  db    = new älytalodbEntities();
            LampotilaViewModel model = new LampotilaViewModel();

            return(View(model));
        }
        // GET: SaunaTila/Create
        public ActionResult Create()
        {
            älytalodbEntities db    = new älytalodbEntities();
            SaunaVIewModel    model = new SaunaVIewModel();

            return(View(model));
        }
        // GET: ValoTila
        public ActionResult Index()
        {
            List <ValoViewModel> model    = new List <ValoViewModel>();
            älytalodbEntities    entities = new älytalodbEntities();

            try
            {
                List <Valot> val = entities.Valot.OrderByDescending(Valot => Valot.ValoId).ToList();
                foreach (Valot valo in val)
                {
                    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;
                    model.Add(view);
                }
            }
            finally
            {
                entities.Dispose();
            }
            return(View(model));
        }
Example #5
0
        public ActionResult Register(UserDataViewModel LogEnt)
        {
            if (ModelState.IsValid)
            {
                älytalodbEntities Log = new älytalodbEntities();

                Users us = new Users();
                us.UserName = LogEnt.UserName;
                us.Password = LogEnt.Password;
                Log.Users.Add(us);
                Log.SaveChanges();
                ViewBag.Success = "Your username is: " + LogEnt.UserName + " And password: " + LogEnt.Password;
            }

            return(View(LogEnt));
        }
Example #6
0
 public ActionResult Login(UserDataViewModel us)
 {
     if (ModelState.IsValid)
     {
         älytalodbEntities entities = new älytalodbEntities();
         {
             var log = entities.Users.Where(a => a.UserName.Equals(us.UserName) && a.Password.Equals(us.Password)).FirstOrDefault();
             if (log != null)
             {
                 Session["username"] = log.UserName;
                 return(RedirectToAction("Index", "Home"));
             }
             else
             {
                 Response.Write("<script> alert('Väärä salasana')</script>");
             }
         }
     }
     return(View());
 }
Example #7
0
        public ActionResult Index()
        {
            List <LampotilaViewModel> model    = new List <LampotilaViewModel>();
            älytalodbEntities         entities = new älytalodbEntities();

            try
            {
                List <Lampo> lamp = entities.Lampo.OrderByDescending(Lampo => Lampo.LampoId).ToList();
                foreach (Lampo lam in lamp)
                {
                    LampotilaViewModel view = new LampotilaViewModel();
                    view.LampoId = lam.LampoId;
                    view.TalonTavoiteLampotila = lam.TalonTavoiteLampotila;
                    view.TalonNykyLampotila    = lam.TalonNykyLampotila;
                    view.LampotilaAsetettu     = lam.LampotilaAsetettu;
                    model.Add(view);
                }
            }
            finally
            {
                entities.Dispose();
            }
            return(View(model));
        }