Ejemplo n.º 1
0
        /// <summary>
        /// Follow útfærir virknina þegar þú sem notandi vilt "fylgja" öðrum notenda
        /// </summary>
        public ActionResult Follow(string id)
        {
            var statusList = new List <Feed>();
            var followList = new List <FollowList>();

            var myProfileRepo = new StatusRepository();

            statusList = myProfileRepo.ReturnProfileStatuses(id);
            followList = myProfileRepo.ReturnFollowingList(id);

            var displayProfile = new ProfileViewModel();

            displayProfile.myFeedList     = statusList;
            displayProfile.myFullNameList = followList;
            displayProfile.OpenID         = id;
            displayProfile.isFollowing    = true;

            string yourId  = id;
            string otherId = User.Identity.GetUserId();

            // AreFollowers fallið athugar niður í grunn hvort notendur
            // eru nú þegar að fylgja hvorum öðrum. Ef ekki þá skrifum við vensl í töflu
            if (!myProfileRepo.AreFollowers(id, otherId))
            {
                var myRepo = new StatusRepository();
                myRepo.MakeFollowers(otherId, id);
            }

            return(RedirectToAction("ProfilePage", new
            {
                id = id
            }));
        }