Beispiel #1
0
        public ActionResult SetLikeState(int shareid, bool liked)
        {
            int res = 0;

            Liked like = likedManager.Find(x => x.Share.Id == shareid && x.LikedUser.Id == CurrentSession.User.Id);

            Share share = shareManager.Find(x => x.Id == shareid);

            if (like != null && liked == false)
            {
                res = likedManager.Delete(like);
            }
            else if (like == null && liked == true)
            {
                res = likedManager.Insert(new Liked()
                {
                    LikedUser = CurrentSession.User,
                    Share     = share
                });
            }
            if (res > 0)
            {
                if (liked)
                {
                    share.LikeCount++;
                }
                else
                {
                    share.LikeCount--;
                }
                shareManager.Update(share);
                return(Json(new { hasError = false, errorMessage = string.Empty, result = share.LikeCount }));
            }
            return(Json(new { hasError = true, errorMessage = "Beğenme işlemi gerçekleştirilemedi", result = share.LikeCount }));
        }
Beispiel #2
0
        public ActionResult Create(Comments comment, int?shareid)
        {
            if (ModelState.IsValid)
            {
                ModelState.Remove("CreatedDate");



                if (shareid == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                Share share = shareManager.Find(x => x.Id == shareid);


                if (share == null)
                {
                    return(new HttpNotFoundResult());
                }
                comment.Share       = share;
                comment.Owner       = CurrentSession.User;
                comment.CreatedDate = DateTime.Now;
                if (commentManager.Insert(comment) > 0)
                {
                    return(Json(new { result = true }, JsonRequestBehavior.AllowGet));
                }
            }
            return(Json(new { result = false }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Share share = shareManager.Find(x => x.ShareId == id);

            if (share == null)
            {
                return(HttpNotFound());
            }
            return(View(share));
        }