コード例 #1
0
ファイル: AdminController.cs プロジェクト: abyshobs/BeautySNS
        public ActionResult AdminSearch(string searchString)
        {
            //prevents users from accessing the page if they are not logged in
            if (userSession.LoggedIn == false)
            {
                return(Content("You are not logged in ! Please login to view this page"));
            }

            //prevents user from using this search engine if they are not admin
            Account account   = userSession.CurrentUser;
            var     adminUser = accountPermissionDAO.FetchByEmail(account.email);

            if (adminUser == null)
            {
                return(Content("This search engine is only available to admin users"));
            }

            else if (adminUser != null)
            {
                List <Account> accounts = accountDAO.SearchAccounts(searchString);
                if (accounts.Count == 0)
                {
                    TempData["errorMessage"] = "No search results !";
                    return(RedirectToAction("SiteActivity", "Alert"));
                    //return RedirectToAction("Index");
                }

                else if (accounts.Count > 0)
                {
                    //wraps the list of accounts into the index model
                    BeautySNS.Admin.Models.Accounts.IndexViewModel model = new BeautySNS.Admin.Models.Accounts.IndexViewModel(accounts);

                    if (userSession.LoggedIn == true)
                    {
                        model.userSession = true;
                    }

                    else if (userSession.LoggedIn == false)
                    {
                        model.userSession = false;
                    }

                    //model.permissionType = adminUser.Permission.name;
                    model.adminUser         = true;
                    model.loggedInAccount   = account;
                    model.loggedInAccountID = account.accountID;
                    model.fullName          = string.Format("{0} {1}", model.firstName, model.lastName);
                    return(View(model));
                }
            }

            return(View());
        }
コード例 #2
0
        public ActionResult Index(string searchString)
        {
            //prevents users from accessing the page if they are not logged in
            if (userSession.LoggedIn == false)
            {
                return(Content("You are not logged in ! Please login to view this page"));
            }

            //prevents user from searching a profile if they haven't created their profile or if they are admin
            Account account   = userSession.CurrentUser;
            var     adminUser = accountPermissionDAO.FetchByEmail(account.email);

            if (adminUser != null)
            {
                return(Content("Please use the search engine in the admin site"));
            }

            if (account.Profile == null)
            {
                TempData["errorMessage"] = "This search isn't available to users without a BeautySNS profile !";
                return(RedirectToAction("Create", "Profile"));
            }

            else if (account.Profile != null)
            {
                List <Account> accounts = accountDAO.SearchAccounts(searchString);
                if (accounts.Count == 0)
                {
                    TempData["errorMessage"] = "No search results !";
                    return(RedirectToAction("NewsFeed", "Alert"));
                    //return RedirectToAction("Index");
                }

                else if (accounts.Count > 0)
                {
                    //wraps the list of accounts into the index model
                    IndexViewModel model = new IndexViewModel(accounts);
                    model.userSession       = userSession.LoggedIn;
                    model.loggedInAccount   = account;
                    model.loggedInAccountID = account.accountID;
                    model.fullName          = string.Format("{0} {1}", model.firstName, model.lastName);
                    model.adminUser         = false;
                    return(View(model));
                }
            }

            return(View());
        }