/// <summary>
        /// Calculate the value of an <c>Opportunity</c> that is in the <c>Won</c> state.
        /// <para>
        /// Please note that this method works correctly if opportunity has valid <c>Quote</c> records that <c>Won</c> state (converted to <c>SalesOrder</c>).
        /// For more information look at https://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.calculateactualvalueopportunityrequest(v=crm.7).aspx
        /// </para>
        /// </summary>
        /// <param name="id"><c>Opportunity</c> Id</param>
        /// <returns>
        /// <see cref="CalculateActualValueOpportunityResponse"/> <c>Value</c> attribute for calculated revenue
        /// </returns>
        public CalculateActualValueOpportunityResponse CalculateActualValue(Guid id)
        {
            ExceptionThrow.IfGuidEmpty(id, "id");

            CalculateActualValueOpportunityRequest request = new CalculateActualValueOpportunityRequest()
            {
                OpportunityId = id
            };

            return((CalculateActualValueOpportunityResponse)this.OrganizationService.Execute(request));
        }
        public CalculateActualValueOpportunityResponse CalculateActualValueOfOpportunity(EntityReference entityReference)
        {
            var portal  = PortalCrmConfigurationManager.CreatePortalContext();
            var context = portal.ServiceContext;

            var calculateActualValueRequest =
                new     CalculateActualValueOpportunityRequest()
            {
                OpportunityId = entityReference.Id
            };

            var calculateActualValueResponse =
                (CalculateActualValueOpportunityResponse)context.Execute(calculateActualValueRequest);

            return(calculateActualValueResponse);
        }