public void Execute() { _outputReciever.ClearScreen(); _outputReciever.WriteLine("Select product:\n"); _listManager.SetItems(_cartService.GetCartItems()); _listManager.SetItemToString(item => $"{item.Product.Name}"); _listManager.PrintItems(); _outputReciever.Write("Your choise: "); var selectedItem = _listManager.GetSelectedItem(); if (selectedItem.IsNull()) { _outputReciever.WriteError("You didn't select anything. Try again."); return; } _outputReciever.Write("\nHow much products do we need to add to cart? [1] "); var count = _outputReciever.GetIntResponse() ?? 1; if (count < 1) { _outputReciever.WriteError("Can't add less than 1 product."); return; } _cartService.AddProduct(selectedItem.Product, Convert.ToUInt32(count)); _outputReciever.WriteInfo($"Added {count} product(-s)."); }
public void Execute() { _outputReciever.ClearScreen(); _outputReciever.Write("How much commands do we need to do again? [1] "); var count = _outputReciever.GetIntResponse() ?? 1; _cartService.Redo(Convert.ToUInt32(count)); _outputReciever.WriteInfo($"Up to {count} command(-s) was successfully redone."); }
public void Execute() { _outputReciever.ClearScreen(); PrintCartItems(); _outputReciever.WriteLine(new string('-', 20)); _outputReciever.WriteLine($"Total: ${_cartService.GetTotalPrice()}"); _outputReciever.GetStringResponse(); }
public void Execute() { // exit when throwed exception (MenuExitException) while (true) { _outputReciever.ClearScreen(); WriteMenu(); _outputReciever.Write("\nYour choise: "); var command = _listManager.GetSelectedItem(); if (command.IsNull()) { _outputReciever.ClearScreen(); _outputReciever.WriteError( "You've selected a nonexistent menu item! Try to select another one!" ); continue; } command.Execute(); } }
public void Execute() { _outputReciever.ClearScreen(); ShowProducts(); var selected = GetSelectedProduct(); if (selected.IsNull()) { _outputReciever.WriteError("Wrong index of product. Try to choose other."); return; } _cartService.AddProduct(selected); _outputReciever.WriteInfo($"Product '{selected.Name}' successfully added to your cart!"); }
public void Execute() { _outputReciever.ClearScreen(); _outputReciever.WriteLine("Select product from cart:"); var items = _cartService.GetCartItems(); _listManager.SetItems(items); _listManager.SetItemToString(item => $"{item.Product.Name}"); _listManager.PrintItems(); var selectedProduct = _listManager.GetSelectedItem(); if (selectedProduct.IsNull()) { _outputReciever.WriteError("You didn't select product!"); return; } _outputReciever.Write("Enter your key: "); var key = GetCouponKey(); if (key.IsNullOrWhiteSpace()) { _outputReciever.WriteError($"Entered key '{key}' does not conform our rules."); return; } var coupon = GetCoupon(key); if (coupon.IsNull()) { _outputReciever.WriteError($"Coupon with key '{key}' does not exists."); return; } if (coupon.Product != selectedProduct.Product) { _outputReciever.WriteError($"Coupon with key '{key}' does not applies to that product."); return; } _cartService.AddProductDiscount(selectedProduct.Product, coupon.Value); _outputReciever.WriteInfo($"Coupon added. Discount to {selectedProduct.Product.Name} is {coupon.Value}%"); }
public void Execute() { _outputReciever.ClearScreen(); _outputReciever.WriteLine("Select item from cart to remove:"); _listManager.SetItems(_cartService.GetCartItems()); _listManager.SetItemToString(item => $"{item.Product.Name}, In cart: {item.Count}"); _listManager.PrintItems(); var selectedProduct = _listManager.GetSelectedItem(); if (selectedProduct.IsNull()) { _outputReciever.WriteError("You didn't select anything. Try again."); return; } _cartService.RemoveProduct(selectedProduct.Product); _outputReciever.WriteWarn($"Product '{selectedProduct.Product.Name}' successfully removed."); }
public void Execute() { _outputReciever.ClearScreen(); _outputReciever.Write("Enter your key: "); var key = _outputReciever.GetStringResponse(); if (key.IsNullOrWhiteSpace()) { _outputReciever.WriteError($"Entered key '{key}' does not conform our rules."); return; } var coupon = GetCouponByKey(key); if (coupon.IsNull()) { _outputReciever.WriteError($"Coupon with key '{key}' does not exists."); return; } _cartService.AddCartDiscount(coupon.Value); _outputReciever.WriteInfo($"Coupon added. Discount to cart is {coupon.Value}%"); }
public void Execute() { _outputReciever.ClearScreen(); _outputReciever.WriteInfo("Bye!"); throw new MenuExitException(); }