public ActionResult Search() { ViewData["loginModal"] = -100; ViewData["UserLog"] = true; if (User.Identity.Name != null || User.Identity.Name != "") { ViewData["UserLoggedIn"] = true; ViewData["Username"] = User.Identity.Name; } else { ViewData["Username"] = null; } UserDBAccess db = new UserDBAccess(); SessionVariables.UserData = db.GetUserInfoByName(User.Identity.Name); UsersDatabaseEntities entity = new UsersDatabaseEntities(); int userID = SessionVariables.UserData.Id; //Get all the users List <GetAllUsers_Result> data = entity.GetAllUsers(userID).ToList(); //Get the users friends List <GetUserFriends_Result> userFriends = entity.GetUserFriends(userID).ToList(); ViewBag.userdetails = data; ViewBag.userFriends = userFriends; return(View()); }
public ActionResult Index() { ViewData["loginModal"] = -100; ViewData["Username"] = User.Identity.Name; if (User.Identity.Name == null) { FormsAuthentication.SignOut(); } UsersDatabaseEntities entity = new UsersDatabaseEntities(); UserDBAccess db = new UserDBAccess(); //If the user's data is null //In other words auto logged in if (SessionVariables.UserData == null) { //get the user's data SessionVariables.UserData = db.GetUserInfoByName(User.Identity.Name); } //set the users id int id = SessionVariables.UserData.Id; //check term of use agreements //0 = false 1=true int agree = Convert.ToInt32(entity.AgreedTermsUseFunc(id).FirstOrDefault()); //redirect to agree to terms of use if (agree == 0) { return(Redirect("/User/TermsAgree")); } //check for friend requests var requests = entity.CheckFriendRequests(id); //Search for user friends and return their info by the user's id var data = entity.GetUserFriends(id).ToList(); //Get links data List <GetUserSocialLinks_Result> links = entity.GetUserSocialLinks(id).ToList(); //Set view Data ViewBag.requests = requests; ViewBag.friends = data; ViewBag.Links = links; return(View()); }
public ActionResult AddFriend(string UserID) { UsersDatabaseEntities entity = new UsersDatabaseEntities(); UserDBAccess db = new UserDBAccess(); //create new friend FUID friend = new FUID(); friend.BLOCK = false; friend.FRIENDID = Convert.ToInt32(UserID); int userID = db.GetUserInfoByName(User.Identity.Name).Id; friend.USERID = userID; friend.Confirmed = 1; List <GetUserFriends_Result> usersFriends = entity.GetUserFriends(userID).ToList(); bool friended = false; //Check each id for if already friend foreach (GetUserFriends_Result uf in usersFriends) { if (uf.ID == userID) { friended = true; } } if (!friended) { entity.AddNewFriend(friend.FRIENDID, friend.BLOCK, friend.USERID); } Users users = new Users { Id = friend.USERID }; SessionVariables.UserData = users; return(Redirect("/User/Friends/")); }
public ActionResult UserPage(string userName) { //get user data ViewData["loginModal"] = -100; ViewData["UserLog"] = true; if (User.Identity.Name != null || User.Identity.Name != "") { ViewData["UserLoggedIn"] = true; ViewData["Username"] = User.Identity.Name; } else { ViewData["Username"] = null; } //set the looked up user name ViewData["UserLookedUp"] = userName; //get searched user UsersDatabaseEntities entity = new UsersDatabaseEntities(); UserDBAccess db = new UserDBAccess(); //get user info by name SessionVariables.UserPage = db.GetUserInfoByName(userName); //set the users id int id = SessionVariables.UserPage.Id; //Search for user friends and return their info by the user's id var friends = entity.GetUserFriends(id).ToList(); //Get links data List <GetUserSocialLinks_Result> links = entity.GetUserSocialLinks(id).ToList(); //Set view Data ViewBag.friends = friends; ViewBag.Links = links; return(View()); }