Пример #1
0
        public ActionResult Follow(int channelid, bool followed)
        {
            int     res     = 0;
            Follow  follow  = followmanager.Find(x => x.Channel.id == channelid && x.Owner.id == CurrentSession.User.id);
            Channel channel = channelmanager.Find(x => x.id == channelid);

            if (follow != null && followed == false)
            {
                res = followmanager.Delete(follow);
            }
            else if (follow == null && followed == true)
            {
                res = followmanager.Insert(new Follow()
                {
                    CreatedOn = DateTime.Now,
                    Channel   = channel,
                    Owner     = CurrentSession.User
                });
            }
            if (res > 0)
            {
                return(Json(new { hasError = false, errorMessage = string.Empty, result = channel.Follows.Count }));
            }
            return(Json(new { hasError = true, errorMessage = "Takip etme işlemi gerçekleştirilemedi.", result = channel.Follows.Count }));
        }
        public ActionResult RequestFollow(int following_id)
        {
            FollowManager fm = new FollowManager();
            Follow        f  = new Follow()
            {
                Following = following_id,
                Follower  = (Session["user"] as User).Id,
            };

            fm.Insert(f);
            Notification not = new Notification()
            {
                Comment   = "",
                Date      = DateTime.Now,
                FromWho   = (Session["user"] as User).Id,
                ToWho     = following_id,
                Type      = 2,
                projectid = -1,
            };

            nm.Insert(not);
            return(View());
        }