public PolicyArtifactController()
        {
            var proxyFactory = new ServiceProxyFactory((c) => new FabricTransportServiceRemotingClientFactory(
                                                           serializationProvider: new GenericDataProvider(new List <Type> {
                typeof(bool), typeof(List <PolicyArtifact>), typeof(PolicyArtifact)
            })));

            _service = proxyFactory.CreateServiceProxy <IPolicyArtifactService>(new Uri("fabric:/FCGDirect/FCGDirect.Policy"), new ServicePartitionKey(0));
        }
        public async Task <CheckoutSummary> CheckoutQuote(string userId)
        {
            var result = new CheckoutSummary();

            result.Date      = DateTime.UtcNow;
            result.Artifacts = new List <CheckoutArtifact>();

            //call user actor to get the basket
            IProfile userActor            = GetUserActor(userId);
            Dictionary <Guid, int> basket = await userActor.GetQuote();

            //get catalog client
            IPolicyArtifactService catalogService = GetPolicyArtifactService();

            //constuct CheckoutProduct items by calling to the catalog
            foreach (KeyValuePair <Guid, int> basketLine in basket)
            {
                PolicyArtifact artifact = await catalogService.GetPolicyQuoteById(basketLine.Key);

                var checkoutProduct = new CheckoutArtifact
                {
                    Artifact = artifact,
                    Price    = artifact.Price,
                    Quantity = basketLine.Value
                };
                result.Artifacts.Add(checkoutProduct);
            }

            //generate total price
            result.TotalPrice = result.Artifacts.Sum(p => p.Price);

            //clear user basket
            await userActor.ClearQuote();

            await AddToHistory(result);

            return(result);
        }