Beispiel #1
0
 public async Task HandleAsync(DeleteFavoriteRemark command)
 {
     await _handler
     .Run(async() => await _remarkService.DeleteFavoriteRemarkAsync(command.RemarkId, command.UserId))
     .OnSuccess(async() => await _bus.PublishAsync(new FavoriteRemarkDeleted(command.Request.Id,
                                                                             command.UserId, command.RemarkId)))
     .OnCustomError(ex => _bus.PublishAsync(new DeleteFavoriteRemarkRejected(command.Request.Id,
                                                                             command.RemarkId, command.UserId, ex.Code, ex.Message)))
     .OnError(async(ex, logger) =>
     {
         logger.Error(ex, $"Error occured while deleting a favorite remark: '{command.RemarkId}' by user: '******'.");
         await _bus.PublishAsync(new DeleteFavoriteRemarkRejected(command.Request.Id,
                                                                  command.RemarkId, command.UserId, OperationCodes.Error, ex.Message));
     })
     .ExecuteAsync();
 }