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