public ActionResult RegFormHandle(string submitbutton, string strFName, string strLName, string strMail,
                                          string strPassword = "******")
        {
            // checking for existing user with same e-mail
            if (DataService.IsUser(strMail) || strFName.Length == 0 || strLName.Length == 0 || strMail.Length == 0)
            {
                // User with the same e-mail already exists
                return(RedirectToAction("WrongAccountForm", "User"));
            }
            else
            {
                FactoryAbstractUser userFactory = new FactoryUser();
                switch (submitbutton)
                {
                case "User":
                    User currUser = userFactory.Create(strFName, strLName, strMail, (int)UserType.User) as User;
                    DataService.UserToDataBase(currUser);

                    // Send notification about registration
                    return(RedirectToAction("Contact", "Email",
                                            new
                    {
                        strUserMail = strMail,
                        strMessage = "Your account (User) was successfully created",
                        strRedirectAction = "RegFormMessage",
                        strRedirectController = "User"
                    }));

                case "Librarian":
                    if (strPassword == "Password")
                    {
                        User currLibrarian =
                            userFactory.Create(strFName, strLName, strMail, (int)UserType.Librarian) as User;
                        DataService.UserToDataBase(currLibrarian);

                        // Send notification about registration
                        return(RedirectToAction("Contact", "Email",
                                                new
                        {
                            strUserMail = strMail,
                            strMessage = "Your account (Librarian) was successfully created",
                            strRedirectAction = "RegFormMessage",
                            strRedirectController = "User"
                        }));
                    }
                    break;

                default:
                    break;
                }

                // ТУТ и в подобных метсах, где может быть ошибка, надо возвращать страницу ошибки и все
                return(RedirectToAction("Index", "Entrance"));
            }
        }
        public ActionResult DeleteFormHandle(string submitbutton, string strMail = null)
        {
            if (submitbutton == "Home")
            {
                return(RedirectToAction("MenuLibrarian", "Entrance"));
            }

            // method checks user for its existing
            if (!DataService.IsUser(strMail) || strMail.Length == 0)
            {
                return(RedirectToAction("WrongAccountForm", "User"));
            }
            User tmpUser = DataService.SearchUser(strMail);

            ViewBag.User = tmpUser;
            // calls the dataservice method to delete information about user
            DataService.DeleteUser(strMail);

            return(View());
        }
        public ActionResult LoginHandler(string submitbutton, string strMail, string strPassword)
        {
            if (!DataService.IsUser(strMail) || strMail.Length == 0)
            {
                return(RedirectToAction("WrongAccountForm", "User"));
            }

            User currUser = DataService.SearchUser(strMail);

            switch (submitbutton)
            {
            case "User":
                // checking for existing user with such mail and role
                if (currUser != null && currUser.Role == (int)UserType.User)
                {
                    // Cause user could only observe books
                    return(RedirectToAction("Index", "Filter"));
                }
                break;

            case "Librarian":
                // checks librarians password
                if (strPassword == "Password")
                {
                    if (currUser != null && currUser.Role == (int)UserType.Librarian)
                    {
                        return(RedirectToAction("MenuLibrarian", "Entrance"));
                    }
                }
                break;

            default:
                break;
            }
            return(RedirectToAction("WrongAccountForm", "User"));
        }