private Price TransformProxyPriceToPrice(ProxyPrice price)
        {
            Price newPrice = new Price();

            newPrice.PartnerId  = price.PartnerId;
            newPrice.ProductSku = price.ProductSku;
            newPrice.Value      = price.Value;

            return(newPrice);
        }
        /// <summary>
        /// Retrieve the price for a particular SKU that applies to the currently logged on user. This price includes all the discounts that have been
        /// applied to it for the current partner.
        /// </summary>
        /// <param name="sku">The SKU to retrieve pricing for.</param>
        /// <returns>The price.</returns>
        public Price GetPriceBySku(string sku)
        {
            Price price = null;

            //prices are stored per sku and partner
            IPartnerSiteDirectory partnerSiteDirectory =
                SharePointServiceLocator.Current.GetInstance <IPartnerSiteDirectory>();
            string key = string.Format(CultureInfo.InvariantCulture, "{0}:{1}:{2}", typeof(Price).FullName, sku,
                                       partnerSiteDirectory.GetCurrentPartnerId());

            if (cache[key] == null)
            {
                // Impersonate as the AppPool account:
                // As part of the trusted facade, we want to ensure that only the SharePoint server can access
                // the WCF LOB services. In order to check that, we have added a PrincipalPermissionAttribute that demands
                // that the calling account is part of a specific group. The app pool account is also part of that group
                // so we need to impersonate as the app pool account.
                using (HostingEnvironment.Impersonate())
                {
                    // Dispose of the proxy after usage, to ensure the resources are cleaned up:
                    // Creating proxy classes can potentially be a heavy operation, so you might consider
                    // creating a pool of proxy objects.
                    using (DisposableProxy <IPricing> client = GetClient())
                    {
                        price = TransformProxyPriceToPrice(client.Proxy.GetPriceBySku(sku));
                    }
                }

                if (price != null)
                {
                    cache.Add(key, price, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(5f),
                              CacheItemPriority.Normal, null);
                }
            }
            else
            {
                price = cache[key] as Price;
            }

            return(price);
        }