Пример #1
0
        public ActionResult Verify(Inventory_management.Models.login userModel)
        {
            using (inventorymgtEntities dbModel = new inventorymgtEntities())
            {
                var pass        = userModel.password_;
                var userDetails = dbModel.users.Where(x => x.email == userModel.username).FirstOrDefault();
                if (userDetails == null)
                {
                    userModel.status_ = "Invalid User Credentials.";

                    return(View("Login", userModel));
                }

                else
                if (userDetails.email.Equals("*****@*****.**") && userDetails.password_.Equals("1202"))
                {
                    return(View("~/Views/Search/Index.cshtml"));
                }

                else
                {
                    Session["userID"] = userDetails.regId;
                    Session["user"]   = userDetails.fname;
                    return(View("Welcome"));
                }
            }
        }
Пример #2
0
        public ActionResult Verify(Inventory_management.Models.login userModel)
        {
            using (inventorymgtEntities dbModel = new inventorymgtEntities())
            {
                var pass = userModel.password_ != null?userModel.password_.ToString() : "";

                var usrname = userModel.username != null?userModel.username.ToString() : "";

                if (pass != null && usrname != null)
                {
                    var userDetails = dbModel.users.Where(x => x.email == usrname && x.password_ == pass).FirstOrDefault();

                    if (userDetails != null && userDetails.email != null && userDetails.password_ != null && userDetails.email.Equals("*****@*****.**") && userDetails.password_.Equals("1202"))
                    {
                        Session["userID"]     = userDetails.regId;
                        Session["user"]       = userDetails.fname;
                        Session["occupation"] = userDetails.ocp;

                        return(RedirectToAction("Index", "Search"));
                    }
                    else if (userDetails == null)
                    {
                        userModel.status_ = "Invalid User Credentials.";

                        return(View("Login", userModel));
                    }
                    else
                    {
                        Session["userID"]     = userDetails.regId;
                        Session["user"]       = userDetails.fname;
                        Session["occupation"] = userDetails.ocp;
                        return(View("Welcome"));
                    }
                }
                else
                {
                    userModel.status_ = "Invalid User Credentials.";

                    return(View("Login", userModel));
                }
            }
        }