Esempio n. 1
0
        public void RemoveLike(LikeBLL likeBll)
        {
            if (likeBll == null)
            {
                throw new ArgumentNullException("Object cannot be null");
            }
            var like = _db.Likes.Find(p => p.Id == likeBll.Id).SingleOrDefault();

            _db.Likes.Remove(like);
            _db.Save();
        }
Esempio n. 2
0
 public ActionResult Like(LikeBLL like)
 {
     if (_likeService.GetLikeByUserToPhoto(like.UserId, like.PhotoId) != null)
     {
         ViewBag.liked = true;
     }
     else
     {
         ViewBag.liked = false;
     }
     return(PartialView());
 }
Esempio n. 3
0
 public void AddLike(LikeBLL likeBll)
 {
     if (likeBll == null)
     {
         throw new ArgumentNullException("Object cannot be null");
     }
     _db.Likes.Add(new Like()
     {
         Id    = Guid.NewGuid().ToString(),
         Photo = _db.Photos.Find(p => p.Id == likeBll.PhotoId).Single(),
         User  = _db.UserRepository.Find(p => p.Id == likeBll.UserId).Single()
     });
     _db.Save();
 }
Esempio n. 4
0
        public string LikeSave(LikeBLL like)
        {
            var isLike = _likeService.GetLikeByUserToPhoto(like.UserId, like.PhotoId);

            if (isLike == null)
            {
                _likeService.AddLike(like);
            }
            else
            {
                _likeService.RemoveLike(isLike);
            }
            return(LikeCount(like));
        }
Esempio n. 5
0
        public string LikeCount(LikeBLL like)
        {
            var isLike = _likeService.GetLikeByUserToPhoto(like.UserId, like.PhotoId);

            return((@"<span class='glyphicon glyphicon-heart " + (isLike != null ? " red-font" : "") + "'></span>" + GetLikesCount(like.PhotoId)).ToString());
        }