Exemple #1
0
        public static void WriteInventory(int marker)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            IConfigurationRoot configuration = builder.Build();

            var optionsBuilder = new DbContextOptionsBuilder <Project1Context>();

            optionsBuilder.UseSqlServer(configuration.GetConnectionString("Project1"));

            var repo = new PizzaRepos(new Project1Context(optionsBuilder.Options));

            List <LocationInventory> inventories = repo.GetInventories();

            Console.WriteLine($"\nLocation Name: {inventories[marker].LocationName}" +
                              $"\nDough: {inventories[marker].Dough}" +
                              $"\nAnchovies: {inventories[marker].Anchovies}" +
                              $"\nBacon: {inventories[marker].Bacon}" +
                              $"\nChicken: {inventories[marker].Chicken}" +
                              $"\nMushrooms: {inventories[marker].Mushrooms}" +
                              $"\nOlives: {inventories[marker].Olives}" +
                              $"\nOnions: {inventories[marker].Onions}" +
                              $"\nPepperoni: {inventories[marker].Pepperoni}" +
                              $"\nPeppers: {inventories[marker].Peppers}" +
                              $"\nSalami: {inventories[marker].Salami}" +
                              $"\nSausage: {inventories[marker].Sausage}");
        }
Exemple #2
0
        public static void WritePizzaOrder(int marker)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            IConfigurationRoot configuration = builder.Build();

            var optionsBuilder = new DbContextOptionsBuilder <Project1Context>();

            optionsBuilder.UseSqlServer(configuration.GetConnectionString("Project1"));

            var repo = new PizzaRepos(new Project1Context(optionsBuilder.Options));

            List <PizzaOrder> pizzaOrders = repo.GetPizzaOrders();
            List <string>     toppings;

            toppings = new List <string> {
            };
            foreach (var item in pizzaOrders[marker].PizzaOrderToppings)
            {
                toppings.Add(item.ToppingName.ToString());
            }

            Console.WriteLine($"Customer Name: {pizzaOrders[marker].Customer.CustomerName}" +
                              $"\nLocation Name: {pizzaOrders[marker].Location.LocationName}" +
                              $"\nPizza Size: {pizzaOrders[marker].Pizza.PizzaSize}" +
                              $"\nPizza Crust: {pizzaOrders[marker].Pizza.PizzaCrust}" +
                              $"\nPizza Toppings: {string.Join(", ", toppings.ToArray())}" +
                              $"\nOrder Quantity: {pizzaOrders[marker].PizzaQuantity}" +
                              $"\nOrder Cost: {pizzaOrders[marker].OrderCost}" +
                              $"\nOrder Time: {pizzaOrders[marker].OrderTime}\n");
        }