Exemplo n.º 1
0
        static void Main(string[] args)
        {
            ILogger logger = LogManager.GetCurrentClassLogger();

            string jsonLocations = @"C:\revature\luigi_cupcakes_locations.json";
            string jsonCustomers = @"C:\revature\luigi_cupcakes_customers.json";
            string jsonOrders    = @"C:\revature\luigi_cupcakes_orders.json";

            LoadDataFromJSON(jsonLocations,
                             jsonCustomers,
                             jsonOrders,
                             out var storeLocations,
                             out var customers,
                             out var orders);

            Console.WriteLine("Welcome to Luigi's Cupcakes Manager");
            Console.WriteLine();
            Console.WriteLine("Please select from the following options (not case-sensitive):");

            while (true)
            {
                ConsoleDisplay.DisplayMenu();
                ConsoleRead.GetMenuInput(out var input);
                if (input == "S")
                {
                    GetDataAndAddLocation(jsonLocations, storeLocations);
                }
                else if (input == "C")
                {
                    GetDataAndAddCustomer(jsonCustomers, customers, storeLocations);
                }
                else if (input == "O")
                {
                    GetDataAndAddOrder(jsonLocations, jsonCustomers, jsonOrders,
                                       customers, storeLocations, orders);
                }
                else if (input == "SL")
                {
                    ConsoleDisplay.StoreList(storeLocations);
                }
                else if (input == "SO")
                {
                    ConsoleRead.StoreOrders(storeLocations);
                }
                else if (input == "CL")
                {
                    ConsoleDisplay.CustomerList(customers);
                }
                else if (input == "CS")
                {
                    ConsoleRead.CustomerSearch(customers);
                }
                else if (input == "CO")
                {
                    ConsoleRead.CustomerOrders(customers);
                }
                else if (input == "OL")
                {
                    ConsoleDisplay.OrderList(orders, storeLocations);
                }
                else if (input == "OR")
                {
                    ConsoleRead.OrderRecommended(customers, orders);
                }
                else if (input == "Q")
                {
                    break;
                }
            }
        }
Exemplo n.º 2
0
        /// <remarks>
        ///  The following command is the command in Package Manager Console to scaffold and re-scaffold the
        ///  database. I have had to do this 4-5 times already, so I have the command at the top of the
        ///  program so I can grab it.
        /// </remarks>
        // Scaffold-DbContext "<your-connection-string>"
        //      Microsoft.EntityFrameworkCore.SqlServer
        //      -Project <name-of-data-project>

        /// <remarks>
        ///  The following line of code is commented out so that the SQL logging does not interfere with
        ///  using the console. Once the console UI is replaced with a website, I plan on turning
        ///  the SQL logging to the console back on since there will no longer be a conflict.
        /// </remarks>
        /// <param name="args"></param>
        //public static readonly LoggerFactory AppLoggerFactory
        //    = new LoggerFactory(new[] { new ConsoleLoggerProvider((_, __) => true, true) });

        static void Main(string[] args)
        {
            NLog.ILogger logger = LogManager.GetCurrentClassLogger();

            var optionsBuilder = new DbContextOptionsBuilder <Project0Context>();

            optionsBuilder.UseSqlServer(SecretConfiguration.ConnectionString);
            //optionsBuilder.UseLoggerFactory(AppLoggerFactory);
            var options = optionsBuilder.Options;

            using (var dbContext = new Project0Context(options))
            {
                IProject0Repo p0Repo = new Project0Repo(dbContext);

                Console.WriteLine("Welcome to Matt's Cupcakes Manager");
                Console.WriteLine();
                Console.WriteLine("Please select from the following options (not case-sensitive):");

                while (true)
                {
                    ConsoleDisplay.DisplayMenu();
                    ConsoleRead.GetMenuInput(out var input);
                    if (input == "L")
                    {
                        GetDataAndAddLocation(p0Repo);
                    }
                    else if (input == "C")
                    {
                        GetDataAndAddCustomer(p0Repo);
                    }
                    else if (input == "O")
                    {
                        GetDataAndAddOrder(p0Repo);
                    }
                    else if (input == "LL")
                    {
                        ConsoleDisplay.LocationList(p0Repo);
                    }
                    else if (input == "LO")
                    {
                        ConsoleRead.LocationOrders(p0Repo);
                    }
                    else if (input == "CL")
                    {
                        ConsoleDisplay.CustomerList(p0Repo);
                    }
                    else if (input == "CS")
                    {
                        ConsoleRead.CustomerSearch(p0Repo);
                    }
                    else if (input == "CO")
                    {
                        ConsoleRead.CustomerOrders(p0Repo);
                    }
                    else if (input == "OD")
                    {
                        ConsoleRead.OrderDetails(p0Repo);
                    }
                    else if (input == "OL")
                    {
                        ConsoleDisplay.OrderList(p0Repo, p0Repo.GetAllOrders().ToList(),
                                                 p0Repo.GetAllOrderItems().ToList(),
                                                 p0Repo.GetAllCupcakes().ToList(), p0Repo.GetAllLocations().ToList());
                    }
                    else if (input == "OR")
                    {
                        ConsoleRead.OrderRecommended(p0Repo);
                    }
                    else if (input == "Q")
                    {
                        break;
                    }
                }
            }
        }