Example #1
0
 private static int GenderTypeMapper(IDataReader reader, ProviderDetail providerDetail, int startingIndex)
 {
     providerDetail.GenderType      = new GenderType();
     providerDetail.GenderType.Id   = reader.GetSafeInt32(startingIndex++);
     providerDetail.GenderType.Name = reader.GetSafeString(startingIndex++);
     return(startingIndex);
 }
        public static Provider ToProvider(this ProviderDetail providerDetail)
        {
            try
            {
                int id = int.TryParse(providerDetail.ProviderID, out id) ? id : 0;

                IAddress address = providerDetail.ProviderAddress.ToAddess();

                Provider provider = new Provider(id, providerDetail.ProviderName, address);
                provider.UKPRN                                   = providerDetail.UKPRN;
                provider.UPIN                                    = providerDetail.UPIN;
                provider.TFPlusLoans                             = providerDetail.TFPlusLoans;
                provider.TFPlusLoansSpecified                    = providerDetail.TFPlusLoansSpecified;
                provider.DFE1619Funded                           = providerDetail.DFE1619Funded;
                provider.DFE1619FundedSpecified                  = providerDetail.DFE1619FundedSpecified;
                provider.FEChoices_LearnerDestination            = providerDetail.FEChoices_LearnerDestination;
                provider.FEChoices_LearnerDestinationSpecified   = providerDetail.FEChoices_LearnerDestinationSpecified;
                provider.FEChoices_LearnerSatisfaction           = providerDetail.FEChoices_LearnerSatisfaction;
                provider.FEChoices_LearnerSatisfactionSpecified  = providerDetail.FEChoices_LearnerSatisfactionSpecified;
                provider.FEChoices_EmployerSatisfaction          = providerDetail.FEChoices_EmployerSatisfaction;
                provider.FEChoices_EmployerSatisfactionSpecified = providerDetail.FEChoices_EmployerSatisfactionSpecified;
                provider.Website                                 = Uri.IsWellFormedUriString(providerDetail.Website, UriKind.Absolute) ? providerDetail.Website: string.Empty;
                provider.Email                                   = providerDetail.Email;
                provider.Phone                                   = providerDetail.Phone;
                provider.UKPRN                                   = providerDetail.Fax;
                provider.UKPRN                                   = providerDetail.UKPRN;


                return(provider);
            }
            catch
            {
                return(new Provider(1, "test"));
            }
        }
        // GET api/providers
        public HttpResponseMessage Get(int?min_discharges = null, int?max_discharges = null, decimal?max_average_covered_charges = null,
                                       decimal?min_average_covered_charges   = null, decimal?min_average_medicare_payments = null,
                                       decimal?max_average_medicare_payments = null, string state = null)
        {
            ProviderDetail objProviderDetail = new ProviderDetail();

            // Load Search criteria based on input query string parameters
            SearchCriteria criteria = new SearchCriteria();

            if (min_discharges.HasValue)
            {
                criteria.min_discharges = min_discharges.Value;
            }

            if (max_discharges.HasValue)
            {
                criteria.max_discharges = max_discharges.Value;
            }

            if (min_average_covered_charges.HasValue)
            {
                criteria.min_average_covered_charges = min_average_covered_charges.Value;
            }

            if (max_average_covered_charges.HasValue)
            {
                criteria.max_average_covered_charges = max_average_covered_charges.Value;
            }

            if (min_average_medicare_payments.HasValue)
            {
                criteria.min_average_medicare_payments = min_average_medicare_payments.Value;
            }

            if (max_average_medicare_payments.HasValue)
            {
                criteria.max_average_medicare_payments = max_average_medicare_payments.Value;
            }

            if (!string.IsNullOrWhiteSpace(state))
            {
                criteria.state = state;
            }

            string result = objProviderDetail.GetFilteredProviderData(criteria);

            if (!string.IsNullOrWhiteSpace(result))
            {
                // Create response object
                var response = Request.CreateResponse(HttpStatusCode.OK);

                // Call Data layer method to return filtered provider Data
                response.Content = new StringContent(result, Encoding.UTF8, "application/json");
                return(response);
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.NoContent));
            }
        }
        /// <summary>
        /// Populates a ProviderDetail object with values from a Provider entity.
        /// </summary>
        /// <param name="provider">Provider entity.</param>
        /// <returns>Populated ProviderDetail object.</returns>
        private static ProviderDetail BuildProviderDetail(Provider provider)
        {
            ProviderDetail providerDetail = new ProviderDetail
            {
                ProviderID      = provider.ProviderId,
                ProviderName    = provider.ProviderName,
                ProviderAddress = new AddressType
                {
                    Address_line_1 = provider.AddressLine1,
                    Address_line_2 = provider.AddressLine2,
                    Town           = provider.Town,
                    County         = provider.County,
                    PostCode       = provider.Postcode
                },
                Phone                  = provider.Phone,
                Email                  = provider.Email,
                Fax                    = provider.Fax,
                Website                = provider.Website,
                UKPRN                  = provider.Ukprn,
                UPIN                   = provider.Upin,
                TFPlusLoans            = provider.TFPlusLoans,
                TFPlusLoansSpecified   = true,
                DFE1619Funded          = provider.DFE1619Funded,
                DFE1619FundedSpecified = true
            };

            return(providerDetail);
        }
Example #5
0
 private static int ProviderDetailMapper(IDataReader reader, ProviderDetail providerDetail, int startingIndex)
 {
     providerDetail.Id       = reader.GetSafeInt32(startingIndex++);
     providerDetail.Phone    = reader.GetSafeString(startingIndex++);
     providerDetail.Fax      = reader.GetSafeString(startingIndex++);
     providerDetail.Networks = reader.GetSafeString(startingIndex++);
     return(startingIndex);
 }
        public void ShouldNotShowAnyNavigationDetailsIfOnlyOnePage()
        {
            var providerDetails = new ProviderDetail();
            var model           = GetProvider();
            var html            = providerDetails.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, "#previous-nav").Should().Be(string.Empty);
            GetPartial(html, "#next-nav").Should().Be(string.Empty);
        }
        public void ShouldShowNoTradingNamesFieldIfNoTradingNames()
        {
            var providerDetails = new ProviderDetail();
            var model           = GetProvider();

            model.TradingNames = string.Empty;
            var html = providerDetails.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, "#trading-names").Should().Be(string.Empty);
        }
        public void ShouldShowNoNationalFieldIfNationalIsFalse()
        {
            var providerDetails = new ProviderDetail();
            var model           = GetProvider();

            model.NationalProvider = false;
            var html = providerDetails.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, ".tag-national").Should().Be(string.Empty);
        }
Example #9
0
 private static int ProfessionalDetailMapper(IDataReader reader, ProviderDetail providerDetail, int startingIndex)
 {
     providerDetail.ProfessionalDetail                     = new ProfessionalDetail();
     providerDetail.ProfessionalDetail.Id                  = reader.GetSafeInt32(startingIndex++);
     providerDetail.ProfessionalDetail.NPI                 = reader.GetSafeString(startingIndex++);
     providerDetail.ProfessionalDetail.GenderAccepted      = new GenderType();
     providerDetail.ProfessionalDetail.GenderAccepted.Id   = reader.GetSafeInt32(startingIndex++);
     providerDetail.ProfessionalDetail.GenderAccepted.Name = reader.GetSafeString(startingIndex++);
     providerDetail.ProfessionalDetail.IsAccepting         = reader.GetSafeBool(startingIndex++);
     return(startingIndex);
 }
        public void ShouldShowLearnerSatisfactionIf0()
        {
            var providerDetails = new ProviderDetail();
            var model           = GetProvider();

            model.LearnerSatisfaction        = NoSatisfactionScore;
            model.LearnerSatisfactionMessage = NoSatisfactionScoreMessage;
            var html = providerDetails.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, "#learner-satisfaction").Should().Be(NoSatisfactionScoreMessage);
        }
        public void ShouldShowEmployerSatisfactionIfNot0()
        {
            var providerDetails = new ProviderDetail();
            var model           = GetProvider();

            model.EmployerSatisfaction        = SatisfactionScore;
            model.EmployerSatisfactionMessage = SatisfactionScoreMessage;
            var html = providerDetails.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, "#employer-satisfaction").Should().Contain(SatisfactionScoreMessage);
        }
Example #12
0
 private static int UserProfileMapper(IDataReader reader, ProviderDetail providerDetail, int startingIndex)
 {
     providerDetail.UserProfile           = new UserProfile();
     providerDetail.UserProfile.Id        = reader.GetSafeInt32(startingIndex++);
     providerDetail.UserProfile.UserId    = reader.GetSafeInt32(startingIndex++);
     providerDetail.UserProfile.FirstName = reader.GetSafeString(startingIndex++);
     providerDetail.UserProfile.LastName  = reader.GetSafeString(startingIndex++);
     providerDetail.UserProfile.Mi        = reader.GetSafeString(startingIndex++);
     providerDetail.UserProfile.AvatarUrl = reader.GetSafeString(startingIndex++);
     return(startingIndex);
 }
        public void GetFilteredProviderData_ResultNull_Test()
        {
            ProviderDetail objProviderDetail = new ProviderDetail();
            SearchCriteria criteria          = new SearchCriteria();

            criteria.min_discharges = 21;
            criteria.max_discharges = 20;
            string result = objProviderDetail.GetFilteredProviderData(criteria);

            // Above criteria should return null as max discharges is less than min discharges
            Assert.IsTrue(string.IsNullOrWhiteSpace(result));
        }
        public void ShouldShowAboutThisProviderIfNoTradingNamesIsSet()
        {
            var providerDetails = new ProviderDetail();
            var model           = GetProvider();

            model.TradingNames             = string.Empty;
            model.DisplayAboutThisProvider = true;

            var html = providerDetails.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, "#about-this-provider").Should().Contain("About this provider");
        }
        public void ShouldNotShowSourceIfNoSatisfactionScores()
        {
            var providerDetails = new ProviderDetail();
            var model           = GetProvider();

            model.LearnerSatisfaction        = NoSatisfactionScore;
            model.LearnerSatisfactionMessage = NoSatisfactionScoreMessage;

            var html = providerDetails.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, ".satisfaction-source").Should().Be(string.Empty);
        }
Example #16
0
        private static ProviderDetail MapProviderDetails(IDataReader reader)
        {
            ProviderDetail providerDetail = new ProviderDetail();

            int startingIndex = 0;

            startingIndex = ProviderDetailMapper(reader, providerDetail, startingIndex);
            startingIndex = ProfessionalDetailMapper(reader, providerDetail, startingIndex);
            startingIndex = TitleTypeMapper(reader, providerDetail, startingIndex);
            startingIndex = UserProfileMapper(reader, providerDetail, startingIndex);
            startingIndex = GenderTypeMapper(reader, providerDetail, startingIndex);

            return(providerDetail);
        }
        public void ShouldShowIsLevyPayerOnlyMessageIfSet()
        {
            var providerDetails = new ProviderDetail();
            var model           = GetProvider();

            model.HasParentCompanyGuarantee = false;
            model.IsLevyPayerOnly           = true;
            model.IsNew = false;

            var html = providerDetails.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, "#parent-company-guarantee").Should().Be(string.Empty);
            GetPartial(html, "#is-new-provider").Should().Be(string.Empty);
        }
Example #18
0
        private static void MapProviderDetails(IDataReader reader, ref List <ProviderDetail> providerDetailsList, ref int startingIndex)
        {
            ProviderDetail providerDetail = new ProviderDetail();

            startingIndex = ProviderDetailMapper(reader, providerDetail, startingIndex);
            startingIndex = ProfessionalDetailMapper(reader, providerDetail, startingIndex);
            startingIndex = TitleTypeMapper(reader, providerDetail, startingIndex);
            startingIndex = UserProfileMapper(reader, providerDetail, startingIndex);
            startingIndex = GenderTypeMapper(reader, providerDetail, startingIndex);

            if (providerDetailsList == null)
            {
                providerDetailsList = new List <ProviderDetail>();
            }

            providerDetailsList.Add(providerDetail);
        }
        public void GetFilteredProviderData_ResultNotNull_Test()
        {
            ProviderDetail objProviderDetail = new ProviderDetail();
            SearchCriteria criteria          = new SearchCriteria();

            criteria.min_discharges = 14;
            criteria.max_discharges = 20;
            criteria.min_average_covered_charges   = 8000;
            criteria.max_average_covered_charges   = 8600;
            criteria.min_average_medicare_payments = 4000;
            criteria.max_average_medicare_payments = 5000;
            criteria.state = "AL";
            string result = objProviderDetail.GetFilteredProviderData(criteria);

            // Above criteria should return records
            Assert.IsTrue(!string.IsNullOrWhiteSpace(result));
        }
        public void ShouldShowOnlyNextNavigationDetailsIfMoreThanOnePageAndOnFirstPage()
        {
            var providerDetails = new ProviderDetail();
            var model           = GetProvider();

            model.ApprenticeshipTrainingSummary.PaginationDetails
                = new PaginationDetails
                {
                LastPage = 2,
                NumberOfRecordsToSkip = 0,
                NumberPerPage         = 20,
                TotalCount            = 1,
                Page = 1
                };

            var html = providerDetails.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, "#previous-nav").Should().Be(string.Empty);
            GetPartial(html, "#next-nav").Should().Contain("2 of 2");
        }
        public void ShouldShowFieldsAsExpected()
        {
            var providerDetails = new ProviderDetail();
            var model           = GetProvider();

            var html = providerDetails.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, "#provider-name").Should().Contain(ProviderName);
            GetPartial(html, ".tag-national").Should().Contain("National");
            GetPartial(html, "#trading-names").Should().Contain(TradingNames);
            GetPartial(html, ".data-list--provider").Should().Contain(UkPrn.ToString());

            GetPartial(html, ".apprenticeshipContact").Should().Contain(ProviderName + " website");
            GetAttribute(html, ".apprenticeshipContact", "href").Should().Be(Website, "because http be added if missing");
            GetPartial(html, ".phone").Should().Contain(model.Phone);
            GetPartial(html, ".email").Should().Contain(model.Email);
            GetPartial(html, "#employer-satisfaction").Should().Be(NoSatisfactionScoreMessage);
            GetPartial(html, "#learner-satisfaction").Should().Contain(SatisfactionScoreMessage);
            GetPartial(html, ".satisfaction-source").Should().Contain("Source:");
        }
        public void ShouldShowOnlyPreviousNavigationDetailsIfLastPage()
        {
            var providerDetails = new ProviderDetail();
            var model           = GetProvider();

            model.ApprenticeshipTrainingSummary.PaginationDetails
                = new PaginationDetails
                {
                LastPage = 4,
                NumberOfRecordsToSkip = 60,
                NumberPerPage         = 20,
                TotalCount            = 69,
                Page = 4
                };

            var html = providerDetails.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, "#previous-nav").Should().Contain("3 of 4");
            GetPartial(html, "#next-nav").Should().Be(string.Empty);
        }
Example #23
0
        private static async void UpdateIndividualDetails(ProviderDetail detail, ProviderDetail apiDetail, SQLiteContext dbContext)
        {
            detail.locationIdsAsAString = string.Join(", ", apiDetail.locationIds);
            // detail.organisationType = apiDetail.organisationType;
            // detail.name = apiDetail.name;
            // detail.alsoKnownAs = apiDetail.alsoKnownAs;
            // detail.registrationStatus = apiDetail.registrationStatus;
            detail.registrationDate = apiDetail.registrationDate;
            // detail.website = apiDetail.website;
            // detail.postalAddressLine1 = apiDetail.postalAddressLine1;
            // detail.postalAddressLine2 = apiDetail.postalAddressLine2;
            // detail.postalAddressTownCity = apiDetail.postalAddressTownCity;
            // detail.postalAddressCounty = apiDetail.postalAddressCounty;
            // detail.region = apiDetail.region;
            // detail.postalCode = apiDetail.postalCode;
            // detail.mainPhoneNumber = apiDetail.mainPhoneNumber;

            dbContext.ProviderDetails.Update(detail);
            dbContext.SaveChanges();
        }
Example #24
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();
        }
Example #25
0
 private static ProviderDetails GetProviderDetailsData(ProviderDetail provider)
 {
     return(new ProviderDetails
     {
         EmailAddress = provider.Email,
         Website = provider.Website,
         AddressLine = provider.ProviderAddress.Address_line_1,
         AddressLine2 = provider.ProviderAddress.Address_line_2,
         Town = provider.ProviderAddress.Town,
         County = provider.ProviderAddress.County,
         PostCode = provider.ProviderAddress.PostCode,
         Longitude = provider.ProviderAddress.Longitude,
         Latitude = provider.ProviderAddress.Latitude,
         PhoneNumber = provider.Phone,
         Name = provider.ProviderName,
         LearnerSatisfactionSpecified = provider.FEChoices_LearnerSatisfactionSpecified,
         EmployerSatisfactionSpecified = provider.FEChoices_EmployerSatisfactionSpecified,
         LearnerSatisfaction = provider.FEChoices_LearnerSatisfaction,
         EmployerSatisfaction = provider.FEChoices_EmployerSatisfaction
     });
 }
Example #26
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}");
            }
        }
Example #27
0
        private static void MapProviders(IDataReader reader, out ProviderDetail providerDetail, out int startingIndex)
        {
            providerDetail = new ProviderDetail();
            startingIndex  = 0;
            startingIndex  = ProviderDetailMapper(reader, providerDetail, startingIndex);
            startingIndex  = ProfessionalDetailMapper(reader, providerDetail, startingIndex);
            startingIndex  = TitleTypeMapper(reader, providerDetail, startingIndex);
            startingIndex  = UserProfileMapper(reader, providerDetail, startingIndex);
            startingIndex  = GenderTypeMapper(reader, providerDetail, startingIndex);

            string affiliationsString = reader.GetSafeString(startingIndex++);

            if (!string.IsNullOrEmpty(affiliationsString))
            {
                providerDetail.Affiliations = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Affiliation> >(affiliationsString);
            }

            string languagesString = reader.GetSafeString(startingIndex++);

            if (!string.IsNullOrEmpty(languagesString))
            {
                providerDetail.Languages = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Language> >(languagesString);
            }

            string licensesString = reader.GetSafeString(startingIndex++);

            if (!string.IsNullOrEmpty(licensesString))
            {
                providerDetail.Licenses = Newtonsoft.Json.JsonConvert.DeserializeObject <List <License> >(licensesString);
            }

            string providerSpecializationsString = reader.GetSafeString(startingIndex++);

            if (!string.IsNullOrEmpty(providerSpecializationsString))
            {
                providerDetail.ProviderSpecializations = Newtonsoft.Json.JsonConvert.DeserializeObject <List <ProviderSpecialization> >(providerSpecializationsString);
            }
        }
Example #28
0
        private async Task UpdateIndividualDetails(ProviderDetail detail, ProviderDetail apiDetail, SQLiteContext db, bool saveRecordsToDatabase)
        {
            var recordUpdated = false;

            if (detail.locationIds != apiDetail.locationIds)
            {
                detail.locationIds = apiDetail.locationIds;
                recordUpdated      = true;
            }

            if (detail.organisationType != apiDetail.organisationType)
            {
                detail.organisationType = apiDetail.organisationType;
                recordUpdated           = true;
            }

            if (detail.name != apiDetail.name)
            {
                detail.name   = apiDetail.name;
                recordUpdated = true;
            }

            if (detail.alsoKnownAs != apiDetail.alsoKnownAs)
            {
                detail.alsoKnownAs = apiDetail.alsoKnownAs;
                recordUpdated      = true;
            }

            if (detail.registrationStatus != apiDetail.registrationStatus)
            {
                detail.registrationStatus = apiDetail.registrationStatus;
                recordUpdated             = true;
            }

            if (detail.registrationDate != apiDetail.registrationDate)
            {
                detail.registrationDate = apiDetail.registrationDate;
                recordUpdated           = true;
            }

            if (detail.website != apiDetail.website)
            {
                detail.website = apiDetail.website;
                recordUpdated  = true;
            }

            if (detail.postalAddressLine1 != apiDetail.postalAddressLine1)
            {
                detail.postalAddressLine1 = apiDetail.postalAddressLine1;
                recordUpdated             = true;
            }

            if (detail.postalAddressLine2 != apiDetail.postalAddressLine2)
            {
                detail.postalAddressLine2 = apiDetail.postalAddressLine2;
                recordUpdated             = true;
            }

            if (detail.postalAddressTownCity != apiDetail.postalAddressTownCity)
            {
                detail.postalAddressTownCity = apiDetail.postalAddressTownCity;
                recordUpdated = true;
            }

            if (detail.postalAddressCounty != apiDetail.postalAddressCounty)
            {
                detail.postalAddressCounty = apiDetail.postalAddressCounty;
                recordUpdated = true;
            }

            if (detail.region != apiDetail.region)
            {
                detail.region = apiDetail.region;
                recordUpdated = true;
            }

            if (detail.postalCode != apiDetail.postalCode)
            {
                detail.postalCode = apiDetail.postalCode;
                recordUpdated     = true;
            }

            if (detail.mainPhoneNumber != apiDetail.mainPhoneNumber)
            {
                detail.mainPhoneNumber = apiDetail.mainPhoneNumber;
                recordUpdated          = true;
            }

            if (recordUpdated)
            {
                _logger.LogInformation($"Differences found. Updating record for Provider: {detail.name} - Id: {detail.providerId}.");
                db.ProviderDetails.Update(detail);
            }
            else
            {
                _logger.LogInformation($"No differences found for record for Provider: {detail.name} - Id: {detail.providerId}.");
            }

            if (saveRecordsToDatabase)
            {
                _logger.LogInformation($"Saving batched changes to database.");
                await db.SaveChangesAsync();
            }
        }