public PostLike Add(PostLike postLike)
{
try
{
var tmpPostLike = _postLikeRepository.Find(a => a.PostId == postLike.PostId && a.UserId == postLike.UserId, false).ToList();
if (tmpPostLike.Count > 0)
{
_postLikeRepository.Delete(tmpPostLike.FirstOrDefault());
return null;
}
return PostLikeMapper.ToDto(_postLikeRepository.Add(PostLikeMapper.ToEntity(postLike)));
}
catch (Exception ex)
{
throw new BlogException(ex.Message, ex.InnerException);
}
}
}