public async Task <IActionResult> UnlikeImagePost(int imagePostId) { _logger.LogInformation("Received image post unlike request."); _logger.LogInformation("Image post id: {0}", imagePostId); User currentUser = _currentUserService.GetCurrentUser(HttpContext); _logger.LogInformation("Requesting user email: {0}", currentUser.Email); if (!await _likeService.UnlikeImagePost(imagePostId, currentUser.Email)) { _logger.LogError("Failed to delete like by '{0}' on image post with id '{1}'.", currentUser.Email, imagePostId); return(BadRequest()); } // Publish event. _logger.LogInformation("Publishing unlike notification."); UnlikeResponse unlikeResponse = new UnlikeResponse() { ImagePostId = imagePostId, UserEmail = currentUser.Email, Username = currentUser.Username }; await _notificationService.Publish(new UnlikeNotification(unlikeResponse)); _logger.LogInformation("Successfully deleted like by '{0}' on image post with id {1}.", currentUser.Email, imagePostId); return(NoContent()); }
public UnlikeNotification(UnlikeResponse unlikeResponse) { UnlikeResponse = unlikeResponse; }