// GET: /Profile/ public ActionResult Index(string id) { var user = (User)Session["User"]; Profile profile = null; if (login.CheckSession(user)) { var sentTORequest = userManager.GetUserByProfileId(Convert.ToInt32(id)); ViewBag.User = ""; Session["User2"] = sentTORequest.Id.ToString(); profile = profileManager.GetProfileByUserId(user.Id); if (profile.Id == Convert.ToInt32(id)) { ViewBag.ThisUser = 1; } else { ViewBag.ThisUser = 0; } ViewBag.CurrentUserProfile = user.Profile; ViewBag.Layout = "~/Views/Profile/Index.cshtml"; ViewBag.Name = user.Profile.FristName + " " + user.Profile.LastName; if (friendRequestManager.CheckDuplication(user.Id, sentTORequest.Id)) { ViewBag.FriendReqeust = 1; } if (id != null) { ViewBag.User = (string)Session["User2"]; profile = profileManager.GetProfileById(Convert.ToInt32(id)); } //check the friend list var userId = userManager.GetUserByProfileId(Convert.ToInt32(id)); var friendList = friendsManager.CheckFriendList(user.Id, userId.Id); if (friendList) { ViewBag.Friend = 1; } else { ViewBag.Friend = 0; } ViewBag.Profile = profile; var currentProfileId = profileManager.GetProfileByUserId(user.Id); var getUserId = userManager.GetUserByProfileId(Convert.ToInt32(id)); Work work = null; Education education = null; Address address = null; Hobby hobby = null; if (id == null) { work = workMnager.GetWorkByUser(user); education = educaionManager.GetEducationByUser(user); address = addressManager.GetAddressByUserId(user); hobby = hobbyManager.GetHobyByUser(user); } else { work = workMnager.GetWorkByUser(getUserId); education = educaionManager.GetEducationByUser(getUserId); address = addressManager.GetAddressByUserId(getUserId); hobby = hobbyManager.GetHobyByUser(getUserId); } ViewBag.CoverPhoto = profile.CoverPicture; ViewBag.ProfilePicture = profile.Picture; ViewBag.Work = work; ViewBag.Education = education; ViewBag.Address = address; ViewBag.Hobby = hobby; ViewBag.ConfirmFriendRequest = friendRequestManager.ConfirmFriendRequest(user.Id, sentTORequest.Id); ViewBag.Name = user.Profile.FristName + " " + user.Profile.LastName; return(View()); } else { return(View("Error")); } }