Exemple #1
0
        public ActionResult <IEnumerable <PartnerInspirationCategoriesUKDTO> > PartnerInspirationCategoriesUK([FromBody] PartnerInspirationCategoriesUKDTO PartnerInspirationCategoriesUKDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (PartnerInspirationCategoriesUKDTO == null)
            {
                return(BadRequest());
            }

            var checkPartnerCenterRoomInfoIdinDb = _choiceRepoistory.GetPartnerInspirationCategoriesUK().Find(c => c.PartnerInspirationCategoriesUKId == PartnerInspirationCategoriesUKDTO.PartnerInspirationCategoriesUKId);

            if (checkPartnerCenterRoomInfoIdinDb != null)
            {
                return(BadRequest());
            }

            PartnerInspirationCategoriesUK newlyPartnerInspirationCategoriesUKDTO = new PartnerInspirationCategoriesUK()
            {
                PartnerInspirationCategoriesUKId = PartnerInspirationCategoriesUKDTO.PartnerInspirationCategoriesUKId,
                CRMPartnerId    = PartnerInspirationCategoriesUKDTO.CRMPartnerId,
                Heading         = PartnerInspirationCategoriesUKDTO.Heading,
                Description     = PartnerInspirationCategoriesUKDTO.Description,
                Price           = PartnerInspirationCategoriesUKDTO.Price,
                Sorting         = PartnerInspirationCategoriesUKDTO.Sorting,
                ContentStatusId = PartnerInspirationCategoriesUKDTO.ContentStatusId,
                CreatedDate     = PartnerInspirationCategoriesUKDTO.CreatedDate,
                CreatedBy       = PartnerInspirationCategoriesUKDTO.CreatedBy,
                LastModified    = PartnerInspirationCategoriesUKDTO.LastModified,
                LastModifiedBY  = PartnerInspirationCategoriesUKDTO.LastModifiedBY
            };

            _choiceRepoistory.SetpartnerInspirationCategoriesUK(newlyPartnerInspirationCategoriesUKDTO);
            _choiceRepoistory.Complete();

            return(CreatedAtRoute("getbypartnerinspirationcategoriesUK", new { newlyPartnerInspirationCategoriesUKDTO.PartnerInspirationCategoriesUKId }, newlyPartnerInspirationCategoriesUKDTO));
        }
        //public void SetpartnerCenterInfo(PartnerCenterInfo partnerCenterInfo)
        //{
        //    _dbContext.PartnerCenterInfo.Add(partnerCenterInfo);
        //}

        public void SetpartnerInspirationCategoriesUK(PartnerInspirationCategoriesUK partnerInspirationCategoriesUK)
        {
            _dbContext.PartnerInspirationCategoriesUK.Add(partnerInspirationCategoriesUK);
        }
Exemple #3
0
 public void InsertData()
 {
     try
     {
         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();
         var contentStatusId = Extension.GetApprovedConentStatusId(DKBSDbContext);
         foreach (ListItem oListItem in collListItem)
         {
             var hyperLink = ((FieldUrlValue)(oListItem["CISite"]));
             if (hyperLink != null)
             {
                 var           hLink   = ((FieldUrlValue)(oListItem["CISite"])).Url;
                 ClientContext Context = new ClientContext(hLink);
                 Context.AuthenticationMode           = ClientAuthenticationMode.FormsAuthentication;
                 Context.FormsAuthenticationLoginInfo = new FormsAuthenticationLoginInfo("CRM Automation", "9LEkTny4");
                 Context.ExecuteQuery();
                 List oListData = Context.Web.Lists.GetByTitle("Inspirationskategorier (EN)");
                 camlQuery.ViewXml = "<View Scope='RecursiveAll'><Query></Query></View>";
                 ListItemCollection oListDataItem = oListData.GetItems(camlQuery);
                 Context.Load(oListDataItem);
                 Context.ExecuteQuery();
                 CRMPartner partner = DKBSDbContext.CRMPartner.Where(p => p.AccountId == oListItem.Id.ToString()).Single();
                 foreach (ListItem oItem in oListDataItem)
                 {
                     try
                     {
                         log.Info($"PartnerInspirationCategoriesUK started. Partner Id: {partner.AccountId} SharepointId:{oItem.Id}");
                         PartnerInspirationCategoriesUK uk = new PartnerInspirationCategoriesUK();
                         uk.Heading         = oItem["Headline"].ToSharepointString();
                         uk.CRMPartnerId    = partner.CRMPartnerId;
                         uk.Description     = oItem["Description"].ToSharepointString();
                         uk.CreatedBy       = oItem.GetAuthor();
                         uk.LastModifiedBY  = oItem.GetEditor();
                         uk.CreatedDate     = oItem.GetCreateDate();
                         uk.LastModified    = oItem.GetModifiedDate();
                         uk.ContentStatusId = contentStatusId;
                         uk.Price           = oItem["Price"].ToDecimal();
                         uk.Sorting         = oItem["Position"].ToInt();
                         uk.SharepointId    = oItem.Id;
                         DKBSDbContext.PartnerInspirationCategoriesUK.Add(uk);
                         DKBSDbContext.SaveChanges();
                         log.Info($"PartnerInspirationCategoriesUK completed. Partner Id: {partner.AccountId} SharepointId:{oItem.Id}");
                     }
                     catch (Exception ex)
                     {
                         ErrorCount += 1;
                         log.Error($"PartnerInspirationCategoriesUK unable to process. Partner Id: {partner.AccountId} SharepointId:{oItem.Id}", ex);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         ErrorCount += ErrorCount;
         log.Error($"Unable to load Inspirationskategorier (EN)", ex);
     }
     log.Info($"Total ErrorCount:{ErrorCount}");
 }
        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("Inspirationskategorier (EN)");

                        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} \nHeadline: {1}", oItem["ID"], oItem["Headline"]);
                            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["Title"]);
                            Console.WriteLine(oItem["Description"]);
                            Console.WriteLine(oItem["Picture"]);
                            Console.WriteLine(oItem["Price"]);
                            PartnerInspirationCategoriesUK partnerInspirationCategoriesUK = new PartnerInspirationCategoriesUK();
                            if (oItem["Headline"] != null)
                            {
                                partnerInspirationCategoriesUK.Heading = oItem["Headline"].ToString();
                            }
                            partnerInspirationCategoriesUK.CRMPartnerId = 1;
                            if (oItem["Description"] != null)
                            {
                                partnerInspirationCategoriesUK.Description = oItem["Description"].ToString();
                            }

                            if (((SP.FieldUserValue)(oItem["Author"])).LookupValue != null)
                            {
                                partnerInspirationCategoriesUK.CreatedBy = ((SP.FieldUserValue)(oItem["Author"])).LookupValue;
                            }
                            if (((SP.FieldUserValue)(oItem["Editor"])).LookupValue != null)
                            {
                                partnerInspirationCategoriesUK.LastModifiedBY = ((SP.FieldUserValue)(oItem["Editor"])).LookupValue;
                            }
                            if (oItem["Created"] != null)
                            {
                                partnerInspirationCategoriesUK.CreatedDate = Convert.ToDateTime(oItem["Created"].ToString());
                            }
                            if (oItem["Modified"] != null)
                            {
                                partnerInspirationCategoriesUK.LastModified = Convert.ToDateTime(oItem["Modified"].ToString());
                            }
                            partnerInspirationCategoriesUK.ContentStatusId = 1;
                            if (oItem["Price"] != null)
                            {
                                partnerInspirationCategoriesUK.Price = Convert.ToDecimal(oItem["Price"].ToString());
                            }
                            dbContext.Add(partnerInspirationCategoriesUK);
                            dbContext.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }