public void Start() { do { Cart cart = cartServices.GetCartByCustId(customer.Id); List <CartItem> ci = cartItemServices.GetAllCartItemsByCartId(cart.Id); Console.WriteLine("These are the items in your cart"); foreach (CartItem item in ci) { Sticks stick = productServices.GetProductByStickId(item.stickId); Console.WriteLine($"{stick.description} \t${stick.Price}"); } Console.WriteLine("Welcome to check out! If there is anything you forget go back otherwise proceed to checkout. Thank you for Shopping with us."); Console.WriteLine("[0] Back \n[2] Checkout"); custInput = Console.ReadLine(); switch (custInput) { case "0": break; case "2": CheckOutItems(); break; default: ValidInvalidServices.InvalidInput(); break; } } while (!(custInput.Equals("0"))); }
public Customer CustomerValidation() { string filepath = "../lacrosseDB/DBFiles/Customer.txt"; Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.File(filepath, rollingInterval: RollingInterval.Day) .CreateLogger(); string email; Customer cust = new Customer(); Console.WriteLine("Enter email"); email = Console.ReadLine(); try { cust = customerServices.GetCustomerByEmail(email); if (cust.email != email) { throw new System.ArgumentException(); } else { customer = cust; Log.Information($"{cust.email} has signed in"); CustMenu custMenu = new CustMenu(customer, context); try { cartServices.DeleteCart(cartServices.GetCartByCustId(customer.Id)); } catch (InvalidOperationException) { } finally { Cart newCart = new Cart(); newCart.custId = customer.Id; cartServices.AddCart(newCart); custMenu.Start(); } } } catch (ArgumentException) { Log.Information($"Customer {cust.email} tried and failed to login."); ValidInvalidServices.InvalidInput(); } catch (InvalidOperationException) { Log.Information($"Customer tried to sign into an account the DNE."); ValidInvalidServices.InvalidInput(); } return(cust); }
public void Start() { do { Inventory selected = inventoryServices.GetItemByLocIdStickId(customer.LocationId, stick.Id); inventoryQuantity = selected.quantity; Console.WriteLine("The item you have selected: "); Console.WriteLine($"{stick.description} \t${stick.Price}"); Console.WriteLine("Would you like to add this item to cart?"); Console.WriteLine("[0] No \n[1] Yes"); custInput = Console.ReadLine(); switch (custInput) { case "0": break; case "1": int quantity; do { Console.WriteLine("How many would you like of this item?"); quantity = Int32.Parse(Console.ReadLine()); } while (ValidInvalidServices.InvalidQuanityOfItems(inventoryQuantity, quantity) == false); CartItem ci = new CartItem(); Cart custCart = cartServices.GetCartByCustId(customer.Id); ci.cartId = custCart.Id; ci.stickId = stick.Id; ci.quantity = quantity; cartItemServices.AddCartItem(ci); Console.WriteLine("Your item has been added to your cart"); break; default: ValidInvalidServices.InvalidInput(); break; } } while (!(custInput.Equals("1"))); }