Пример #1
0
        public ActionResult Index(string username, string password)
        {
            UserBLL users = new UserBLL();

            var user = users.LogInnUser(password, username);
            if(user == null)
            {
                TempData["error"] = Localization.Get("errorLogIn");
                return RedirectToAction("Index", "Index");
            }
            else
            {
                TempData["success"] = Localization.Get("welcomeBack") + user.username;

                Session["logged_in"] = user;

                return RedirectToAction("Index", "MyPage");
            }
        }
Пример #2
0
        public ActionResult Subscribe(SubscribeViewModel subscribe)
        {
            var firstName = subscribe.firstname;
            var lastName = subscribe.lastname;
            var username = subscribe.username;
            var password = subscribe.password;
            var confirmPassword = subscribe.confirm_password;

            var users = new UserBLL();
            var ok = true;

            //does username exist?
            if(users.CheckIfUsernameExists(username))
            {
                TempData["username_error"] = Localization.Get("errorUserName");
                ok = false;
                Debug.WriteLine("username error");
            }

            //are the password-fields identical?
            if(password != confirmPassword)
            {
                TempData["password_error"] = Localization.Get("errorPasswd");
                ok = false;
                Debug.WriteLine("password error");
            }

            if(ok)
            {
                User newUser = new User
                {
                    userFirstName = firstName,
                    userLastName = lastName,
                    username = username,
                    userPasswd = password
                };

                ok = users.InsertUser(newUser);
                if(ok)
                {
                    Debug.WriteLine("it worked");
                    TempData["success"] = Localization.Get("successSignUp") + username
                        + Localization.Get("approval");

                    Session["logged_in"] = null;

                    return RedirectToAction("Index", "MyPage");
                }
            }
            Debug.WriteLine("didnt work too bad");
            return RedirectToAction("Subscribe");
        }