Ejemplo n.º 1
0
        public ActionResult NurseryRegister(Nursery nursery)
        {
            if (ModelState.IsValid)
            {
                using (ENDbContext db = new ENDbContext())
                {
                    db.Nurseries.Add(nursery);
                    db.SaveChanges();
                }

                ModelState.Clear();
                ViewBag.Message = nursery.NurseryName + " which is at location " + nursery.Location + " successfully registered.";
            }
            return(RedirectToAction("NurseryAuthenticate"));
        }
Ejemplo n.º 2
0
        public ActionResult UserRegister(User user)
        {
            if (ModelState.IsValid)
            {
                using (ENDbContext db = new ENDbContext())
                {
                    db.Users.Add(user);
                    db.SaveChanges();
                }

                ModelState.Clear();
                ViewBag.Message = user.FirstName + " " + user.LastName + " successfully registered.";
            }
            return(RedirectToAction("UserAuthenticate"));
        }
Ejemplo n.º 3
0
        public ActionResult NurseryLogin(Nursery nursery)
        {
            using (ENDbContext db = new ENDbContext())
            {
                var nrsry = db.Nurseries.Single(n => n.NUserName == nursery.NUserName && n.Password == nursery.Password);

                if (nrsry != null)
                {
                    Session["NurseryId"] = nrsry.NurseryId.ToString();
                    Session["NUserName"] = nrsry.NUserName.ToString();
                    return(RedirectToAction("Index", "Nursery"));
                }
                else
                {
                    ModelState.AddModelError("", "Nursery Username or Password is wrong.");
                    return(View("NurseryLogin"));
                }
            }
        }
Ejemplo n.º 4
0
        public ActionResult UserLogin(User user)
        {
            using (ENDbContext db = new ENDbContext())
            {
                var usr = db.Users.Single(u => u.Username == user.Username && u.Password == user.Password);

                if (usr != null)
                {
                    Session["UserID"]   = usr.UserId.ToString();
                    Session["Username"] = usr.Username.ToString();

                    return(RedirectToAction("Index", "User"));
                }
                else
                {
                    ModelState.AddModelError("", "Username or Password is wrong.");
                    return(View("UserLogin"));
                }
            }
        }
Ejemplo n.º 5
0
        public ActionResult AdminLogin(Admin admin)
        {
            if (ModelState.IsValid)
            {
                using (ENDbContext db = new ENDbContext())
                {
                    var usr = db.Admins.Single(a => a.AUsername == admin.AUsername && a.Password == admin.Password);

                    if (usr != null)
                    {
                        Session["AdminID"]   = usr.AdminId.ToString();
                        Session["AUsername"] = usr.AUsername.ToString();
                        return(RedirectToAction("Index", "Admin"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Admin Username or Password is wrong.");
                        return(View("AdminLogin"));
                    }
                }
            }
            return(View());
        }