public async Task CanPrepareShoppingCartModel() { var model = await _shoppingCartModelFactory.PrepareShoppingCartModelAsync(new ShoppingCartModel(), new List <ShoppingCartItem> { _shoppingCartItem }); model.IsEditable.Should().BeTrue(); model.Items.Any().Should().BeTrue(); model.Items.Count.Should().Be(1); model.Warnings.Count.Should().Be(0); }
public async Task <IViewComponentResult> InvokeAsync(bool?prepareAndDisplayOrderReviewData, ShoppingCartModel overriddenModel) { //use already prepared (shared) model if (overriddenModel != null) { return(View(overriddenModel)); } //if not passed, then create a new model var cart = await _shoppingCartService.GetShoppingCartAsync(await _workContext.GetCurrentCustomerAsync(), ShoppingCartType.ShoppingCart, (await _storeContext.GetCurrentStoreAsync()).Id); var model = new ShoppingCartModel(); model = await _shoppingCartModelFactory.PrepareShoppingCartModelAsync(model, cart, isEditable : false, prepareAndDisplayOrderReviewData : prepareAndDisplayOrderReviewData.GetValueOrDefault()); return(View(model)); }