Exemplo n.º 1
0
        private static async void GetDetailsAndAddToDatabase(ProvidersSummary providersSummary, SQLiteContext dbContext)
        {
            foreach (var item in providersSummary.providers.ToList())
            {
                var providerDetails = dbContext.ProviderDetails.FirstOrDefault(x => x.providerId == item.providerId);

                if (providerDetails == null)
                {
                    providerDetails = new ProviderDetail
                    {
                        providerId = item.providerId,
                        name       = item.providerName
                    };

                    dbContext.ProviderDetails.Add(providerDetails);
                }
            }

            dbContext.SaveChanges();
        }
Exemplo n.º 2
0
        private async Task GetDetailsAndAddToDatabase(ProvidersSummary providersSummary)
        {
            try
            {
                _logger.LogInformation($"Page: {providersSummary.page} of {providersSummary.totalPages}");

                using (var db = new SQLiteContext())
                {
                    foreach (var item in providersSummary.providers.ToList())
                    {
                        var providerDetails = db.ProviderDetails.FirstOrDefault(x => x.providerId == item.providerId);

                        if (providerDetails == null)
                        {
                            _logger.LogInformation($"No details found for {item.providerName}. Adding to database.");

                            providerDetails = new ProviderDetail
                            {
                                providerId = item.providerId,
                                name       = item.providerName
                            };

                            await db.ProviderDetails.AddAsync(providerDetails);
                        }
                        else
                        {
                            _logger.LogInformation($"Existing details found for {item.providerName}. Skipping.");
                        }
                    }

                    await db.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Error occurred while updating provider summary data for page {providersSummary.page}");
            }
        }
Exemplo n.º 3
0
        public async Task <IActionResult> OnGetAsync()
        {
            ProvidersSummary = await _providerSummaryServices.GetProviderSummary(string.Empty);

            return(Page());
        }