コード例 #1
0
        private void UpdateCrmPartnerChildDetails(List <CRMPartner> crmPartners, Dictionary <int, PartnerChildDetails> dictionary)
        {
            foreach (var crmPartner in crmPartners)
            {
                crmPartner.PartnerCenterRoomInfo.Clear();
                crmPartner.PartnerCenterDescription.Clear();
                crmPartner.PartnerCoursePackage.Clear();
                crmPartner.PartnerCenterInfo.Clear();
                crmPartner.Pictures.Clear();

                PartnerChildDetails partnerChildDetails = new PartnerChildDetails();

                if (dictionary.TryGetValue(crmPartner.CRMPartnerId, out partnerChildDetails))
                {
                    crmPartner.PartnerCenterRoomInfo.AddRange(partnerChildDetails.PartnerCenterRoomInfo);
                    crmPartner.PartnerCenterDescription.AddRange(partnerChildDetails.PartnerCenterDescription);
                    crmPartner.PartnerCoursePackage.AddRange(partnerChildDetails.PartnerCoursePackage);
                    crmPartner.PartnerCenterInfo.AddRange(partnerChildDetails.PartnerCenterInfo);
                    crmPartner.Pictures.AddRange(partnerChildDetails.Pictures);
                }
            }
        }
コード例 #2
0
        private void UpdateCrmPartnerForApprovedStatusAndLastModifiedDate(List <CRMPartner> crmPartners, DateTime lastModifiedDate)
        {
            Dictionary <int, PartnerChildDetails> _dictionary = new Dictionary <int, PartnerChildDetails>();

            foreach (var crmPartner in crmPartners)
            {
                PartnerChildDetails partnerChildDetails = new PartnerChildDetails();

                foreach (var partnerCenterRoomInfo in crmPartner.PartnerCenterRoomInfo)
                {
                    if (_partnerCenterRoomInfoContentStatus(partnerCenterRoomInfo, 1) && _validatePartnerCenterRoomInfoLastModifiedDate(partnerCenterRoomInfo, lastModifiedDate))
                    {
                        partnerChildDetails.PartnerCenterRoomInfo.Add(partnerCenterRoomInfo);
                    }
                }

                foreach (var partnerCenterDescription in crmPartner.PartnerCenterDescription)
                {
                    if (_partnerCenterDescriptionContentStatus(partnerCenterDescription, 1) && _validatePartnerCenterDescriptionLastModifiedDate(partnerCenterDescription, lastModifiedDate))
                    {
                        partnerChildDetails.PartnerCenterDescription.Add(partnerCenterDescription);
                    }
                }

                foreach (var partnerCoursePackage in crmPartner.PartnerCoursePackage)
                {
                    if (_partnerCoursePackageContentStatus(partnerCoursePackage, 1) && _validatePartnerCoursePackageLastModifiedDate(partnerCoursePackage, lastModifiedDate))
                    {
                        partnerChildDetails.PartnerCoursePackage.Add(partnerCoursePackage);
                    }
                }

                foreach (var partnerCenterInfo in crmPartner.PartnerCenterInfo)
                {
                    if (_partnerCenterInfoContentStatus(partnerCenterInfo, 1) && _validatePartnerCenterInfoLastModifiedDate(partnerCenterInfo, lastModifiedDate))
                    {
                        partnerChildDetails.PartnerCenterInfo.Add(partnerCenterInfo);
                    }
                }

                foreach (var picture in crmPartner.Pictures)
                {
                    if (picture.LastModified != null && picture.LastModified > lastModifiedDate)
                    {
                        partnerChildDetails.Pictures.Add(picture);
                    }
                }

                if (crmPartner.PartnerInspirationCategoriesDK?.ContentStatusId == null ||
                    crmPartner.PartnerInspirationCategoriesDK?.ContentStatusId != 1 ||
                    crmPartner.PartnerInspirationCategoriesDK?.LastModified == null ||
                    crmPartner.PartnerInspirationCategoriesDK?.LastModified < lastModifiedDate)
                {
                    crmPartner.PartnerInspirationCategoriesDK = null;
                }

                if (crmPartner.PartnerInspirationCategoriesUK?.ContentStatusId == null ||
                    crmPartner.PartnerInspirationCategoriesUK?.ContentStatusId != 1 ||
                    crmPartner.PartnerInspirationCategoriesUK?.LastModified == null ||
                    crmPartner.PartnerInspirationCategoriesUK?.LastModified < lastModifiedDate)
                {
                    crmPartner.PartnerInspirationCategoriesUK = null;
                }

                _dictionary.Add(crmPartner.CRMPartnerId, partnerChildDetails);
            }

            UpdateCrmPartnerChildDetails(crmPartners, _dictionary);
        }
コード例 #3
0
        public List <CRMPartner> GetCrmPartnersBasedOnApprovalStatus()
        {
            var crmResults = DkbsContext.CRMPartner
                                                                       //.Include(x => x.Pictures)
                             .Include(x => x.PartnerCenterInfo)
                                                                       //.ThenInclude(x => x.ContentStatus)
                             .Include(x => x.PartnerCenterRoomInfo)
                             .Include(x => x.PartnerCenterDescription) //.ThenInclude(x => x.ContentStatus)
                             .Include(x => x.PartnerInspirationCategoriesDK)
                             .Include(x => x.PartnerInspirationCategoriesUK)
                             .Include(x => x.PartnerCoursePackage)
                             //.ThenInclude(x => x.CoursePackage).ThenInclude(x => x.PackageIncludedItems)
                             //.Include(x => x.PartnerCoursePackage)
                             //.ThenInclude(x => x.PartnerPackageIncludedItems)
                             //.Include(x => x.PartnerCoursePackage)
                             //.ThenInclude(x => x.PartnerPackageAdditionalItems)
                             //.Include(x => x.PartnerCoursePackage)
                             //.ThenInclude(x => x.PartnerPackageYears)
                             //.Include(x => x.PartnerCoursePackage)
                             //.ThenInclude(x => x.ContentStatus)
                             .ToList()
            ;


            Dictionary <int, PartnerChildDetails> _dictionary = new Dictionary <int, PartnerChildDetails>();

            foreach (var crmPartner in crmResults)
            {
                PartnerChildDetails partnerChildDetails = new PartnerChildDetails();

                foreach (var partnerCenterRoomInfo in crmPartner.PartnerCenterRoomInfo)
                {
                    if (_partnerCenterRoomInfoContentStatus(partnerCenterRoomInfo, 2))
                    {
                        partnerChildDetails.PartnerCenterRoomInfo.Add(partnerCenterRoomInfo);
                    }
                }

                foreach (var partnerCenterDescription in crmPartner.PartnerCenterDescription)
                {
                    if (_partnerCenterDescriptionContentStatus(partnerCenterDescription, 2))
                    {
                        partnerChildDetails.PartnerCenterDescription.Add(partnerCenterDescription);
                    }
                }

                foreach (var partnerCoursePackage in crmPartner.PartnerCoursePackage)
                {
                    if (_partnerCoursePackageContentStatus(partnerCoursePackage, 2))
                    {
                        partnerChildDetails.PartnerCoursePackage.Add(partnerCoursePackage);
                    }
                }

                foreach (var partnerCenterInfo in crmPartner.PartnerCenterInfo)
                {
                    if (_partnerCenterInfoContentStatus(partnerCenterInfo, 2))
                    {
                        partnerChildDetails.PartnerCenterInfo.Add(partnerCenterInfo);
                    }
                }

                if (crmPartner.PartnerInspirationCategoriesDK?.ContentStatusId != null ||
                    crmPartner.PartnerInspirationCategoriesDK?.ContentStatusId == 1)
                {
                    crmPartner.PartnerInspirationCategoriesDK = null;
                }

                if (crmPartner.PartnerInspirationCategoriesUK?.ContentStatusId != null ||
                    crmPartner.PartnerInspirationCategoriesUK?.ContentStatusId == 1)
                {
                    crmPartner.PartnerInspirationCategoriesUK = null;
                }

                _dictionary.Add(crmPartner.CRMPartnerId, partnerChildDetails);
            }

            UpdateCrmPartnerChildDetails(crmResults, _dictionary);

            return(crmResults);
        }