// Check login credentials and show dashboard
        public ActionResult Dashboard()
        {
            CinemaViewModel model = (CinemaViewModel)TempData["model"];
            // Request input from cash register login
            string username = Request["username"];
            string password = Request["password"];

            // No user input
            if (username == "" || password == "")
            {
                return(RedirectToAction("CashRegisterEmployeeLogin", "Login", new { error = "Vul a.u.b. beide velden in" }));
            }
            else
            {
                // Get all logins
                IEnumerable <CashRegisterLogin> allLogins = LoginRepo.GetLogins();

                // Check if username and password exist in database
                bool exists = LoginLogic.CheckCashRegisterLogin(username, password, allLogins);

                if (exists == true)
                {
                    model.LoggedInUser         = username;
                    model.LoggedInCashRegister = true;
                    TempData["model"]          = model;
                    return(View("Dashboard", model));
                }
                // No right username - password combination
                else
                {
                    return(RedirectToAction("CashRegisterEmployeeLogin", "Login",
                                            new { error = "Deze combinatie van gebruikersnaam en wachtwoord kon niet gevonden worden" }));
                }
            }
        }
Пример #2
0
        public void TestCashRegisterLogin()
        {
            // Arrange
            // create username, password and list of logins
            string existingusername             = "******";
            string existingpassword             = "******";
            List <CashRegisterLogin> loginslist = new List <CashRegisterLogin>
            {
                new CashRegisterLogin {
                    Password = "******", Username = "******"
                }
            };
            IEnumerable <CashRegisterLogin> logins = loginslist.ToEnumerable();

            // Act
            bool expectedResult = true;
            bool result         = LoginLogic.CheckCashRegisterLogin(existingusername, existingpassword, logins);

            // Assert
            Assert.AreEqual(expectedResult, result);
        }