Example #1
0
        public void AddLike(AddLikeDto like)
        {
            var addLike = new Likes();

            var existingLike = _likesRepository.GetFirstWhere(x => x.UserId == like.UserId && x.PostId == like.PostId);

            if (existingLike != null)
            {
                throw new FlowException("Like already exists!");
            }

            addLike = DTOtoModel.AddLikeDTOtoLike(like, addLike);
            _likesRepository.Add(addLike);
            _likesRepository.SaveEntities();
        }