public static void Show() { IngredientController controller = new IngredientController(); IngredientsDataAcess ingredient = new IngredientsDataAcess(); Console.Write("Ingredient ID:\n"); int id = Int32.Parse(Console.ReadLine()); ingredient = controller.FindById(id); Console.WriteLine(ingredient.ToString()); Console.WriteLine($"New name: (leave blank for no change) ({ingredient.Name})"); string name = Console.ReadLine(); if (!String.IsNullOrEmpty(name)) { ingredient.Name = name; } Console.WriteLine($"New stock quantity: (leave blank for no change) ({ingredient.Stock})"); string stockStr = Console.ReadLine(); if (!String.IsNullOrEmpty(stockStr)) { int stock = Int32.Parse(stockStr); ingredient.Stock = stock; } controller.Update(ingredient); Console.WriteLine("\nIngredient updated!\n"); Console.ReadKey(); ClearHelper.Clear(); }
public static void Show() { IngredientsDataAcess ingredient = new IngredientsDataAcess(); Console.Write("Ingredient ID:\n"); int id = Int32.Parse(Console.ReadLine()); IngredientController controller = new IngredientController(); controller.Delete(id); Console.WriteLine("\nIngredient deleted!\n"); Console.ReadKey(); ClearHelper.Clear(); }
public static void ShowForm() { IngredientsDataAcess ingredient = new IngredientsDataAcess(); Console.Write("Ingrediente Name:\n"); ingredient.Name = Console.ReadLine(); Console.Write("Quantity in Stock:\n"); ingredient.Stock = Int32.Parse(Console.ReadLine()); IngredientController controller = new IngredientController(); controller.Save(ingredient); Console.WriteLine("\nIngredient saved!\n"); Console.ReadKey(); ClearHelper.Clear(); }
private static void SearchById() { ClearHelper.Clear(); Console.WriteLine("Ingredients Search\n"); Console.WriteLine("Search by ID:"); int id = Int32.Parse(Console.ReadLine()); Console.WriteLine("\nFetching Data, please wait..."); IngredientsDataAcess ingredient = controller.FindById(id); Console.WriteLine(); if (ingredient == null) { Console.WriteLine($"There is no Ingredient with this Id"); } else { Console.WriteLine(ingredient.ToString()); } Console.ReadKey(); ClearHelper.Clear(); }
public static void ShowForm() { PizzasDataAcess pizza = new PizzasDataAcess(); Console.Write("Pizza Name:\n"); pizza.Name = Console.ReadLine(); Console.Write("Pizza Price:\n"); pizza.Price = Decimal.Parse(Console.ReadLine()); Console.WriteLine("Retrieving Ingredients, please wait...\n"); IngredientController ingredientController = new IngredientController(); List <IngredientsDataAcess> ingredientsList = ingredientController.getAll(); string option = ""; do { Console.WriteLine(); //Show all Ingredientes foreach (IngredientsDataAcess ingredient in ingredientsList) { Console.WriteLine($"Ingredient ID: {ingredient.Id} - {ingredient.Name}"); } Console.WriteLine("\nd - Done"); Console.Write("\nIngredient ID:\n"); option = Console.ReadLine(); int ingredientId = 0; //if is integer if (int.TryParse(option, out ingredientId)) { IngredientsDataAcess ingredientSearch = ingredientController.FindById(ingredientId); //If Ingredient exists with this ID if (ingredientSearch != null) { pizza.PizzasIngredients.Add(new PizzasIngredientsDataAcess() { IngredientId = ingredientSearch.Id }); } //Not existis ingredients else { Console.WriteLine("Invalid ID!"); Console.ReadKey(); ClearHelper.Clear(); } } //Not Integer, if is option d else if (option != "d") { Console.WriteLine("Wrong Id or \"d\" for done"); Console.ReadKey(); ClearHelper.Clear(); } } while (option != "d"); PizzaController controller = new PizzaController(); controller.Save(pizza); Console.WriteLine("\nPizza saved!\n"); Console.ReadKey(); ClearHelper.Clear(); }