public ActionResult <IEnumerable <PartnerCenterDescriptionDTO> > CreatePartnerCenterDescription([FromBody] PartnerCenterDescriptionDTO partnerCenterDescriptionDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

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

            var checkPartnerIdinDb = _choiceRepoistory.GetPartnerCenterDescriptions().Find(c => c.PartnerCenterDescriptionId == partnerCenterDescriptionDto.PartnerCenterDescriptionId);

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

            PartnerCenterDescription newlyCreatedPartnerCenterDescription = new PartnerCenterDescription()
            {
                PartnerCenterDescriptionId = partnerCenterDescriptionDto.PartnerCenterDescriptionId,
                CRMPartnerId             = partnerCenterDescriptionDto.CRMPartnerId,
                Rooms                    = partnerCenterDescriptionDto.Rooms,
                Capacity                 = partnerCenterDescriptionDto.Capacity,
                Facilities               = partnerCenterDescriptionDto.Facilities,
                Activities               = partnerCenterDescriptionDto.Activities,
                TextforQuotationforEmail = partnerCenterDescriptionDto.TextforQuotationforEmail,
                Transportation           = partnerCenterDescriptionDto.Transportation,
                Description              = partnerCenterDescriptionDto.Description,
                AdditionalIncluded       = partnerCenterDescriptionDto.AdditionalIncluded,
                Language                 = partnerCenterDescriptionDto.Language,
                ContentStatusId          = partnerCenterDescriptionDto.ContentStatusId,
                CreatedDate              = partnerCenterDescriptionDto.CreatedDate,
                CreatedBy                = partnerCenterDescriptionDto.CreatedBy,
                LastModified             = partnerCenterDescriptionDto.LastModified,
                LastModifiedBY           = partnerCenterDescriptionDto.LastModifiedBy
            };
            var destination = _mapper.Map <PartnerCenterDescription, PartnerCenterDescriptionDTO>(newlyCreatedPartnerCenterDescription);


            //_choiceRepoistory.GetPartnerCenterDescriptions().Add(destination);
            //_choiceRepoistory.Complete();

            _choiceRepoistory.SetPartnerCenterDescriptions(newlyCreatedPartnerCenterDescription);
            _choiceRepoistory.Complete();

            var crmPartner = _choiceRepoistory.GetById <CRMPartner>(x => x.CRMPartnerId == newlyCreatedPartnerCenterDescription.CRMPartnerId);

            crmPartner.LastModified   = DateTime.UtcNow;
            crmPartner.LastModifiedBy = "CloudMission";
            _choiceRepoistory.Attach(crmPartner);
            _choiceRepoistory.Complete();


            return(CreatedAtRoute("GetPartnerCenterDescriptionId", new { newlyCreatedPartnerCenterDescription.PartnerCenterDescriptionId }, newlyCreatedPartnerCenterDescription));

            // return CreatedAtRoute("GetPartnerByAccountId", new { newPartner.AccountId }, dto);
        }
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("Centerbeskrivelse");

                        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} \nDescription: {1} \nLanguageType:{2} \nRooms:{3}", oItem["ID"], oItem["Description"], oItem["LanguageType"], oItem["Rooms"]);
                            Console.WriteLine("TraficConnections: {0} \nCapacity: {1} \nFacilities:{2} \nActivities:{3}", oItem["TraficConnections"], oItem["Capacity"], oItem["Facilities"], oItem["Activities"]);
                            Console.WriteLine("TextOffer: {0} \nFurtherIncluded: {1}", oItem["TextOffer"], oItem["FurtherIncluded"]);
                            Console.WriteLine(((SP.FieldUserValue)(oItem["Author"])).LookupValue);
                            Console.WriteLine(((SP.FieldUserValue)(oItem["Editor"])).LookupValue);
                            Console.WriteLine(oItem["Created"].ToString());
                            Console.WriteLine(oItem["Modified"].ToString());
                            PartnerCenterDescription partnerCenterDescription = new PartnerCenterDescription();
                            // partnerCenterDescription.CRMPartnerId = 1;//oListItem.Id
                            partnerCenterDescription.CRMPartnerId = oListItem.Id;
                            // partnerCenterDescription.ContentStatusId = 2;//Approved
                            if (oItem["Rooms"] != null)
                            {
                                partnerCenterDescription.Rooms = oItem["Rooms"].ToString();
                            }
                            if (oItem["Capacity"] != null)
                            {
                                partnerCenterDescription.Capacity = oItem["Capacity"].ToString();
                            }
                            if (oItem["Facilities"] != null)
                            {
                                partnerCenterDescription.Facilities = oItem["Facilities"].ToString();
                            }
                            if (oItem["Activities"] != null)
                            {
                                partnerCenterDescription.Activities = oItem["Activities"].ToString();
                            }
                            if (oItem["TextOffer"] != null)
                            {
                                partnerCenterDescription.TextforQuotationforEmail = oItem["TextOffer"].ToString();
                            }
                            if (oItem["TraficConnections"] != null)
                            {
                                partnerCenterDescription.Transportation = oItem["TraficConnections"].ToString();
                            }
                            if (oItem["Description"] != null)
                            {
                                partnerCenterDescription.Description = oItem["Description"].ToString();
                            }
                            if (oItem["ID"] != null)
                            {
                                partnerCenterDescription.PartnerCenterDescriptionSpId = oItem["ID"].ToString();
                            }

                            if (oItem["FurtherIncluded"] != null)
                            {
                                partnerCenterDescription.AdditionalIncluded = oItem["FurtherIncluded"].ToString();
                            }
                            if (oItem["LanguageType"] != null)
                            {
                                partnerCenterDescription.Language = oItem["LanguageType"].ToString();
                            }
                            if (((SP.FieldUserValue)(oItem["Author"])).LookupValue != null)
                            {
                                partnerCenterDescription.CreatedBy = ((SP.FieldUserValue)(oItem["Author"])).LookupValue;
                            }
                            if (oItem["Created"] != null)
                            {
                                partnerCenterDescription.CreatedDate = Convert.ToDateTime(oItem["Created"].ToString());
                            }
                            if (((SP.FieldUserValue)(oItem["Editor"])).LookupValue != null)
                            {
                                partnerCenterDescription.LastModifiedBY = ((SP.FieldUserValue)(oItem["Editor"])).LookupValue;
                            }
                            if (oItem["Modified"] != null)
                            {
                                partnerCenterDescription.LastModified = Convert.ToDateTime(oItem["Modified"].ToString());
                            }
                            partnerCenterDescription.ContentStatusId = 1;
                            dbContext.Add(partnerCenterDescription);
                            dbContext.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 3
0
 public void SetPartnerCenterDescriptions(PartnerCenterDescription PartnerCenterDescription)
 {
     _dbContext.PartnerCenterDescription.Add(PartnerCenterDescription);
 }