public void InsertData()
        {
            try
            {
                List      oList     = ClientContext.Web.Lists.GetByTitle("Partnere");
                CamlQuery camlQuery = new CamlQuery();
                //<Where><Eq><FieldRef Name='ID' /><Value Type='Text'>49</Value></Eq>
                camlQuery.ViewXml = "<View Scope='RecursiveAll'><Query></Where></Query></View>";
                ListItemCollection collListItem = oList.GetItems(camlQuery);
                ClientContext.Load(collListItem);
                ClientContext.ExecuteQuery();
                //get content status Id.
                var contentStatusId = Extension.GetApprovedConentStatusId(DKBSDbContext);
                foreach (ListItem oListItem in collListItem)
                {
                    var hyperLink = ((FieldUrlValue)(oListItem["CISite"]));
                    if (hyperLink != null)
                    {
                        try
                        {
                            var           hLink   = ((FieldUrlValue)(oListItem["CISite"])).Url;
                            ClientContext Context = new ClientContext(hLink);
                            Context.AuthenticationMode           = ClientAuthenticationMode.FormsAuthentication;
                            Context.FormsAuthenticationLoginInfo = new FormsAuthenticationLoginInfo(Configuration["SharePointUserName"], Configuration["SharePointPassword"]);
                            Context.ExecuteQuery();
                            List oListData = Context.Web.Lists.GetByTitle("Kursuspakke");
                            camlQuery.ViewXml = "<View Scope='RecursiveAll'><Query></Query></View>";
                            ListItemCollection oListDataItem = oListData.GetItems(camlQuery);
                            Context.Load(oListDataItem);
                            Context.ExecuteQuery();

                            foreach (ListItem oItem in oListDataItem)
                            {
                                log.Info($"Partner course package data process started Partner Id: {oItem.Id}");
                                try
                                {
                                    log.Info($"Partner course package data process started Kursuspakke: {oItem.Id} Service Catalog Id { oItem["KursuspakkeID"].ToInt(true, 0)}");
                                    CoursePackage        coursePackage  = DKBSDbContext.CoursePackage.Where(p => p.SharepointId == oItem["KursuspakkeID"].ToInt(true, 0)).Single();
                                    CRMPartner           partner        = DKBSDbContext.CRMPartner.Where(p => p.AccountId == oListItem.Id.ToString()).Single();
                                    PartnerCoursePackage partnerPackage = new PartnerCoursePackage();
                                    partnerPackage.CRMPartnerId    = partner.CRMPartnerId;
                                    partnerPackage.SharepointId    = oItem.Id;
                                    partnerPackage.CoursePackageId = coursePackage.CoursePackageId;
                                    partnerPackage.ContentStatusId = contentStatusId;
                                    partnerPackage.Offered         = oItem["Offered"].ToBoolean();
                                    partnerPackage.Price           = oItem["Price"].ToDecimal();
                                    partnerPackage.CreatedDate     = oItem.GetCreateDate();
                                    partnerPackage.LastModified    = oItem.GetModifiedDate();
                                    partnerPackage.LastModifiedBy  = oItem.GetEditor();
                                    partnerPackage.CreatedBy       = oItem.GetAuthor();

                                    var includedPriceDetails = oItem["IncludedInPriceDefault"].ParseString();
                                    var additionalIncluded   = oItem["IncludedInPriceAdditional"].ParseString();
                                    var optionalPurchages    = oItem["OptionalPurchases"].ParseString();
                                    var pricePerYear         = oItem["PricePerYear"].ParseString();

                                    // Included in price
                                    foreach (var item in includedPriceDetails)
                                    {
                                        var packageItem = DKBSDbContext.PackageIncludedItem.First(p => p.CoursePackageId == coursePackage.CoursePackageId && p.DK == item[0]);
                                        PartnerPackageIncludedItem ppi = new PartnerPackageIncludedItem()
                                        {
                                            PartnerCoursePackageId = partnerPackage.PartnerCoursePackageId,
                                            CreatedDate            = oItem.GetCreateDate(),
                                            LastModified           = oItem.GetModifiedDate(),
                                            LastModifiedBy         = oItem.GetEditor(),
                                            CreatedBy             = oItem.GetAuthor(),
                                            PackageIncludedItemId = packageItem.PackageIncludedItemId,
                                            Offered = item[2].IsChecked(),
                                        };
                                        partnerPackage.PartnerPackageIncludedItems.Add(ppi);
                                    }

                                    // additional included
                                    foreach (var item in additionalIncluded)
                                    {
                                        PartnerPackageAdditionalItem ppai = new PartnerPackageAdditionalItem()
                                        {
                                            PartnerCoursePackageId = partnerPackage.PartnerCoursePackageId,
                                            CreatedDate            = oItem.GetCreateDate(),
                                            LastModified           = oItem.GetModifiedDate(),
                                            LastModifiedBy         = oItem.GetEditor(),
                                            CreatedBy = oItem.GetAuthor(),
                                            DK        = item[0],
                                            UK        = item[1]
                                        };
                                        partnerPackage.PartnerPackageAdditionalItems.Add(ppai);
                                    }

                                    // optional purchages in price
                                    foreach (var item in optionalPurchages)
                                    {
                                        PartnerPackageAdditionalItem ppai = new PartnerPackageAdditionalItem()
                                        {
                                            PartnerCoursePackageId = partnerPackage.PartnerCoursePackageId,
                                            CreatedDate            = oItem.GetCreateDate(),
                                            LastModified           = oItem.GetModifiedDate(),
                                            LastModifiedBy         = oItem.GetEditor(),
                                            CreatedBy = oItem.GetAuthor(),
                                            DK        = item[0],
                                            UK        = item[1],
                                            Price     = item[2].ToDecimal(defaultData: true, defaultDataValue: 0).Value
                                        };
                                        partnerPackage.PartnerPackageAdditionalItems.Add(ppai);
                                    }

                                    // Price next year
                                    foreach (var item in pricePerYear)
                                    {
                                        PartnerPackageYear pny = new PartnerPackageYear()
                                        {
                                            PartnerCoursePackageId = partnerPackage.PartnerCoursePackageId,
                                            CreatedDate            = oItem.GetCreateDate(),
                                            LastModified           = oItem.GetModifiedDate(),
                                            LastModifiedBy         = oItem.GetEditor(),
                                            CreatedBy      = oItem.GetAuthor(),
                                            Year           = item[0].ToInt(true, 0).Value,
                                            PricePerPerson = item[1].ToDecimal(true, 0).Value,
                                        };
                                        partnerPackage.PartnerPackageYears.Add(pny);
                                    }
                                    DKBSDbContext.Add(partnerPackage);
                                    DKBSDbContext.SaveChanges();
                                    log.Info($"Partner course package data process completed Kursuspakke: {oItem.Id} Service Catalog Id { oItem["KursuspakkeID"].ToInt(true, 0)}");
                                }
                                catch (Exception ex)
                                {
                                    ErrorCount += 1;
                                    log.Error($"Error:Unable to insert Course package Kursuspakke Id: {oItem.Id} Service Catalog Id { oItem["KursuspakkeID"].ToInt(true, 0)}", ex);
                                }
                            }
                            log.Info($"Partner course package data process completed Partner Id: {oListItem.Id}");
                        }
                        catch (Exception ex)
                        {
                            ErrorCount += 1;
                            log.Error($"Error:Unable to pull Kursuspakke. PartnerId:{oListItem.Id}", ex);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error($"Error:Unable to pull Partnere.", ex);
            }
            log.Info($"Total ErrorCount:{ErrorCount}");
        }
Esempio n. 2
0
        public void InsertData(ClientContext clientContext, DKBSDbContext dbContext)
        {
            try
            {
                Console.WriteLine(" Successfully Connected");


                SP.List oList = clientContext.Web.Lists.GetByTitle("Partnere");

                CamlQuery camlQuery = new CamlQuery();
                camlQuery.ViewXml = "<View Scope='RecursiveAll'><Query></Query></View>";
                ListItemCollection collListItem = oList.GetItems(camlQuery);

                clientContext.Load(collListItem);

                clientContext.ExecuteQuery();

                foreach (ListItem oListItem in collListItem)
                {
                    var hyperLink = ((SP.FieldUrlValue)(oListItem["CISite"]));
                    if (hyperLink != null)
                    {
                        Console.WriteLine("ID: {0} \nTitle: {1} \nSite: {2} \nSiteUrl: {3} ", oListItem.Id, oListItem["Title"], oListItem["CISite"], oListItem["CISiteShortUrl"]);
                        var hLink = ((SP.FieldUrlValue)(oListItem["CISite"])).Url;
                        Console.WriteLine(hLink);


                        ClientContext Context = new ClientContext(hLink);
                        Context.AuthenticationMode           = ClientAuthenticationMode.FormsAuthentication;
                        Context.FormsAuthenticationLoginInfo = new FormsAuthenticationLoginInfo("CRM Automation", "9LEkTny4");
                        Context.ExecuteQuery();
                        SP.List oListData = Context.Web.Lists.GetByTitle("Kursuspakke");

                        camlQuery.ViewXml = "<View Scope='RecursiveAll'><Query></Query></View>";
                        ListItemCollection oListDataItem = oListData.GetItems(camlQuery);

                        Context.Load(oListDataItem);

                        Context.ExecuteQuery();

                        foreach (ListItem oItem in oListDataItem)
                        {
                            Console.WriteLine("ID: {0} \nTitle: {1} \nKursuspakkeUK:{2} \nOffered: {3} \nPrice:{4}", oItem.Id, oItem["Title"], oItem["KursuspakkeUK"], oItem["Offered"], oItem["Price"]);
                            Console.WriteLine("IncludedInPriceAdditional: {0} \nIncludedInPriceDefault:{1} \nOptionalPurchases: {2} \nPricePerYear:{3}", oItem["IncludedInPriceAdditional"], oItem["IncludedInPriceDefault"], oItem["OptionalPurchases"], oItem["PricePerYear"]);
                            Console.WriteLine(((SP.FieldUserValue)(oItem["Author"])).LookupValue);
                            Console.WriteLine(((SP.FieldUserValue)(oItem["Editor"])).LookupValue);
                            Console.WriteLine(oItem["Created"].ToString());
                            Console.WriteLine(oItem["Modified"].ToString());
                            Console.WriteLine(oItem["KursuspakkeID"]);
                            CoursePackage        coursePackage        = dbContext.CoursePackage.Where(p => p.CoursePackageName == oItem["Title"].ToString()).First();
                            PartnerCoursePackage partnerCoursePackage = new PartnerCoursePackage();
                            PartnerPackageYear   partnerPackageYear   = new PartnerPackageYear();
                            // partnerCoursePackage.CRMPartnerId = oListItem.Id;
                            partnerCoursePackage.CRMPartnerId    = 1; //hard-coded value for test purpose
                            partnerCoursePackage.CoursePackageId = coursePackage.CoursePackageId;
                            // partnerCoursePackage.CoursePackageId = oItem.Id;
                            partnerCoursePackage.ContentStatusId = 1;    //hard-coded value for test purpose
                            partnerCoursePackage.Offered         = Convert.ToBoolean(oItem["Offered"]);
                            partnerCoursePackage.Price           = Convert.ToDecimal(oItem["Price"]);
                            partnerCoursePackage.CreatedDate     = Convert.ToDateTime(oItem["Created"].ToString());
                            partnerCoursePackage.LastModified    = Convert.ToDateTime(oItem["Modified"].ToString());
                            partnerCoursePackage.LastModifiedBy  = ((SP.FieldUserValue)(oItem["Editor"])).LookupValue;
                            partnerCoursePackage.CreatedBy       = ((SP.FieldUserValue)(oItem["Author"])).LookupValue;

                            partnerPackageYear.PartnerCoursePackageId = oItem.Id;
                            // if(oItem["PricePerYear"] != null) partnerPackageYear.Year = Convert.ToInt32(oItem["PricePerYear"]);
                            partnerPackageYear.CreatedDate    = Convert.ToDateTime(oItem["Created"].ToString());
                            partnerPackageYear.LastModified   = Convert.ToDateTime(oItem["Modified"].ToString());
                            partnerPackageYear.LastModifiedBy = ((SP.FieldUserValue)(oItem["Editor"])).LookupValue;
                            partnerPackageYear.CreatedBy      = ((SP.FieldUserValue)(oItem["Author"])).LookupValue;
                            //partnerPackageYear.PricePerPerson = oItem.

                            if (oItem["IncludedInPriceDefault"] != null)
                            {
                                ArrayList parsedData = new ArrayList();
                                partnerCoursePackage.PartnerPackageIncludedItems = new List <PartnerPackageIncludedItem>();
                                SharedFunctions sharedFunctions = new SharedFunctions();
                                parsedData = sharedFunctions.ParseFunction(oItem["IncludedInPriceDefault"].ToString());
                                if (parsedData.Count > 0)
                                {
                                    foreach (List <String> pacakageData in parsedData)
                                    {
                                        Console.WriteLine(pacakageData);
                                        Array pacakageDataArray = pacakageData.ToArray();
                                        PackageIncludedItem packageIncludedItem = dbContext.PackageIncludedItem.Where(p => p.DK == pacakageData[0]).First();
                                        partnerCoursePackage.PartnerPackageIncludedItems.Add(new PartnerPackageIncludedItem()
                                        {
                                            PartnerCoursePackageId       = oItem.Id,
                                            PartnerPackageIncludedItemId = packageIncludedItem.PackageIncludedItemId,
                                            Offered = (pacakageData.Count > 2 ? (pacakageData[2] == "checked" ? true : false) : false)
                                        });
                                    }
                                }
                            }
                            //else
                            //{

                            //    partnerCoursePackage.PartnerPackageIncludedItems.Add(new PartnerPackageIncludedItems() { CoursePackageId = Convert.ToInt32(oItem["ID"]) });

                            //}
                            if (oItem["IncludedInPriceAdditional"] != null)
                            {
                                ArrayList parsedData = new ArrayList();
                                partnerCoursePackage.PartnerPackageIncludedItems = new List <PartnerPackageIncludedItem>();
                                SharedFunctions sharedFunctions = new SharedFunctions();
                                parsedData = sharedFunctions.ParseFunction(oItem["IncludedInPriceAdditional"].ToString());
                                if (parsedData.Count > 0)
                                {
                                    foreach (List <String> pacakageData in parsedData)
                                    {
                                        Console.WriteLine(pacakageData);
                                        Array pacakageDataArray = pacakageData.ToArray();

                                        partnerCoursePackage.PartnerPackageAdditionalItems.Add(new PartnerPackageAdditionalItem()
                                        {
                                            PartnerCoursePackageId = oItem.Id,
                                            DK             = pacakageData[0],
                                            CreatedDate    = Convert.ToDateTime(oItem["Created"].ToString()),
                                            LastModified   = Convert.ToDateTime(oItem["Modified"].ToString()),
                                            LastModifiedBy = ((SP.FieldUserValue)(oItem["Editor"])).LookupValue,
                                            CreatedBy      = ((SP.FieldUserValue)(oItem["Author"])).LookupValue,
                                            Price          = Convert.ToDecimal(oItem["Price"])
                                        });
                                    }
                                }
                            }
                            if (oItem["OptionalPurchases"] != null)
                            {
                                ArrayList parsedData = new ArrayList();
                                partnerCoursePackage.PartnerPackageIncludedItems = new List <PartnerPackageIncludedItem>();
                                SharedFunctions sharedFunctions = new SharedFunctions();
                                parsedData = sharedFunctions.ParseFunction(oItem["OptionalPurchases"].ToString());
                                if (parsedData.Count > 0)
                                {
                                    foreach (List <String> pacakageData in parsedData)
                                    {
                                        Console.WriteLine(pacakageData);
                                        Array pacakageDataArray = pacakageData.ToArray();

                                        partnerCoursePackage.PartnerPackageAdditionalItems.Add(new PartnerPackageAdditionalItem()
                                        {
                                            PartnerCoursePackageId = oItem.Id,
                                            DK             = pacakageData[0],
                                            CreatedDate    = Convert.ToDateTime(oItem["Created"].ToString()),
                                            LastModified   = Convert.ToDateTime(oItem["Modified"].ToString()),
                                            LastModifiedBy = ((SP.FieldUserValue)(oItem["Editor"])).LookupValue,
                                            CreatedBy      = ((SP.FieldUserValue)(oItem["Author"])).LookupValue
                                                             //Price = pacakageData[2] == "" ? 0 : Convert.ToDecimal(pacakageData[2])
                                        });
                                    }
                                }
                            }
                            dbContext.Add(partnerCoursePackage);
                            dbContext.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        public ActionResult <PartnerCoursePackageDTO> UpdatePartnerCoursePackages(int partnerCoursePackageId, [FromBody] PutPartnerCoursePackageDTO putPartnerCoursePackageDTO)
        {
            var partnerCoursePackageEntryInDb = _choiceRepository.GetById <PartnerCoursePackage>(x => x.PartnerCoursePackageId == partnerCoursePackageId);

            partnerCoursePackageEntryInDb.CoursePackageId = putPartnerCoursePackageDTO.CoursePackageId;
            partnerCoursePackageEntryInDb.ContentStatusId = putPartnerCoursePackageDTO.ContentStatusId;
            partnerCoursePackageEntryInDb.CreatedBy       = putPartnerCoursePackageDTO.CreatedBy;
            partnerCoursePackageEntryInDb.CreatedDate     = putPartnerCoursePackageDTO.CreatedDate;
            partnerCoursePackageEntryInDb.LastModified    = putPartnerCoursePackageDTO.LastModified;
            partnerCoursePackageEntryInDb.LastModifiedBy  = putPartnerCoursePackageDTO.LastModifiedBy;
            partnerCoursePackageEntryInDb.Offered         = putPartnerCoursePackageDTO.Offered;
            partnerCoursePackageEntryInDb.Price           = putPartnerCoursePackageDTO.Price;


            //PartnerPackageIncludedItem
            var allPartnerPackageIncludedItemsInDb = _choiceRepository.GetAll <PartnerPackageIncludedItem>(x => x.PartnerCoursePackageId == partnerCoursePackageEntryInDb.PartnerCoursePackageId);

            // First remove all
            foreach (var partnerPackageIncludedItem in allPartnerPackageIncludedItemsInDb)
            {
                _choiceRepository.Remove <PartnerPackageIncludedItem>(partnerPackageIncludedItem);
            }

            foreach (var packageIncludedItemDTO in putPartnerCoursePackageDTO.PartnerPackageIncludedItemDTOs)
            {
                PartnerPackageIncludedItem partnerPackageIncludedItem = new PartnerPackageIncludedItem();
                partnerPackageIncludedItem.PartnerCoursePackageId = partnerCoursePackageEntryInDb.PartnerCoursePackageId;
                partnerPackageIncludedItem.PackageIncludedItemId  = packageIncludedItemDTO.PackageIncludedItemId;
                partnerPackageIncludedItem.CreatedBy      = packageIncludedItemDTO.CreatedBy;
                partnerPackageIncludedItem.CreatedDate    = packageIncludedItemDTO.CreatedDate;
                partnerPackageIncludedItem.LastModified   = packageIncludedItemDTO.LastModified;
                partnerPackageIncludedItem.LastModifiedBy = packageIncludedItemDTO.LastModifiedBy;
                partnerPackageIncludedItem.Offered        = packageIncludedItemDTO.Included;
                _choiceRepository.Add <PartnerPackageIncludedItem>(partnerPackageIncludedItem);
            }


            //PartnerPackageAdditionalItem
            var allPartnerPackageAdditionalItemInDb = _choiceRepository.GetAll <PartnerPackageAdditionalItem>(x => x.PartnerCoursePackageId == partnerCoursePackageEntryInDb.PartnerCoursePackageId);

            // First remove all
            foreach (var partnerPackageAdditionalItem in allPartnerPackageAdditionalItemInDb)
            {
                _choiceRepository.Remove <PartnerPackageAdditionalItem>(partnerPackageAdditionalItem);
            }

            foreach (var partnerPackageAdditionalItemDTO in putPartnerCoursePackageDTO.PartnerPackageAdditionalItemDTOs)
            {
                PartnerPackageAdditionalItem partnerPackageAdditionalItem = new PartnerPackageAdditionalItem();
                partnerPackageAdditionalItem.PartnerCoursePackageId = partnerCoursePackageEntryInDb.PartnerCoursePackageId;

                partnerPackageAdditionalItem.CreatedBy      = partnerPackageAdditionalItemDTO.CreatedBy;
                partnerPackageAdditionalItem.CreatedDate    = partnerPackageAdditionalItemDTO.CreatedDate;
                partnerPackageAdditionalItem.LastModified   = partnerPackageAdditionalItemDTO.LastModified;
                partnerPackageAdditionalItem.LastModifiedBy = partnerPackageAdditionalItemDTO.LastModifiedBy;
                partnerPackageAdditionalItem.Price          = partnerPackageAdditionalItemDTO.Price;
                partnerPackageAdditionalItem.UK             = partnerPackageAdditionalItemDTO.UK;
                partnerPackageAdditionalItem.DK             = partnerPackageAdditionalItemDTO.DK;

                _choiceRepository.Add <PartnerPackageAdditionalItem>(partnerPackageAdditionalItem);
            }


            //PartnerPackageYear
            var allPartnerPackageYearsInDb = _choiceRepository.GetAll <PartnerPackageYear>(x => x.PartnerCoursePackageId == partnerCoursePackageEntryInDb.PartnerCoursePackageId);

            // First remove all
            foreach (var partnerPackageYearItem in allPartnerPackageYearsInDb)
            {
                _choiceRepository.Remove <PartnerPackageYear>(partnerPackageYearItem);
            }

            foreach (var partnerPackageAdditionalItemDTO in putPartnerCoursePackageDTO.PartnerPackageYearDTOs)
            {
                PartnerPackageYear partnerPackageYear = new PartnerPackageYear();
                partnerPackageYear.PartnerCoursePackageId = partnerCoursePackageEntryInDb.PartnerCoursePackageId;

                partnerPackageYear.CreatedBy      = partnerPackageAdditionalItemDTO.CreatedBy;
                partnerPackageYear.CreatedDate    = partnerPackageAdditionalItemDTO.CreatedDate;
                partnerPackageYear.LastModified   = partnerPackageAdditionalItemDTO.LastModified;
                partnerPackageYear.LastModifiedBy = partnerPackageAdditionalItemDTO.LastModifiedBy;
                partnerPackageYear.PricePerPerson = partnerPackageAdditionalItemDTO.PricePerPerson;
                partnerPackageYear.Year           = partnerPackageAdditionalItemDTO.Year;

                _choiceRepository.Add <PartnerPackageYear>(partnerPackageYear);
            }


            _choiceRepository.Complete();

            var crmPartner = _choiceRepository.GetById <CRMPartner>(x => x.CRMPartnerId == partnerCoursePackageEntryInDb.CRMPartnerId);

            crmPartner.LastModified   = DateTime.UtcNow;
            crmPartner.LastModifiedBy = "CloudMission";

            _choiceRepository.Attach(crmPartner);
            _choiceRepository.Complete();


            return(NoContent());
        }
Esempio n. 4
0
        // Later move it seperate class
        private void CreatePartnerRelatedTablesDefaultEntries(CRMPartner newlyCreatedPartner)
        {
            //===========Create Partner Center Description=================================

            List <PartnerCenterDescription> partnerCenterDescriptions = new List <PartnerCenterDescription>(3);

            partnerCenterDescriptions.Add(new PartnerCenterDescription()
            {
                Language = "UK", CRMPartnerId = newlyCreatedPartner.CRMPartnerId, CreatedDate = DateTime.UtcNow, LastModified = DateTime.UtcNow, ContentStatusId = 1
            });
            partnerCenterDescriptions.Add(new PartnerCenterDescription()
            {
                Language = "DK", CRMPartnerId = newlyCreatedPartner.CRMPartnerId, CreatedDate = DateTime.UtcNow, LastModified = DateTime.UtcNow, ContentStatusId = 1
            });
            partnerCenterDescriptions.Add(new PartnerCenterDescription()
            {
                Language = "Ger", CRMPartnerId = newlyCreatedPartner.CRMPartnerId, CreatedDate = DateTime.UtcNow, LastModified = DateTime.UtcNow, ContentStatusId = 1
            });

            foreach (var item in partnerCenterDescriptions)
            {
                _choiceRepoistory.Add <PartnerCenterDescription>(item);
            }

            //===========Create Partner Course Package=================================

            foreach (var item in _choiceRepoistory.GetAll <CoursePackage>())
            {
                PartnerCoursePackage partnerCoursePackage = new PartnerCoursePackage();
                partnerCoursePackage.CoursePackageId = item.CoursePackageId;
                partnerCoursePackage.CRMPartnerId    = newlyCreatedPartner.CRMPartnerId;
                _choiceRepoistory.Add <PartnerCoursePackage>(partnerCoursePackage);

                PartnerPackageIncludedItem partnerPackageIncludedItem = new PartnerPackageIncludedItem();
                partnerPackageIncludedItem.PartnerCoursePackageId = partnerCoursePackage.PartnerCoursePackageId;
                // partnerPackageIncludedItem.PackageIncludedItemId = _choiceRepoistory.GetById<PackageIncludedItem>(x => x.CoursePackageId == partnerCoursePackage.CoursePackageId).PackageIncludedItemId;
                var res = _choiceRepoistory.GetById <PackageIncludedItem>(x => x.CoursePackageId == partnerCoursePackage.CoursePackageId);
                partnerPackageIncludedItem.PackageIncludedItemId = res != null ? (int?)res.PackageIncludedItemId : null;
                _choiceRepoistory.Add <PartnerPackageIncludedItem>(partnerPackageIncludedItem);

                PartnerPackageAdditionalItem partnerPackageAdditionalItem = new PartnerPackageAdditionalItem();
                partnerPackageAdditionalItem.PartnerCoursePackageId = partnerCoursePackage.PartnerCoursePackageId;
                _choiceRepoistory.Add <PartnerPackageAdditionalItem>(partnerPackageAdditionalItem);

                PartnerPackageYear partnerPackageYear = new PartnerPackageYear();
                partnerPackageYear.PartnerCoursePackageId = partnerCoursePackage.PartnerCoursePackageId;
                _choiceRepoistory.Add <PartnerPackageYear>(partnerPackageYear);
            }


            //===========Create PartnerCenterInfo=================================

            PartnerCenterInfo partnerCenterInfo = new PartnerCenterInfo();

            partnerCenterInfo.CRMPartnerId = newlyCreatedPartner.CRMPartnerId;
            _choiceRepoistory.Add <PartnerCenterInfo>(partnerCenterInfo);


            //===========Create PartnerCenterRoomInfo=================================

            //PartnerCenterRoomInfo partnerCenterRoomInfo = new PartnerCenterRoomInfo();
            //partnerCenterRoomInfo.CRMPartnerId = newlyCreatedPartner.CRMPartnerId;
            //_choiceRepoistory.Add<PartnerCenterRoomInfo>(partnerCenterRoomInfo);

            //===========Create PartnerInspirationCategoriesDK=================================

            //PartnerInspirationCategoriesDK partnerInspirationCategoriesDK = new PartnerInspirationCategoriesDK();
            //partnerInspirationCategoriesDK.CRMPartnerId = newlyCreatedPartner.CRMPartnerId;
            //_choiceRepoistory.Add<PartnerInspirationCategoriesDK>(partnerInspirationCategoriesDK);


            //===========Create PartnerInspirationCategoriesUK=================================

            //PartnerInspirationCategoriesUK partnerInspirationCategoriesUK = new PartnerInspirationCategoriesUK();
            //partnerInspirationCategoriesUK.CRMPartnerId = newlyCreatedPartner.CRMPartnerId;
            //_choiceRepoistory.Add<PartnerInspirationCategoriesUK>(partnerInspirationCategoriesUK);
        }