public async Task <Unit> Handle(CreateCommentLikeCommand request, CancellationToken cancellationToken) { var entity = _mapper.Map <CommentLike>(request); entity.UserId = int.Parse(_userService.GetUserId()); _context.CommentLikes.Add(entity); if (await _context.SaveChangesAsync(cancellationToken) > 0) { var item = _context.CommentLikes .Where(x => x.CommentId == entity.CommentId && x.UserId == entity.UserId) .FirstOrDefault(); await _wallService.SendCommentLike(entity.UserId, item.Id, item.CommentId); var recipientId = _context.Comments.Find(entity.CommentId)?.UserId; if (recipientId != null) { var setting = _context.UserNotificationSettings .Where(x => x.UserId == recipientId) .FirstOrDefault() .CommentLikes; if (setting) { if (entity.UserId != recipientId) { var command = new CreateNotificationCommand { UserId = entity.UserId, RecipientId = recipientId.Value, NotificationType = NotificationType.CommentLike }; await _mediator.Send(command); } } } } return(Unit.Value); }