예제 #1
0
        private static Venue GetVenueData(VenueDetail[] venue, OpportunityDetail activeOpportunity)
        {
            var venueData = venue?.Where(v => v.VenueID == activeOpportunity?.Items[0]).FirstOrDefault();

            return(venueData is null
                ? null
                : new Venue
            {
                Location = new Address
                {
                    AddressLine1 = venueData.VenueAddress?.Address_line_1,
                    AddressLine2 = venueData.VenueAddress?.Address_line_2,
                    County = venueData.VenueAddress?.County,
                    Town = venueData.VenueAddress?.Town,
                    Postcode = venueData.VenueAddress?.PostCode,
                    Longitude = venueData.VenueAddress?.Longitude,
                    Latitude = venueData.VenueAddress?.Latitude,
                },
                EmailAddress = venueData.Email,
                PhoneNumber = venueData.Phone,
                Website = venueData.Website,
                VenueName = venueData.VenueName,
                Fax = venueData.Fax,
                Facilities = venueData.Facilities
            });
        }
        public static Opportunity ToOpportunity(this OpportunityDetail opportunityDetail)
        {
            int id = int.TryParse(opportunityDetail.OpportunityId, out id) ? id : 0;

            Venue  venue  = null;
            string region = null;


            try
            {
                if (null != opportunityDetail.Items && null != opportunityDetail.Items[0] &&
                    null != opportunityDetail.ItemsElementName &&
                    opportunityDetail.ItemsElementName[0] != ItemsChoiceType.VenueID)
                {
                    region = opportunityDetail.Items[0].ToString();
                }
            }
            catch (InvalidCastException)
            {
                // Unbale to cast to a Venue or a Region
            }

            return(new Opportunity(
                       id,
                       opportunityDetail.StudyMode.ToStudyMode(),
                       opportunityDetail.AttendanceMode.ToAttendanceMode(),
                       opportunityDetail.AttendancePattern.ToAttendancePattern(),
                       false, //NOT Set in oppinfo
                       opportunityDetail.StartDate.ToDescriptionDate(),
                       venue,
                       region,
                       opportunityDetail.Duration.ToDuration(),
                       //OppDetails
                       opportunityDetail.Price,
                       opportunityDetail.PriceDesc,
                       opportunityDetail.EndDate,
                       opportunityDetail.Timetable,
                       opportunityDetail.LanguageOfAssessment,
                       opportunityDetail.LanguageOfInstruction,
                       opportunityDetail.PlacesAvailable,
                       opportunityDetail.EnquireTo,
                       opportunityDetail.ApplyTo,
                       opportunityDetail.ApplyFromDate,
                       opportunityDetail.ApplyUntilDate,
                       opportunityDetail.ApplyUntilDesc,
                       opportunityDetail.URL,
                       opportunityDetail.A10,
                       opportunityDetail.Items,
                       opportunityDetail.ItemsElementName.ToItemsChoice(),
                       opportunityDetail.ApplicationAcceptedThroughoutYear.ToAppAcceptedThroughout(),
                       opportunityDetail.ApplicationAcceptedThroughoutYearSpecified

                       ));
        }
예제 #3
0
        private static CourseDetails GetCourseDetailsData(CourseDetailStructure apiCourseDetail, OpportunityDetail activeOpportunity)
        {
            var venue = GetVenueData(apiCourseDetail?.Venue, activeOpportunity);

            return(apiCourseDetail?.Course is null ? null : new CourseDetails
            {
                Title = apiCourseDetail.Course.CourseTitle,
                Description = apiCourseDetail.Course.CourseSummary,
                EntryRequirements = apiCourseDetail.Course.EntryRequirements,
                AssessmentMethod = apiCourseDetail.Course.AssessmentMethod,
                EquipmentRequired = apiCourseDetail.Course.EquipmentRequired,
                QualificationName = apiCourseDetail.Course.QualificationTitle,
                QualificationLevel = apiCourseDetail.Course.QualificationLevel,
                VenueDetails = venue,
                ProviderDetails = GetProviderDetailsData(apiCourseDetail.Provider),
                Oppurtunities = GetOpportunities(apiCourseDetail, activeOpportunity?.OpportunityId),
                CourseLink = apiCourseDetail.Course.URL,
                CourseId = apiCourseDetail.Course.CourseID,
                Cost = activeOpportunity?.Price,
                StartDateLabel = activeOpportunity?.StartDate.Item,
                AttendanceMode = activeOpportunity?.AttendanceMode,
                AttendancePattern = activeOpportunity?.AttendancePattern,
                StudyMode = activeOpportunity?.StudyMode,
                Duration = $"{activeOpportunity?.Duration?.DurationValue} {activeOpportunity?.Duration?.DurationUnit}",
                AwardingOrganisation = apiCourseDetail.Course.AwardingBody,
                SubjectCategory = apiCourseDetail.Course.Level2EntitlementCategoryDesc,
                AdditionalPrice = activeOpportunity?.PriceDesc,
                SupportingFacilities = venue?.Facilities,
                AdvancedLearnerLoansOffered = apiCourseDetail.Provider?.TFPlusLoans == true,
                LanguageOfInstruction = activeOpportunity?.LanguageOfInstruction,
                CourseWebpageLink = activeOpportunity?.URL
            });
        }
        /// <summary>
        /// Build CourseDetailOutput object from collection of Courses and CourseDetailInput.
        /// </summary>
        /// <param name="courses">Courses collection.</param>
        /// <param name="courseDetailInput">Original CourseDetailInput.</param>
        /// <returns>Populated CourseDetailOutput object.</returns>
        private static CourseDetailOutput BuildCourseDetailOutput(List <Course> courses, CourseDetailInput courseDetailInput)
        {
            CourseDetailOutput           courseDetailOutput     = new CourseDetailOutput();
            List <CourseDetailStructure> courseDetailStructures = new List <CourseDetailStructure>();

            foreach (Course course in courses)
            {
                // Get Course detail
                CourseDetailStructure courseDetailStructure = new CourseDetailStructure();

                courseDetailStructure.Course = new CourseDetail();

                courseDetailStructure.Course.CourseID                = course.CourseId.ToString();
                courseDetailStructure.Course.CourseTitle             = course.CourseTitle;
                courseDetailStructure.Course.CourseSummary           = course.CourseSummary;
                courseDetailStructure.Course.NoOfOpps                = course.NumberOfOpportunities.ToString();
                courseDetailStructure.Course.QualificationLevel      = course.QualificationLevel;
                courseDetailStructure.Course.QualificationType       = course.QualificationType;
                courseDetailStructure.Course.AccreditationEndDate    = course.AccreditationEndDate;
                courseDetailStructure.Course.AccreditationStartDate  = course.AccreditationStartDate;
                courseDetailStructure.Course.AdultLRStatus           = GetAdultLRStatus(course.AdultLRStatus);
                courseDetailStructure.Course.AssessmentMethod        = course.AssessmentMethod;
                courseDetailStructure.Course.AwardingBody            = course.AwardingBody;
                courseDetailStructure.Course.BookingURL              = course.BookingUrl;
                courseDetailStructure.Course.CertificationEndDate    = course.CertificationEndDate;
                courseDetailStructure.Course.CreditValue             = course.CreditValue;
                courseDetailStructure.Course.DataType                = GetDataType(course.DataType);
                courseDetailStructure.Course.ERAppStatus             = GetERAppStatus(course.ERAppStatus);
                courseDetailStructure.Course.ERTTGStatus             = GetERTtgStatus(course.ERTtgStatus);
                courseDetailStructure.Course.EntryRequirements       = course.EntryRequirements;
                courseDetailStructure.Course.EquipmentRequired       = course.EquipmentRequired;
                courseDetailStructure.Course.IndependentLivingSkills =
                    GetIndependentLivingSkills(course.IndependentLivingSkills);
                courseDetailStructure.Course.LADID = course.LadId;
                courseDetailStructure.Course.Level2EntitlementCategoryDesc = course.Level2EntitlementDescription;
                courseDetailStructure.Course.Level3EntitlementCategoryDesc = course.Level3EntitlementDescription;
                courseDetailStructure.Course.OtherFundingNonFundedStatus   =
                    GetOtherFundingNonFundedStatus(course.OtherFundingNonFundedStatus);
                courseDetailStructure.Course.QCAGuidedLearningHours          = course.QcaGuidedLearningHours;
                courseDetailStructure.Course.QualificationReference          = course.QualificationReference;
                courseDetailStructure.Course.QualificationReferenceAuthority = course.QualificationReferenceAuthority;
                courseDetailStructure.Course.QualificationTitle    = course.QualificationTitle;
                courseDetailStructure.Course.SkillsForLifeFlag     = GetSkillsForLifeFlag(course.SkillsForLifeFlag);
                courseDetailStructure.Course.SkillsForLifeTypeDesc = course.SkillsForLifeTypeDescription;
                courseDetailStructure.Course.TariffRequired        = course.TariffRequired;
                courseDetailStructure.Course.URL = course.Url;

                courseDetailStructure.Course.LDCS          = new LDCSOutputType();
                courseDetailStructure.Course.LDCS.CatCode1 = BuildLdcsInfoType(course.LdcsCode1, course.LdcsDesc1);
                courseDetailStructure.Course.LDCS.CatCode2 = BuildLdcsInfoType(course.LdcsCode2, course.LdcsDesc2);
                courseDetailStructure.Course.LDCS.CatCode3 = BuildLdcsInfoType(course.LdcsCode3, course.LdcsDesc3);
                courseDetailStructure.Course.LDCS.CatCode4 = BuildLdcsInfoType(course.LdcsCode4, course.LdcsDesc4);
                courseDetailStructure.Course.LDCS.CatCode5 = BuildLdcsInfoType(course.LdcsCode5, course.LdcsDesc5);

                // Get Povider detail
                courseDetailStructure.Provider = new ProviderDetail();
                if (course.Provider != null)
                {
                    courseDetailStructure.Provider.ProviderID           = course.Provider.ProviderId;
                    courseDetailStructure.Provider.ProviderName         = course.Provider.ProviderName;
                    courseDetailStructure.Provider.Phone                = course.Provider.Phone;
                    courseDetailStructure.Provider.Fax                  = course.Provider.Fax;
                    courseDetailStructure.Provider.Email                = course.Provider.Email;
                    courseDetailStructure.Provider.Website              = course.Provider.Website;
                    courseDetailStructure.Provider.UKPRN                = course.Provider.Ukprn;
                    courseDetailStructure.Provider.UPIN                 = course.Provider.Upin;
                    courseDetailStructure.Provider.TFPlusLoans          = course.Provider.TFPlusLoans;
                    courseDetailStructure.Provider.TFPlusLoansSpecified = true;

                    if (course.Provider.FEChoices_EmployerSatisfaction.HasValue)
                    {
                        courseDetailStructure.Provider.FEChoices_EmployerSatisfaction = course.Provider.FEChoices_EmployerSatisfaction.Value;
                    }
                    courseDetailStructure.Provider.FEChoices_EmployerSatisfactionSpecified = course.Provider.FEChoices_EmployerSatisfaction.HasValue;
                    if (course.Provider.FEChoices_LearnerSatisfaction.HasValue)
                    {
                        courseDetailStructure.Provider.FEChoices_LearnerSatisfaction = course.Provider.FEChoices_LearnerSatisfaction.Value;
                    }
                    courseDetailStructure.Provider.FEChoices_LearnerSatisfactionSpecified = course.Provider.FEChoices_LearnerSatisfaction.HasValue;
                    if (course.Provider.FEChoices_LearnerDestination.HasValue)
                    {
                        courseDetailStructure.Provider.FEChoices_LearnerDestination = course.Provider.FEChoices_LearnerDestination.Value;
                    }
                    courseDetailStructure.Provider.FEChoices_LearnerDestinationSpecified = course.Provider.FEChoices_LearnerDestination.HasValue;

                    courseDetailStructure.Provider.ProviderAddress = BuildAddressType(course.Provider.AddressLine1,
                                                                                      course.Provider.AddressLine2, course.Provider.Town, course.Provider.County, course.Provider.Postcode);
                }

                // Get Opportunity detail
                List <OpportunityDetail> opportunityDetails = new List <OpportunityDetail>();
                foreach (Opportunity opportunity in course.Opportunities)
                {
                    OpportunityDetail opportunityDetail = new OpportunityDetail();

                    opportunityDetail.AttendanceMode    = opportunity.AttendanceMode;
                    opportunityDetail.AttendancePattern = opportunity.AttendancePattern;

                    opportunityDetail.Duration = new DurationType();
                    opportunityDetail.Duration.DurationDescription = opportunity.DurationDescription;
                    opportunityDetail.Duration.DurationUnit        = opportunity.DurationUnit;

                    if (opportunity.DurationValue != 0)
                    {
                        opportunityDetail.Duration.DurationValue = opportunity.DurationValue.ToString();
                    }

                    opportunityDetail.Price     = opportunity.Price;
                    opportunityDetail.PriceDesc = opportunity.PriceDescription;
                    opportunityDetail.StudyMode = opportunity.StudyMode;
                    opportunityDetail.Timetable = opportunity.Timetable;

                    opportunityDetail.StartDate = BuildStartDateType(opportunity);
                    //opportunityDetail.StartDate = new StartDateType();
                    //opportunityDetail.StartDate.ItemElementName = ItemChoiceType.Date;
                    //opportunityDetail.StartDate.Item = opportunity.StartDate;

                    //opportunityDetail.StartDate = new StartDateType();
                    //opportunityDetail.StartDate.ItemElementName = ItemChoiceType.DateDesc;
                    //opportunityDetail.StartDate.Item = opportunity.StartDateDescription;

                    opportunityDetail.ApplicationAcceptedThroughoutYear =
                        GetApplicationAcceptedThroughoutYear(opportunity.ApplicationAcceptedThroughoutYear);
                    opportunityDetail.ApplyFromDate         = opportunity.ApplyFromDate;
                    opportunityDetail.ApplyTo               = opportunity.ApplyTo;
                    opportunityDetail.ApplyUntilDate        = opportunity.ApplyUntilDate;
                    opportunityDetail.ApplyUntilDesc        = opportunity.ApplyUntilDescription;
                    opportunityDetail.EndDate               = opportunity.EndDate;
                    opportunityDetail.EnquireTo             = opportunity.EnquireTo;
                    opportunityDetail.LanguageOfAssessment  = opportunity.LanguageOfAssessment;
                    opportunityDetail.LanguageOfInstruction = opportunity.LanguageOfInstruction;
                    opportunityDetail.PlacesAvailable       = opportunity.PlacesAvailable.ToString();
                    opportunityDetail.ProviderOpportunityId = opportunity.ProviderOpportunityId;
                    opportunityDetail.URL = opportunity.Url;
                    opportunityDetail.A10 = opportunity.A10.ToArray();

                    List <String>          items     = new List <String>();
                    List <ItemsChoiceType> itemNames = new List <ItemsChoiceType>();

                    if (opportunity.VenueId != 0 && String.IsNullOrWhiteSpace(opportunity.RegionName))
                    {
                        items.Add(opportunity.VenueId.ToString());
                        itemNames.Add(ItemsChoiceType.VenueID);
                    }
                    if (!String.IsNullOrWhiteSpace(opportunity.RegionName))
                    {
                        items.Add(opportunity.RegionName);
                        itemNames.Add(ItemsChoiceType.RegionName);
                    }

                    opportunityDetail.Items            = items.ToArray();
                    opportunityDetail.ItemsElementName = itemNames.ToArray();

                    opportunityDetail.OpportunityId = opportunity.OpportunityId;

                    opportunityDetails.Add(opportunityDetail);
                }

                courseDetailStructure.Opportunity = opportunityDetails.ToArray();

                // Get Venue details
                List <VenueDetail> venueDetails = new List <VenueDetail>();

                foreach (Venue venue in course.Venues)
                {
                    VenueDetail venueDetail = new VenueDetail();

                    venueDetail.VenueID      = venue.VenueId.ToString();
                    venueDetail.VenueName    = venue.VenueName;
                    venueDetail.Phone        = venue.Phone;
                    venueDetail.Email        = venue.Email;
                    venueDetail.Facilities   = venue.Facilities;
                    venueDetail.Fax          = venue.Fax;
                    venueDetail.Website      = venue.Website;
                    venueDetail.VenueAddress =
                        BuildAddressType(venue.AddressLine1, venue.AddressLine2, venue.Town, venue.County, venue.Postcode, venue.Latitude, venue.Longitude);

                    venueDetails.Add(venueDetail);
                }

                courseDetailStructure.Venue = venueDetails.ToArray();

                courseDetailStructures.Add(courseDetailStructure);
            }

            courseDetailOutput.CourseDetails = courseDetailStructures.ToArray();

            // Get original Request details
            courseDetailOutput.RequestDetails = new CourseDetailRequestStructure
            {
                CourseID = courseDetailInput.CourseID,
                APIKey   = courseDetailInput.APIKey
            };

            return(courseDetailOutput);
        }