public ActionResult Index() { string currentUserId = User.Identity.GetUserId(); object profileId = Request.RequestContext.RouteData.Values["Id"]; UserSignUpModel user = null; if (!string.IsNullOrWhiteSpace((string)profileId)) { var allFriends = friendRepository.GetAllFriendsForUser((string)profileId); user = userRepository.Get((string)profileId); ViewBag.ProfileId = (string)profileId; ViewBag.CurrentUserId = currentUserId; ViewBag.Request = requestRepository.PendingRequest(currentUserId, (string)profileId); ViewBag.Friendship = friendRepository.AlreadyFriends(currentUserId, (string)profileId); if (allFriends.Count > 0) { ViewBag.AllFriends = allFriends; ViewBag.hasFriends = true; } else { ViewBag.hasFriends = false; } } else { var allFriends = friendRepository.GetAllFriendsForUser(currentUserId); user = userRepository.Get(currentUserId); ViewBag.ProfileId = currentUserId; ViewBag.CurrentUserId = currentUserId; ViewBag.Request = requestRepository.PendingRequest(currentUserId, (string)profileId); ViewBag.Friendship = friendRepository.AlreadyFriends(currentUserId, (string)profileId); if (allFriends.Count > 0) { ViewBag.AllFriends = allFriends; ViewBag.hasFriends = true; } else { ViewBag.hasFriends = false; } } return(View(user)); }