Blog.Services.Implementation.PostLikesService.Add C# (CSharp) Method

Add() public method

public Add ( PostLike postLike ) : void
postLike Blog.Common.Contracts.PostLike
return void
        public void Add(PostLike postLike)
        {
            var result = _postLikesLogic.Add(postLike);
            if (result != null && result.Error != null) throw new Exception(result.Error.Message);

            var postLikes = _postLikesLogic.Get(postLike.PostId);
            var postLikesUpdate = new PostLikesUpdate
            {
                PostId = postLike.PostId,
                PostLikes = postLikes,
                ClientFunction = Constants.SocketClientFunctions.PostLikesUpdate.ToString()
            };

            _redisService.Publish(postLikesUpdate);
        }
    }