Пример #1
0
        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());
        }