public async Task HandleAsync(AddFavoriteRemark command) { await _handler .Run(async() => await _remarkService.AddFavoriteRemarkAsync(command.RemarkId, command.UserId)) .OnSuccess(async() => await _bus.PublishAsync(new FavoriteRemarkAdded(command.Request.Id, command.UserId, command.RemarkId))) .OnCustomError(ex => _bus.PublishAsync(new AddFavoriteRemarkRejected(command.Request.Id, command.RemarkId, command.UserId, ex.Code, ex.Message))) .OnError(async(ex, logger) => { logger.Error(ex, $"Error occured while adding a favorite remark: '{command.RemarkId}' by user: '******'."); await _bus.PublishAsync(new AddFavoriteRemarkRejected(command.Request.Id, command.RemarkId, command.UserId, OperationCodes.Error, ex.Message)); }) .ExecuteAsync(); }