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); }
public async Task Delete(string quoteId) { IProfile actor = GetActor(quoteId); await actor.ClearQuote(); }