/// <summary> /// This method generate in the console a table-like format with all the order history of the store. /// </summary> /// <param name="myRepoLayer">Our Repository Layer to access into the Database.</param> private static void StoreOrdersHistory(P0_RLayer myRepoLayer) { bool bolUILocationSelected = true; int intLocationID = 0; do { Console.Write($"{myRepoLayer.ListEveryLocation()}\nSelect the LocationID to view the orders history: "); string strLocationID = Console.ReadLine(); intLocationID = myRepoLayer.LocationHistoryVerification(strLocationID); if (intLocationID != 0) { bolUILocationSelected = false; } else { Console.WriteLine("\t\tInvalid option\n"); } } while (bolUILocationSelected); Console.WriteLine(myRepoLayer.GetAllTheHistoryFromStore(intLocationID)); }
/// <summary> /// This method is for adding manually some products into the Store Inventory. If a product is already registered, it will link the already created product and add a /// new store inventory. /// </summary> /// <param name="myRepoLayer">Our Repository Layer to access into the Database.</param> private static void AddOrUpdateProductInventoryInLocation(P0_RLayer myRepoLayer) { bool bolUILocationSelected = true; int intLocationID = 0; do { Console.Write($"{myRepoLayer.ListEveryLocation()}\nSelect the LocationID to view the Inventory of the store : "); string strLocationID = Console.ReadLine(); intLocationID = myRepoLayer.LocationHistoryVerification(strLocationID); if (intLocationID != 0) { bolUILocationSelected = false; } else { Console.WriteLine("\t\tInvalid option\n"); } } while (bolUILocationSelected); bool bolUIInventory = true; do { //GetAllProductsFromInventory Console.Write($"\t\t\tInventory: \n{myRepoLayer.GetAllProductsFromInventory(intLocationID)}\n\nSelect the product to modify (Input A to add a new product):"); string strUIProductID = Console.ReadLine(); if (strUIProductID.ToLower() == "a") { // Add a new product string strName = "", strDescription = ""; double dblPrice = 0; int intQuantity = 0; Console.WriteLine("Name of the product: "); strName = Console.ReadLine(); Console.WriteLine("Description fo the product: "); strDescription = Console.ReadLine(); bool bolUIPriceAndQty = true; do { Console.WriteLine("The price for the product: "); if (!double.TryParse(Console.ReadLine(), out dblPrice)) { Console.WriteLine("Invalid Input\n"); continue; } else { bolUIPriceAndQty = false; } }while (bolUIPriceAndQty); bolUIPriceAndQty = true; do { Console.WriteLine("The quantity for the product: "); if (!int.TryParse(Console.ReadLine(), out intQuantity)) { Console.WriteLine("Invalid Input\n"); continue; } else { bolUIPriceAndQty = false; } }while (bolUIPriceAndQty); //Add the product into the inventory in the store intLocationID try { myRepoLayer.AddProductIntoStoreInventory(intLocationID, strName, strDescription, dblPrice, intQuantity); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } } else if (myRepoLayer.SearchProductWithID(strUIProductID)) { bool bolUIQuantity = true; do { Console.Write("Quantity: "); string strInventoryQuantity = Console.ReadLine(); int intQuantity = 0; /// if (!int.TryParse(strInventoryQuantity, out intQuantity)) { Console.WriteLine("\t\tInvalid input for quantity."); continue; } try { myRepoLayer.SetProductFromInventory(int.Parse(strUIProductID), intQuantity); bolUIQuantity = false; } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } } while (bolUIQuantity); } else { Console.WriteLine("Invalid input\n"); continue;// } if (ValidateIfUserWantToRedoAction("Add or update another product?: \nY/N", myRepoLayer)) { continue; } else //N { bolUIInventory = false; } } while (bolUIInventory); }