Пример #1
0
        public void CheckCredentials(string email, string password, string expectedClass, string expectedMessage)
        {
            var user = new User {
                Email = email, Password = password
            };
            var loginService = new LoginService();

            var result = loginService.CheckCredentials(user);

            result.Should().Be((expectedClass, expectedMessage));
        }
Пример #2
0
        // login
        private void LoginBtn_click(object sender, EventArgs e)
        {
            Employess employee = null;
            string    userName = nameTxtBox.Text;
            string    password = passwordTxtBox.Text;

            try
            {
                if (nameTxtBox.Text == "" || passwordTxtBox.Text == "")
                {
                    // throw an exception if one of the text boxes is empty
                    throw new Exception("Please enter your username/password");
                }

                // pass the entered data to the logic/DB to check if it matches
                employee = login.CheckCredentials(new Login(userName, password));

                if (employee == null)
                {
                    // throw an exception if there is no matching with the DB
                    throw new Exception("Please check your credentials");
                }

                if (employee.position == Position.Waiter) // show the order form if the user is a Waiter
                {
                    //add Employee info to the OrderFrom in order to know who logged in
                    orderForm orderForm = new orderForm(employee, this);
                    orderForm.Show();
                    this.Hide(); // hide the login from
                }
                else if (employee.position == Position.Manager)
                {
                    ManageForm manageForm = new ManageForm();
                    manageForm.Show();
                    this.Hide();
                }
                else
                {
                    // show the kitchen/bar form if the user is a Chef/Barman
                    KitchenBarForm kitchenBarForm = new KitchenBarForm(employee);
                    kitchenBarForm.Show();
                    this.Hide(); // hide the login from
                }
            }
            catch (Exception exception)
            {
                // show the message
                MessageBox.Show(exception.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #3
0
        public ActionResult LoginUser(LoginViewModel vm)
        {
            LoginService ls = new LoginService();

            vm.Message = "Enter Proper Name and Password";
            if (ModelState.IsValid)
            {
                bool state = ls.CheckCredentials(vm);
                if (state)
                {
                    Session["Login"] = vm.UserName;
                }
                return(RedirectToAction("Home", "Contact"));
            }

            return(View(vm));
        }
Пример #4
0
        public ActionResult LoginUser(LoginViewModel vm)
        {
            LoginService ls = new LoginService();

            vm.Message = "Enter Proper Captcha";
            if (this.IsCaptchaValid("Invalid Captcha"))
            {
                vm.Message = "Enter Proper Name and Password";
                bool state = ls.CheckCredentials(vm);
                if (state)
                {
                    Session["Login"] = vm.Login.UserName;
                    return(RedirectToAction("Home", "Contact"));
                }
            }

            return(View(vm));
        }