コード例 #1
0
        public ActionResult DeleteLike(Guid blogid, int itemId)
        {
            Like like = _likeManager.Find(x => x.Id == itemId);

            if (like == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            _likeManager.Delete(like);

            CacheHelper.RemoveGetBlogsWithOutDraftDeleteFromCache();
            return(RedirectToAction("Edit", "Blog", new { @id = blogid }));
        }
コード例 #2
0
        public ActionResult BlogPost(Guid?Blog)
        {
            if (Blog == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            BlogPostViewModel model = new BlogPostViewModel();

            model.Blog      = CacheHelper.GetBlogsWithOutDraftDeleteFromCache().FirstOrDefault(x => x.Id == Blog);
            model.Comments  = _commentManager.ListQueryable().Where(x => x.BlogId == Blog).OrderByDescending(x => x.CreatedOn).ToList();
            model.LikeCount = _likeManager.ListQueryable().Where(x => x.BlogId == Blog).ToList().Count();
            model.IsLiked   = _likeManager.Find(x => x.BlogId == Blog && x.AppUserId == CurrentSession.User.Id) == null ? false : true;


            return(View(model));
        }
コード例 #3
0
        public ActionResult SetLikes(int noteId, bool liked)
        {
            int res = 0;

            if (SessionManager.User == null)
            {
                return(Json(new { hasErrorr = true, errorMessagee = "You must entry in system for to like.", ress = 0 }));
            }
            ELiked like = likeManager.Find(x => x.Note.Id == noteId && x.LikedUser.Id == SessionManager.User.Id);

            ENote note = noteManager.Find(x => x.Id == noteId);

            if (like != null && liked == false)
            {
                res = likeManager.Delete(like);
            }
            else if (like == null && liked == true)
            {
                res = likeManager.Insert(new ELiked()
                {
                    LikedUser = SessionManager.User,
                    Note      = note
                });
            }

            if (res > 0)
            {
                if (liked)
                {
                    note.LikeCount++;
                }
                else
                {
                    note.LikeCount--;
                }


                res = noteManager.Update(note);

                return(Json(new { hasErrorr = false, errorMessagee = string.Empty, ress = note.LikeCount }));
            }

            return(Json(new { hasErrorr = true, errorMessagee = "Failed.", ress = note.LikeCount }));
        }
コード例 #4
0
        public ActionResult SetLikeState(int noteid, bool liked)
        {
            int res = 0;

            if (CurrentSession.User == null)
            {
                return(Json(new { hasError = true, errorMessage = "Yorumu beğenebilmek için giriş yapmalısınız", result = 0 }));
            }

            Liked like = likeManager.Find(x => x.Note.Id == noteid && x.LikedUser.Id == CurrentSession.User.Id);
            Note  note = noteManager.Find(x => x.Id == noteid);

            if (like != null && liked == false)
            {
                res = likeManager.Delete(like);
            }
            else if (like == null && liked == true)
            {
                res = likeManager.Insert(new Liked()
                {
                    LikedUser = CurrentSession.User,
                    Note      = note
                });
            }

            if (res > 0)
            {
                if (liked)
                {
                    note.LikeCount++;
                }
                else
                {
                    note.LikeCount--;
                }
                res = noteManager.Update(note);
                return(Json(new { hasError = false, errorMessage = string.Empty, result = note.LikeCount }));
            }
            return(Json(new { hasError = true, errorMessage = "Yorum Beğenilemedi..!", result = note.LikeCount }));
        }
コード例 #5
0
        public ActionResult SetLike(int card_id, bool like)
        {
            int _result = 0;

            if (UserSession.User == null)
            {
                return(Json(new { anyError = true, errorMessage = "Please login", result = 0 }));
            }


            Like liked = likeManager.Find(x => x.Food.Id == card_id && x.LikedUsers.Id == UserSession.User.Id);

            Food food = foodManager.Find(x => x.Id == card_id);

            if (liked != null && like == false)
            {
                _result = likeManager.Delete(liked);
            }
            else if (liked == null && like == true)
            {
                _result = likeManager.Insert(new Like()
                {
                    LikedUsers = UserSession.User,
                    Food       = food
                });
            }

            if (_result > 0)
            {
                _result = foodManager.Update(food);

                return(Json(new { anyError = false, errorMessage = string.Empty }));
            }

            return(Json(new { anyError = true, errorMessage = "Error" }));
        }