public static DescriptionDate ToDescriptionDate(this StartDateType startDateType)
        {
            DateTime?startDate = DateTime.TryParse(startDateType.Item, out DateTime dt) ? dt : default(DateTime?);

            if (startDate.HasValue && startDateType.ItemElementName == ItemChoiceType.Date)
            {
                return(new DescriptionDate(startDate.Value));
            }

            if (!string.IsNullOrWhiteSpace(startDateType.Item) && startDateType.ItemElementName == ItemChoiceType.DateDesc)
            {
                return(new DescriptionDate(startDateType.Item));
            }

            return(DescriptionDate.Default);
        }
        /// <summary>
        /// Build StartDateType object
        /// </summary>
        /// <param name="opportunity">Opportunity</param>
        /// <returns>StartDateType object created.</returns>
        private static StartDateType BuildStartDateType(Opportunity opportunity)
        {
            StartDateType startDateType = new StartDateType();

            if (opportunity.StartDate != null && !string.IsNullOrEmpty(opportunity.StartDate))
            {
                startDateType.ItemElementName = ItemChoiceType.Date;
                startDateType.Item            = opportunity.StartDate;
            }
            else
            {
                startDateType.ItemElementName = ItemChoiceType.DateDesc;
                startDateType.Item            = opportunity.StartDateDescription;
            }

            return(startDateType);
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ApplyPolicyRequestModel" /> class.
 /// </summary>
 /// <param name="policyId">policyId.</param>
 /// <param name="locationId">locationId.</param>
 /// <param name="folderUrl">folderUrl.</param>
 /// <param name="startDateType">startDateType.</param>
 /// <param name="isCheckLock">isCheckLock.</param>
 /// <param name="filter">filter.</param>
 /// <param name="selectedObjectsId">selectedObjectsId.</param>
 /// <param name="specifyDateTicks">specifyDateTicks.</param>
 /// <param name="isExportLocation">isExportLocation.</param>
 public ApplyPolicyRequestModel(Guid policyId = default(Guid), int locationId = default(int), string folderUrl = default(string), StartDateType startDateType = default(StartDateType), bool isCheckLock = default(bool), string filter = default(string), List <Guid> selectedObjectsId = default(List <Guid>), long specifyDateTicks = default(long), bool isExportLocation = default(bool))
 {
     this.PolicyId          = policyId;
     this.LocationId        = locationId;
     this.FolderUrl         = folderUrl;
     this.StartDateType     = startDateType;
     this.IsCheckLock       = isCheckLock;
     this.Filter            = filter;
     this.SelectedObjectsId = selectedObjectsId;
     this.SpecifyDateTicks  = specifyDateTicks;
     this.IsExportLocation  = isExportLocation;
 }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChangeGroupPolicyResult" /> class.
 /// </summary>
 /// <param name="currentPolicy">currentPolicy.</param>
 /// <param name="allPolicies">allPolicies.</param>
 /// <param name="changePolicyAssignBy">changePolicyAssignBy.</param>
 /// <param name="startDateType">startDateType.</param>
 /// <param name="serviceSpecifyDate">serviceSpecifyDate.</param>
 /// <param name="isEnableLeaseExpired">isEnableLeaseExpired.</param>
 /// <param name="leaseDuration">leaseDuration.</param>
 /// <param name="leaseDurationType">leaseDurationType.</param>
 /// <param name="currentStartDate">currentStartDate.</param>
 public ChangeGroupPolicyResult(GuidModel currentPolicy = default(GuidModel), List <GuidModel> allPolicies = default(List <GuidModel>), AssignBy changePolicyAssignBy = default(AssignBy), StartDateType startDateType = default(StartDateType), DateTime serviceSpecifyDate = default(DateTime), bool isEnableLeaseExpired = default(bool), int leaseDuration = default(int), ApiDurationType leaseDurationType = default(ApiDurationType), DateTime currentStartDate = default(DateTime))
 {
     this.CurrentPolicy        = currentPolicy;
     this.AllPolicies          = allPolicies;
     this.ChangePolicyAssignBy = changePolicyAssignBy;
     this.StartDateType        = startDateType;
     this.ServiceSpecifyDate   = serviceSpecifyDate;
     this.IsEnableLeaseExpired = isEnableLeaseExpired;
     this.LeaseDuration        = leaseDuration;
     this.LeaseDurationType    = leaseDurationType;
     this.CurrentStartDate     = currentStartDate;
 }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChangeGroupPolicyRequest" /> class.
 /// </summary>
 /// <param name="policy">policy.</param>
 /// <param name="isLeaseEnabled">isLeaseEnabled.</param>
 /// <param name="changePolicyConfig">changePolicyConfig.</param>
 /// <param name="startDateType">startDateType.</param>
 /// <param name="specifyStartDate">specifyStartDate.</param>
 /// <param name="groupId">groupId.</param>
 /// <param name="id">id.</param>
 /// <param name="serviceId">serviceId.</param>
 /// <param name="department">department.</param>
 /// <param name="summary">summary.</param>
 /// <param name="notesToApprovers">notesToApprovers.</param>
 /// <param name="questionnaireId">questionnaireId.</param>
 /// <param name="metadatas">metadatas.</param>
 public ChangeGroupPolicyRequest(GuidModel policy = default(GuidModel), bool isLeaseEnabled = default(bool), AssignBy changePolicyConfig = default(AssignBy), StartDateType startDateType = default(StartDateType), DateTime?specifyStartDate = default(DateTime?), Guid groupId = default(Guid), Guid?id = default(Guid?), Guid serviceId = default(Guid), string department = default(string), string summary = default(string), string notesToApprovers = default(string), Guid?questionnaireId = default(Guid?), List <RequestMetadata> metadatas = default(List <RequestMetadata>))
 {
     this.Policy           = policy;
     this.SpecifyStartDate = specifyStartDate;
     this.Id                 = id;
     this.Department         = department;
     this.Summary            = summary;
     this.NotesToApprovers   = notesToApprovers;
     this.QuestionnaireId    = questionnaireId;
     this.Metadatas          = metadatas;
     this.Policy             = policy;
     this.IsLeaseEnabled     = isLeaseEnabled;
     this.ChangePolicyConfig = changePolicyConfig;
     this.StartDateType      = startDateType;
     this.SpecifyStartDate   = specifyStartDate;
     this.GroupId            = groupId;
     this.Id                 = id;
     this.ServiceId          = serviceId;
     this.Department         = department;
     this.Summary            = summary;
     this.NotesToApprovers   = notesToApprovers;
     this.QuestionnaireId    = questionnaireId;
     this.Metadatas          = metadatas;
 }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AutoTaskChangePolicyRequest" /> class.
 /// </summary>
 /// <param name="action">action.</param>
 /// <param name="policy">policy.</param>
 /// <param name="startDateType">startDateType.</param>
 /// <param name="specifyStartDate">specifyStartDate.</param>
 /// <param name="taskId">taskId.</param>
 /// <param name="metadatas">metadatas.</param>
 /// <param name="comments">comments.</param>
 public AutoTaskChangePolicyRequest(LifecycleAction action = default(LifecycleAction), GuidModel policy = default(GuidModel), StartDateType startDateType = default(StartDateType), DateTime?specifyStartDate = default(DateTime?), Guid taskId = default(Guid), List <RequestMetadata> metadatas = default(List <RequestMetadata>), CommentsParam comments = default(CommentsParam))
 {
     this.Action           = action;
     this.Policy           = policy;
     this.StartDateType    = startDateType;
     this.SpecifyStartDate = specifyStartDate;
     this.TaskId           = taskId;
     this.Metadatas        = metadatas;
     this.Comments         = comments;
 }
        /// <summary>
        /// Build CourseListResponseStructure object from CourseListResponse data and original CourseListRequestStructure.
        /// </summary>
        /// <param name="response">CourseListResponse data.</param>
        /// <param name="request">Original CourseListRequestStructure.</param>
        /// <returns>Populated CourseListResponseStructure object.</returns>
        private static CourseListResponseStructure BuildCourseListResponseStructure(CourseListResponse response, CourseListRequestStructure request)
        {
            CourseListResponseStructure courseListResponse = new CourseListResponseStructure();

            // Create matching Ldcs collection
            List <CourseListResponseStructureMatchingLDCS> matchingLdcss =
                new List <CourseListResponseStructureMatchingLDCS>();

            foreach (LdcsCode ldcsCode in response.LdcsCodes)
            {
                CourseListResponseStructureMatchingLDCS matchingLdcs = new CourseListResponseStructureMatchingLDCS();
                matchingLdcs.LDCS   = BuildLdcsInfoType(ldcsCode.LdcsCodeValue, ldcsCode.LdcsCodeDescription);
                matchingLdcs.Counts = ldcsCode.CourseCount.ToString();

                matchingLdcss.Add(matchingLdcs);
            }

            courseListResponse.MatchingLDCS = matchingLdcss.ToArray();

            // Create CourseStructure collection
            List <CourseStructure> courseStructures = new List <CourseStructure>();

            foreach (Course course in response.Courses)
            {
                // Get Course information
                CourseStructure courseStructure = new CourseStructure();

                courseStructure.Course               = new CourseInfo();
                courseStructure.Course.CourseID      = course.CourseId.ToString();
                courseStructure.Course.CourseSummary = course.CourseSummary;
                courseStructure.Course.CourseTitle   = course.CourseTitle;

                courseStructure.Course.LDCS               = new LDCSOutputType();
                courseStructure.Course.LDCS.CatCode1      = BuildLdcsInfoType(course.LdcsCode1, course.LdcsDesc1);
                courseStructure.Course.LDCS.CatCode2      = BuildLdcsInfoType(course.LdcsCode2, course.LdcsDesc2);
                courseStructure.Course.LDCS.CatCode3      = BuildLdcsInfoType(course.LdcsCode3, course.LdcsDesc3);
                courseStructure.Course.LDCS.CatCode4      = BuildLdcsInfoType(course.LdcsCode4, course.LdcsDesc4);
                courseStructure.Course.LDCS.CatCode5      = BuildLdcsInfoType(course.LdcsCode5, course.LdcsDesc5);
                courseStructure.Course.NoOfOpps           = course.NumberOfOpportunities.ToString();
                courseStructure.Course.QualificationLevel = course.QualificationLevel;
                courseStructure.Course.QualificationType  = course.QualificationType;

                // Get Opportunity information
                List <OpportunityInfo> opportunityInfos = new List <OpportunityInfo>();

                foreach (Opportunity opportunity in course.Opportunities)
                {
                    OpportunityInfo opportunityInfo = new OpportunityInfo();

                    opportunityInfo.AttendanceMode    = opportunity.AttendanceMode;
                    opportunityInfo.AttendancePattern = opportunity.AttendancePattern;
                    opportunityInfo.OpportunityId     = opportunity.OpportunityId;

                    StartDateType startDateType = BuildStartDateType(opportunity);

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

                    // TODO: how do we add these in?  I suspect we need to change the contract.
                    //StartDateType startDateDescType = new StartDateType();
                    //startDateDescType.ItemElementName = ItemChoiceType.DateDesc;
                    //startDateDescType.Item = opportunity.StartDateDescription;

                    opportunityInfo.StartDate = startDateType;
                    opportunityInfo.Duration  = new DurationType();
                    opportunityInfo.Duration.DurationDescription = opportunity.DurationDescription;
                    opportunityInfo.Duration.DurationUnit        = opportunity.DurationUnit;

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

                    opportunityInfo.EndDate                = opportunity.EndDate;
                    opportunityInfo.StudyMode              = opportunity.StudyMode;
                    opportunityInfo.DFE1619Funded          = opportunity.DfE1619Funded;
                    opportunityInfo.DFE1619FundedSpecified = true;

                    if (opportunity.Venue != null && !string.IsNullOrEmpty(opportunity.Venue.VenueName))
                    {
                        VenueInfo venueInfo = new VenueInfo();
                        if (!string.IsNullOrEmpty(opportunity.Distance))
                        {
                            venueInfo.DistanceSpecified = true;
                            venueInfo.Distance          = float.Parse(opportunity.Distance);
                        }
                        venueInfo.VenueName    = opportunity.Venue.VenueName;
                        venueInfo.VenueAddress =
                            BuildAddressType(opportunity.Venue.AddressLine1, opportunity.Venue.AddressLine2,
                                             opportunity.Venue.Town, opportunity.Venue.County, opportunity.Venue.Postcode, opportunity.Venue.Latitude, opportunity.Venue.Longitude);

                        opportunityInfo.Item = venueInfo;
                    }
                    else
                    {
                        opportunityInfo.Item = opportunity.RegionName;
                    }

                    opportunityInfos.Add(opportunityInfo);
                }

                // pick out the first opportunity (expecting there to be only one looking at the java web service's design).
                // if there is more than one here - then current site cannot deal with it.
                courseStructure.Opportunity = opportunityInfos.ElementAt(0);

                courseStructure.Provider = new ProviderInfo();
                courseStructure.Provider.ProviderName           = course.Provider.ProviderName;
                courseStructure.Provider.TFPlusLoans            = course.Provider.TFPlusLoans;
                courseStructure.Provider.TFPlusLoansSpecified   = true;
                courseStructure.Provider.DFE1619Funded          = course.Provider.DFE1619Funded;
                courseStructure.Provider.DFE1619FundedSpecified = true;

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


                courseStructures.Add(courseStructure);
            }

            courseListResponse.CourseDetails = courseStructures.ToArray();

            // Get Result information, i.e. page number etc.
            courseListResponse.ResultInfo = new ResultInfoType();

            int requestRecordsPerPage = 0;

            if (!string.IsNullOrEmpty(request.RecordsPerPage))
            {
                requestRecordsPerPage = Int32.Parse(request.RecordsPerPage);
            }

            int responseRecordsPerPage = (requestRecordsPerPage > 0) ? requestRecordsPerPage : 50;
            int totalRecords           = response.NumberOfRecords;
            int numberOfPages          =
                (totalRecords / responseRecordsPerPage) + ((totalRecords % responseRecordsPerPage == 0) ? 0 : 1);

            int currentPage = 1;

            if (!string.IsNullOrEmpty(request.PageNo))
            {
                currentPage = Int32.Parse(request.PageNo);
            }

            courseListResponse.ResultInfo.NoOfRecords = response.NumberOfRecords.ToString();
            courseListResponse.ResultInfo.PageNo      = (currentPage > 0) ? currentPage.ToString() : "1";
            courseListResponse.ResultInfo.NoOfPages   = numberOfPages.ToString();

            // Get original Request details
            courseListResponse.RequestDetails = request;

            return(courseListResponse);
        }