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

Add() public method

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

            var viewCounts = _viewCountLogic.Get(viewCount.PostId);
            var viewCountUpdate = new ViewCountUpdate
            {
                PostId = viewCount.PostId,
                ViewCounts = viewCounts,
                ClientFunction = Constants.SocketClientFunctions.ViewCountUpdate.ToString()
            };

            _redisService.Publish(viewCountUpdate);
        }
    }