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()); }
public ActionResult Friends(int accountID = 0) { Account account = userSession.CurrentUser; accountID = account.accountID; var friends = friendDAO.FetchFriendsAccountByAccountID(accountID); BeautySNS.Admin.Models.Accounts.IndexViewModel model = new BeautySNS.Admin.Models.Accounts.IndexViewModel(friends); model.userSession = userSession.LoggedIn; model.fullName = string.Format("{0} {1}", account.firstName, account.lastName); model.loggedInAccountID = account.accountID; model.loggedInAccount = account; //model.adminUser = false; return(View(model)); }
public ActionResult AllUserFriends(int id = 0) { Account _account = userSession.CurrentUser; Account account = accountDAO.FetchById(id); var friends = friendDAO.FetchFriendsAccountByAccountID(id); BeautySNS.Admin.Models.Accounts.IndexViewModel model = new BeautySNS.Admin.Models.Accounts.IndexViewModel(friends); model.userSession = userSession.LoggedIn; model.firstName = account.firstName; model.userAccountID = account.accountID; model.fullName = string.Format("{0} {1}", _account.firstName, _account.lastName); model.loggedInAccountID = _account.accountID; model.loggedInAccount = _account; return(View(model)); }
//lists out the accounts of the site users on the system public ActionResult UserAccounts() { //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 non admin users from viewing the page Account account = userSession.CurrentUser; var adminUser = accountPermissionDAO.FetchByEmail(account.email); if (adminUser == null) { return(Content("This page is restricted to super admin users.")); } //calls method in repository that lists out all the accounts in the system IEnumerable <Account> accounts = accountDAO.FetchAllUserAccounts(); //returns a list of only non admin accounts List <Account> userAccounts = new List <Account>(); foreach (Account a in accounts) { var adminAccount = accountPermissionDAO.FetchByEmail(a.email); if (adminAccount == null) { userAccounts.Add(a); } } List <Account> result = userAccounts.ToList(); //wraps list into model BeautySNS.Admin.Models.Accounts.IndexViewModel model = new BeautySNS.Admin.Models.Accounts.IndexViewModel(result); model.adminUser = true; model.userSession = userSession.LoggedIn; model.loggedInAccount = account; model.loggedInAccountID = account.accountID; model.permissionType = adminUser.Permission.name; return(View(model)); }
//admin view of a user's network public ActionResult UserNetwork(int id = 0) { //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 access to non admin users Account account = userSession.CurrentUser; var adminUser = accountPermissionDAO.FetchByEmail(account.email); if (adminUser == null) { return(Content("This page is restricted to admin users.")); } //returns error message if user does not exist Account _account = accountDAO.FetchById(id); if (_account == null) { TempData["errorMessage"] = "This user does not exist"; return(RedirectToAction("SiteActivity", "Alert")); } var friends = friendDAO.FetchFriendsAccountByAccountID(id); BeautySNS.Admin.Models.Accounts.IndexViewModel model = new BeautySNS.Admin.Models.Accounts.IndexViewModel(friends); model.adminUser = true; model.userSession = userSession.LoggedIn; model.loggedInAccount = account; model.userSession = userSession.LoggedIn; model.loggedInAccountID = account.accountID; model.permissionType = adminUser.Permission.name; model.firstName = _account.firstName; model.userAccountID = _account.accountID; return(View(model)); }