Exemplo n.º 1
0
        public ActionResult SetLikeProcess(int?id, bool isInsert)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Note note = _noteManager.Get(x => x.Id == id.Value && x.IsDeleted == false);
            User user = CurrentCookieTester.GetCurrentUser(CookieKeys.signedUserToken);

            if (note == null && user == null)
            {
                return(new RedirectResult("/MyEvernoteHome/Index"));
            }

            if (isInsert == true)
            {
                Liked liked = new Liked();
                liked.Note = note;
                liked.User = user;

                if (_likeManager.Get(x => x.Note.Id == note.Id && x.User.Id == user.Id) == null)
                {
                    if (_likeManager.Insert(liked) > 0)
                    {
                        note.LikeCount++;
                        _noteManager.Update(note);
                        return(Json(new { result = 1, likeCount = note.LikeCount, likeStatus = isInsert }, JsonRequestBehavior.AllowGet));
                    }
                    return(Json(new { result = 0, message = "Like Prosesi Ugursuz Oldu. Sistemde Xeta Yarandi Zehmet Olmasa Birazdan Tekrar Cehd Edin", likeCount = note.LikeCount, likeStatus = !isInsert }, JsonRequestBehavior.AllowGet));
                }

                return(new RedirectResult("/MyEvernoteHome/Index"));
            }
            else
            {
                Liked deletingLike = _likeManager.Get(x => x.Note.Id == note.Id && x.User.Id == user.Id);

                if (deletingLike != null)
                {
                    if (_likeManager.PermanentlyDelete(deletingLike) > 0)
                    {
                        note.LikeCount--;
                        _noteManager.Update(note);
                        return(Json(new { result = 1, likeCount = note.LikeCount, likeStatus = isInsert }, JsonRequestBehavior.AllowGet));
                    }

                    return(Json(new { result = 0, message = "Post Beyenilme Prosesi zamani Xeta Formalasdi. Postunuz Beyenilmedi. Zehmet Olmasa Birazdan Tekrar Cehd Edin", likeCount = note.LikeCount, likeStatus = !isInsert }));
                }

                //return Json(new { result = -1, message = "Post Daha Once Dislike Olunmusdur. Sisteminizde Xeta Yaranmisdir Zehmet Olmasa Sehifeni Yenileyin Ve Tekrar Cehd Edin"});
                return(new RedirectResult("/MyEvernoteHome/Index"));
            }
        }
Exemplo n.º 2
0
        public JsonResult Like(EMPLOYEE EMP, string IDEA_ID)
        {
            LikeManager manager    = LikeManager.GetInstance();
            bool        checkLiked = manager.CheckLike(EMP.EMP_ID, IDEA_ID);

            if (checkLiked)
            {
                return(Json(-1));
            }
            return(Json(manager.Insert(IDEA_ID, EMP.EMP_ID, EMP.EMP_NAME)));
        }
        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 }));
        }
Exemplo n.º 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 }));
        }
Exemplo n.º 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" }));
        }