コード例 #1
0
ファイル: Users.cs プロジェクト: coder-ferox/xmas-warehouse
        public void Get_User_Should_Return_Test_User()
        {
            var db   = new xmasDB();
            var test = new User
            {
                Username = USERNAME,
                Password = USERPASSWORD
            };
            var user = db.GetUser(test);

            Assert.IsNotNull(user);
        }
コード例 #2
0
        public ActionResult Login(User user)
        {
            xmasDB db  = new xmasDB();
            var    usr = db.GetUser(user);

            if (usr != null)
            {
                Session["Email"]    = usr.Email.ToString();
                Session["UserID"]   = usr.Id.ToString();
                Session["Username"] = usr.Username.ToString();
                if (usr.IsAdmin)
                {
                    Session["IsAdmin"] = usr.IsAdmin.ToString();
                }
                return(RedirectToAction($"../Home"));
            }
            else
            {
                ModelState.AddModelError("", "Email or password incorrect");
            }
            return(View());
        }