From ae51a4ad4b82de4cd9581fd7ce781dddd593df31 Mon Sep 17 00:00:00 2001 From: Le Deng Date: Sat, 11 Mar 2017 16:05:58 -0500 Subject: [PATCH] latest --- bookstore-api/.idea/workspace.xml | 4 ++-- .../shopping-cart.component.html | 3 +-- .../shopping-cart/shopping-cart.component.ts | 21 +++++++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/bookstore-api/.idea/workspace.xml b/bookstore-api/.idea/workspace.xml index 2926fe3..877f7e8 100644 --- a/bookstore-api/.idea/workspace.xml +++ b/bookstore-api/.idea/workspace.xml @@ -1017,12 +1017,12 @@ - + - diff --git a/store-front/src/app/components/shopping-cart/shopping-cart.component.html b/store-front/src/app/components/shopping-cart/shopping-cart.component.html index 03ad33e..74f6881 100644 --- a/store-front/src/app/components/shopping-cart/shopping-cart.component.html +++ b/store-front/src/app/components/shopping-cart/shopping-cart.component.html @@ -17,7 +17,7 @@
@@ -47,7 +47,6 @@

{{cartItem.book.title}}

-

In Stock

Only {{cartItem.book.inStockNumber}} In Stock

diff --git a/store-front/src/app/components/shopping-cart/shopping-cart.component.ts b/store-front/src/app/components/shopping-cart/shopping-cart.component.ts index c133081..289108a 100644 --- a/store-front/src/app/components/shopping-cart/shopping-cart.component.ts +++ b/store-front/src/app/components/shopping-cart/shopping-cart.component.ts @@ -18,6 +18,8 @@ export class ShoppingCartComponent implements OnInit { private cartItemNumber: number; private shoppingCart: ShoppingCart = new ShoppingCart(); private cartItemUpdated:boolean; + private emptyCart: boolean; + private notEnoughStock: boolean; constructor(private router:Router, private cartService: CartService) { } @@ -76,6 +78,25 @@ export class ShoppingCartComponent implements OnInit { ); } + onCheckout() { + if (this.cartItemNumber==0) { + this.emptyCart=true; + } else { + + for (let item of this.cartItemList) { + if(item.qty > item.book.inStockNumber) { + console.log("not enough stock"); + + this.notEnoughStock = true; + + return; + } + } + + this.router.navigate(['/order']); + } + } + ngOnInit() { this.getCartItemList();