Ejemplo n.º 1
0
        public async Task <Like> AddLike(int userId, int recipientId)
        {
            if (userId != int.Parse(httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                throw new Exception("UnAuthorized.!!");
            }
            var getLike = await likeDal.Get(u => u.LikerId == userId && u.LikeeId == recipientId);

            if (getLike != null)
            {
                throw new Exception("You already like this profiles.!!");
            }

            var getLikeesUserFromRepo = await userDal.Get(u => u.Id == recipientId);

            if (getLikeesUserFromRepo == null)
            {
                throw new Exception("Not found that user you want to like.!!");
            }

            getLike = new Like
            {
                LikerId = userId,
                LikeeId = recipientId
            };

            var addLikeToDb = await likeDal.Add(getLike);

            if (addLikeToDb == null)
            {
                throw new Exception("Failed to like user.!!");
            }

            return(addLikeToDb);
        }
Ejemplo n.º 2
0
        public IDataResult <Like> Add(Like like)
        {
            var like2 = _likeDal.Get(like1 => like1.UserId == like.UserId && like1.PhotoId == like.PhotoId);

            if (like2 == null)
            {
                _likeDal.Add(like);
                like2 = like;
            }
            return(new SuccessDataResult <Like>(like2));
        }
Ejemplo n.º 3
0
        public IResult Add(Like like)
        {
            IResult result = BusinessRule.Run
                             (
                _userService.CheckIfUserExist(like.UserId),
                _videoService.CheckIfVideoExist(like.VideoId),
                CheckIfLikeAlreadyExist(like.Id)
                             );

            if (result != null)
            {
                return(result);
            }

            _likeDal.Add(like);
            return(new SuccessResult());
        }
Ejemplo n.º 4
0
 public Like Insert(Like like)
 {
     return(_likeDal.Add(like));
 }
Ejemplo n.º 5
0
 public void Add(Like like)
 {
     _likeDal.Add(like);
 }