コード例 #1
0
        public void SHOW()
        {
            long opportunityId = 8253984;

            var opportunity = OpportunityResource.Show(opportunityId);

            Assert.Equal("Capsule Dot Net", opportunity.Name);
        }
コード例 #2
0
        public void GET_OPPORTUNITIES_NO_PARAMS()
        {
            // Arrange

            // Act
            var opps = OpportunityResource.List();

            // Assert
            Assert.True(opps.Opportunities.AsQueryable().Count() > 0);
        }
コード例 #3
0
        public void LIST_BY_PARTY()
        {
            // Arrange
            long partyId = 187341289;

            // Act
            var opps = OpportunityResource.ListByParty(partyId);

            // Assert
            Assert.True(opps.Opportunities.AsQueryable().Count() > 0);
        }
コード例 #4
0
        public void SHOW_MULTIPLE()
        {
            long[] ids = new long[2];
            ids[0] = 8253984;
            ids[1] = 8259267;

            var opps = OpportunityResource.ShowMultiple(ids, new List <Embed>()
            {
                Embed.Tags
            }.ToArray());

            Assert.True(opps.Opportunities.AsQueryable().Count() == 2);
            Assert.True(opps.Opportunities.FirstOrDefault().Tags.Count > 0);
        }
コード例 #5
0
        public void UPDATE()
        {
            // Arrange
            long opportunityId = 8253984;
            var  updatedDesc   = Guid.NewGuid().ToString();

            var opportunity = OpportunityResource.Show(opportunityId);

            opportunity.Description = updatedDesc;

            // Act
            var updateResponse = OpportunityResource.Update(opportunityId, opportunity);

            // Assert
            Assert.Equal(updatedDesc, updateResponse.Description);
        }
コード例 #6
0
        public void CREATE()
        {
            // Arrange
            var getParty  = PartyResource.Show(187341289);
            var milestone = MilestoneResource.List();

            var opp = Opportunity.Create(nestedParty: getParty,
                                         name: $"Integration Test - {DateTime.Now.ToString("yyyyMMddHHmmss")}",
                                         nestedMilestone: milestone.Milestones.FirstOrDefault());

            // Act
            var createResponse = OpportunityResource.Create(opp);

            // Assert
            Assert.True(createResponse.Id > 0);
        }
コード例 #7
0
        /// <summary>
        /// Create an Opportunity in OSC
        /// </summary>
        /// <param name="opportunityModel">OpportunityModel</param>
        /// <returns></returns>
        public OpportunityModel CreateOpportunity(OpportunityModel opportunityModel)
        {
            OpportunityModel resultModel = null;

            try
            {
                if (opportunityModel != null)
                {
                    Opportunity opportunity = new Opportunity();
                    opportunity.Name                          = opportunityModel.Name;
                    opportunity.TargetPartyId                 = opportunityModel.TargetPartyId;
                    opportunity.TargetPartyIdSpecified        = opportunityModel.TargetPartyIdSpecified;
                    opportunity.OwnerResourcePartyId          = opportunityModel.OwnerResourcePartyId;
                    opportunity.OwnerResourcePartyIdSpecified = opportunityModel.OwnerResourcePartyIdSpecified;
                    opportunity.KeyContactId                  = opportunityModel.KeyContactId;
                    opportunity.KeyContactIdSpecified         = opportunityModel.KeyContactIdSpecified;

                    OpportunityResource resource = new OpportunityResource();
                    resource.ResourceId          = opportunityModel.OpportunityResourceModel.ResourceId;
                    resource.ResourceIdSpecified = opportunityModel.OpportunityResourceModel.ResourceIdSpecified;
                    resource.OwnerFlag           = opportunityModel.OpportunityResourceModel.OwnerFlag;
                    resource.OwnerFlagSpecified  = opportunityModel.OpportunityResourceModel.OwnerFlagSpecified;

                    OpportunityResource[] resources = new OpportunityResource[] { resource };
                    opportunity.OpportunityResource = resources;
                    if (!OSCCommonUtil.ValidateCurrentSiteName())
                    {
                        resultModel = new OpportunityModel();
                        resultModel.OpportunityId = OSCOpportunitiesCommon.DefaultOpportunitySalesLeadID;
                        return(resultModel);
                    }
                    Opportunity result = _opportunityService._opportunityClient.createOpportunity(opportunity);

                    resultModel = new OpportunityModel();
                    resultModel.OpportunityId = result.OptyId;
                }
            }
            catch (Exception exception)
            {
                _logger.Debug("Error occured while creating opportunity. Opportunity Not Created in Sales Cloud.", exception.StackTrace);
                MessageBox.Show(OSCExceptionMessages.LeadOpportunityCannotBeCreated, OSCExceptionMessages.LeadNotCreatedTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(resultModel);
        }
コード例 #8
0
        /// <summary>
        /// Create an Opportunity in OSC
        /// </summary>
        /// <param name="opportunityModel">OpportunityModel</param>
        /// <returns></returns>
        public OpportunityModel CreateOpportunity(OpportunityModel opportunityModel)
        {
            OpportunityModel resultModel = null;
            try
            {
                if (opportunityModel != null)
                {
                    Opportunity opportunity = new Opportunity();
                    opportunity.Name = opportunityModel.Name;
                    opportunity.TargetPartyId = opportunityModel.TargetPartyId;
                    opportunity.TargetPartyIdSpecified = opportunityModel.TargetPartyIdSpecified;
                    opportunity.OwnerResourcePartyId = opportunityModel.OwnerResourcePartyId;
                    opportunity.OwnerResourcePartyIdSpecified = opportunityModel.OwnerResourcePartyIdSpecified;
                    opportunity.KeyContactId = opportunityModel.KeyContactId;
                    opportunity.KeyContactIdSpecified = opportunityModel.KeyContactIdSpecified;

                    OpportunityResource resource = new OpportunityResource();
                    resource.ResourceId = opportunityModel.OpportunityResourceModel.ResourceId;
                    resource.ResourceIdSpecified = opportunityModel.OpportunityResourceModel.ResourceIdSpecified;
                    resource.OwnerFlag = opportunityModel.OpportunityResourceModel.OwnerFlag;
                    resource.OwnerFlagSpecified = opportunityModel.OpportunityResourceModel.OwnerFlagSpecified;

                    OpportunityResource[] resources = new OpportunityResource[] { resource };
                    opportunity.OpportunityResource = resources;
                    if (!OSCCommonUtil.ValidateCurrentSiteName())
                    {
                        resultModel = new OpportunityModel();
                        resultModel.OpportunityId = OSCOpportunitiesCommon.DefaultOpportunitySalesLeadID;
                        return resultModel;
                    }
                    Opportunity result = _opportunityService._opportunityClient.createOpportunity(opportunity);

                    resultModel = new OpportunityModel();
                    resultModel.OpportunityId = result.OptyId;
                }
            }
            catch (Exception exception)
            {
                _logger.Debug("Error occured while creating opportunity. Opportunity Not Created in Sales Cloud.", exception.StackTrace);
                MessageBox.Show(OSCExceptionMessages.LeadOpportunityCannotBeCreated, OSCExceptionMessages.LeadNotCreatedTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            
            return resultModel;
        }