Exemple #1
0
        private async Task <IList <Merchant> > ProcessMerchantFileAsync(MemoryStream memoryStream)
        {
            IList <Merchant>      lstImportedMerchants  = null;
            MerchantFileProcessor merchantFileProcessor = MerchantProcessorFactory.GetMerchantFileProcessor(merchantFileName);

            lstImportedMerchants = await Task.Run(() => merchantFileProcessor.ImportVisaMidFile(memoryStream)).ConfigureAwait(false);

            if (lstImportedMerchants == null || !lstImportedMerchants.Any())
            {
                throw new Exception($"Error in processing the visa mid file.");
            }
            Log.Info($"Total unique records imported from the visa mid file is {lstImportedMerchants.Count}");

            Log.Info($"Getting all merchants for provider {provider.Id} from db");
            merchantsInDb = await EarnRepository.Instance.GetMerchantsForProviderAsync(provider.Id).ConfigureAwait(false);

            Log.Info($"Got {merchantsInDb.Count()} merchant entries for provider {provider.Id} from db");

            IList <Merchant> lstMerchants = await Task.Run(() => UpdateVisaPayment(lstImportedMerchants)).ConfigureAwait(false);

            return(lstMerchants);
        }