示例#1
0
        public JsonResult ChangeToFollower(int id)
        {
            int      fromAccountID = (int)Session["userID"];
            Follower follower      = _followerService.GetFollower(fromAccountID, id);

            if (follower == null)
            {
                _followerService.Add(new Follower
                {
                    FollowDate    = DateTime.Now,
                    FromAccountID = fromAccountID,
                    ToAccountID   = id
                });
                return(Json(Mapper.Map <List <DiaryForProfileDto> >(_diaryService.GetDiariesForFollower(id)), JsonRequestBehavior.AllowGet));
            }
            else
            {
                _followerService.Delete(follower);
                return(Json(Mapper.Map <List <DiaryForProfileDto> >(_diaryService.GetDiariesForPublic(id)), JsonRequestBehavior.AllowGet));
            }
        }