public virtual async Task RemoveByDeviceCodeAsync(string deviceCode) { Check.NotNull(deviceCode, nameof(deviceCode)); var deviceCodes = await DeviceFlowCodesRepository .FindByDeviceCodeAsync(deviceCode) ; if (deviceCodes == null) { return; } await DeviceFlowCodesRepository .DeleteAsync(deviceCodes, autoSave : true) ; }
protected virtual async Task RemoveDeviceCodesAsync() { for (int i = 0; i < Options.CleanupLoopCount; i++) { var deviceFlowCodeses = await DeviceFlowCodesRepository .GetListByExpirationAsync(Clock.Now, Options.CleanupBatchSize); //TODO: Can be optimized if the repository implements the batch deletion foreach (var deviceFlowCodes in deviceFlowCodeses) { await DeviceFlowCodesRepository .DeleteAsync(deviceFlowCodes); } //No need to continue to query if it gets more than max items. if (deviceFlowCodeses.Count < Options.CleanupBatchSize) { break; } } }