Example #1
0
        static void Main(string[] args)
        {
            var firstLetter  = Console.ReadLine();
            var invoiceQuery = new InvoiceQuery();
            var invoices     = invoiceQuery.GetInvoiceByTrackFirstLetter(firstLetter);

            foreach (var invoice in invoices)
            {
                Console.WriteLine("Invoices Id: {0} was shipped to {1}", invoice.InvoiceId, invoice.BillingAddress);
            }

            var invoiceModifier = new InvoiceModifier();

            invoiceModifier.Delete(9);

            Console.ReadLine();
        }
Example #2
0
        static void Main(string[] args)
        {
            // takes user input
            var firstLetter = Console.ReadLine();

            // querying database
            var invoiceQuery = new InvoiceQuery();
            var invoices     = invoiceQuery.GetInvoiceByTrackFirstLetter(firstLetter);

            // prints output to console
            foreach (var invoice in invoices)
            {
                Console.WriteLine($"Invoice Id {invoice.InvoiceId} was shipped to {invoice.BillingAddress}.");
            }

            var invoiceModifier = new InvoiceModifier();

            invoiceModifier.Delete(9);

            Console.ReadLine();
        }
Example #3
0
        static void Main(string[] args)
        {
            var run = true;

            while (run)
            {
                cki userInput = MainMenu();

                switch (userInput.KeyChar)
                {
                case '0':
                    run = false;
                    break;

                case '1':

                    Console.Clear();
                    Console.WriteLine("Enter in an Employee ID # (1-5)");
                    var invoiceQuery = new AgentInvoiceQuery();

                    var employeeId = Console.ReadLine();

                    var agentInvoiceQuery = new AgentInvoiceQuery();
                    var agentsInvoices    = agentInvoiceQuery.GetInvoiceByEmployeeId(employeeId);

                    foreach (var invoice in agentsInvoices)
                    {
                        Console.WriteLine($"Sales Agent: {invoice.SalesAgent} --- Invoices Id: {invoice.InvoiceId}");
                    }
                    Console.WriteLine("Press enter to continue.");
                    Console.ReadLine();
                    break;

                case '2':

                    Console.Clear();

                    var allInvoicesQuery = new AgentInvoiceQuery();
                    agentsInvoices = allInvoicesQuery.GetInvoiceData();

                    foreach (var invoice in agentsInvoices)
                    {
                        Console.WriteLine($"Sales Agent: {invoice.SalesAgent}" +
                                          $" Customer: {invoice.CustomerName}" +
                                          $" Total: {invoice.Total}" +
                                          $" Billing Country: {invoice.BillingCountry}");
                    }
                    Console.WriteLine("Press enter to continue.");
                    Console.ReadLine();
                    break;

                case '3':

                    Console.Clear();

                    Console.WriteLine("Enter an Invoice ID for how many line items are on that invoice.");
                    var inputId = Console.ReadLine();

                    var lineItemsQuery   = new InvoiceLineItemQuery();
                    var countOfLineItems = lineItemsQuery.GetInvoiceLineItems(int.Parse(inputId));

                    Console.WriteLine($"For {inputId} there are {countOfLineItems} line items.");
                    Console.ReadLine();
                    break;

                case '4':

                    Console.Clear();

                    Console.WriteLine("Enter new customer ID number.");
                    var enteredCustomerId = int.Parse(Console.ReadLine());

                    Console.WriteLine("Enter new customer's billing address");
                    var enteredBillingAddress = Console.ReadLine();

                    var invoiceModifier = new InvoiceModifier();
                    var result          = invoiceModifier.AddInvoice(enteredCustomerId, enteredBillingAddress);

                    if (result)
                    {
                        Console.WriteLine("New invoice added.");
                    }

                    Console.WriteLine("Press enter to continue.");
                    Console.ReadLine();
                    break;

                case '5':
                    Console.Clear();

                    Console.WriteLine("Enter the ID of an Emplyee you're wanting to change.");
                    var enteredEmployeeId = int.Parse(Console.ReadLine());
                    var employeeModifier  = new EmployeeModifier();

                    Console.WriteLine("Enter The new name for this employee");

                    var enteredEmployeeName = Console.ReadLine();
                    result = employeeModifier.UpdateEmployeeName(enteredEmployeeId, enteredEmployeeName);

                    if (result)
                    {
                        Console.WriteLine("Employee updated.");
                    }

                    Console.WriteLine("press enter to continue.");
                    Console.ReadLine();
                    break;
                }
            }


            cki MainMenu()
            {
                View mainMenu = new View()
                                .AddMenuOption("Show invoices by sales agent ID.")
                                .AddMenuOption("Show ALL the invoice data")
                                .AddMenuOption("Show number of invoice line items for an invoice ID")
                                .AddMenuOption("Add new invoice item")
                                .AddMenuOption("Update or change an employee's name.")
                                .AddMenuText("Press [0] to quit application");

                Console.Write(mainMenu.GetFullMenu());
                cki userOption = Console.ReadKey();

                return(userOption);
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            var invoiceQuery  = new InvoiceQuery();
            var modifyInvoice = new InvoiceModifier();

            Console.WriteLine("Please make a selection");
            Console.WriteLine("1: Invoice Listing By Agent\n" +
                              "2: Invoice Detail Listing\n" +
                              "3: Invoice Lineitem Count by Invoice Id\n" +
                              "4: Add New Invoice\n" +
                              "5: Update Employee Name");

            var input = int.Parse(Console.ReadLine());

            if (input == 1)
            {
                // -- Invoices By Agent -- //
                var employeeInvoices = invoiceQuery.GetInvoicesBySalesAgent();
                var agentGroups      = from employee in employeeInvoices
                                       group employee.InvoiceId by employee.EmployeeFullName into a
                                       select new { agent = a.Key, invoices = a.ToList() };

                foreach (var agent in agentGroups)
                {
                    Console.WriteLine($"Invoices for: {agent.agent}");
                    foreach (int invoice in agent.invoices)
                    {
                        Console.WriteLine($"{invoice} ");
                    }
                }
                // -------------------- //
            }
            else if (input == 2)
            {
                // -- Invoice Detail -- //
                var invoiceDetail = invoiceQuery.GetInvoiceDetail();
                foreach (var invoice in invoiceDetail)
                {
                    Console.WriteLine($"{invoice.InvoiceId} - {invoice.Total}: {invoice.CustomerName}, Agent: {invoice.EmployeeFullName}");
                }
                // ------------------- //
            }
            else if (input == 3)
            {
                // -- Invoice Line Item Count -- //
                Console.WriteLine("Enter an invoice id for lookup");
                var number = int.Parse(Console.ReadLine());
                var invoiceLineItemCount = invoiceQuery.InvoiceLineItemCount(number);
                Console.WriteLine($"Line items in invoice {number}: {invoiceLineItemCount}");
                // ---------------------------- //
            }
            else if (input == 4)
            {
                // -- Add New Invoice -- //
                Console.WriteLine("Enter Customer ID");
                var custId = int.Parse(Console.ReadLine());

                Console.WriteLine("Enter Customer Billing Address");
                var billingAddr = Console.ReadLine();

                Console.WriteLine("Enter Customer Billing City");
                var billingCity = Console.ReadLine();

                Console.WriteLine("Enter Customer Billing State");
                var billingState = Console.ReadLine();

                Console.WriteLine("Enter Customer Billing Country");
                var billingCountry = Console.ReadLine();

                Console.WriteLine("Enter Customer Billing Postal Code");
                var billingPost = Console.ReadLine();

                Console.WriteLine("Enter Customer Invoice Total");
                var invoiceTotal = double.Parse(Console.ReadLine());

                modifyInvoice.NewInvoice(custId, billingAddr, billingCity, billingState, billingCountry, billingPost, invoiceTotal);
            }
            else if (input == 5)
            {
                Console.WriteLine("Enter Employee Id");
                var empId = int.Parse(Console.ReadLine());
                Console.WriteLine("Enter Updated First Name");
                var fName = Console.ReadLine();
                Console.WriteLine("Enter Updated Last Name");
                var lName = Console.ReadLine();

                modifyInvoice.updateEmployee(empId, fName, lName);
            }
            else
            {
                Console.WriteLine($"{input} is not a valid selection");
            }
            Console.ReadKey();
        }
Example #5
0
        static void Main(string[] args)
        {
            var run = true;

            while (run)
            {
                ConsoleKeyInfo userInput = MainMenu();

                switch (userInput.KeyChar)
                {
                case '0':
                    run = false;
                    break;

                case '1':
                    Console.Clear();
                    var invoiceQuery = new InvoiceQuery();

                    var invoices       = invoiceQuery.GetInvoicesBySalesRep();
                    var invoiceDetails = invoiceQuery.GetInvoiceDetails();

                    Console.WriteLine("Here are all of the invoice IDs associated with their sales reps");

                    foreach (var invoice in invoices)
                    {
                        Console.WriteLine($"Sales Rep: {invoice.Name}, Invoice ID: {invoice.InvoiceId}");
                    }
                    Console.WriteLine("press enter to continue.");
                    Console.ReadLine();
                    break;

                case '2':
                    Console.Clear();
                    Console.WriteLine("Here are all of the invoices with their totals, and some other shit");

                    invoiceQuery   = new InvoiceQuery();
                    invoices       = invoiceQuery.GetInvoicesBySalesRep();
                    invoiceDetails = invoiceQuery.GetInvoiceDetails();

                    foreach (var detail in invoiceDetails)
                    {
                        Console.WriteLine($"Total: {detail.Total}, Sales Rep: {detail.SalesAgent}, Billing Country: {detail.BillingCountry}, Customer Name: {detail.CustomerName}");
                    }
                    Console.WriteLine("press enter to continue.");
                    Console.ReadLine();
                    break;

                case '3':
                    Console.Clear();
                    Console.WriteLine("Please enter in an invoice ID to see the total number of line items for that invoice.");
                    var invoiceInput = Console.ReadLine();
                    invoiceQuery = new InvoiceQuery();
                    var lineItems = invoiceQuery.GetInvoiceLineItems(int.Parse(invoiceInput));
                    Console.WriteLine($"There are {lineItems} line items for invoice ID {invoiceInput}");
                    Console.WriteLine("press enter to continue.");
                    Console.ReadLine();
                    break;

                case '4':
                    Console.Clear();
                    Console.WriteLine("Please enter your address to create a new invoice.");
                    var userAddress = Console.ReadLine();
                    Console.WriteLine("What is the customerID for this invoice?");
                    var customerID      = Console.ReadLine();
                    var invoiceModifier = new InvoiceModifier();
                    var createInvoice   = invoiceModifier.AddNewInvoice(userAddress, int.Parse(customerID));
                    if (createInvoice)
                    {
                        Console.WriteLine("Congratulations, you created a new invoice!");
                    }
                    Console.WriteLine("press enter to continue.");
                    Console.ReadLine();
                    break;

                case '5':
                    Console.Clear();
                    Console.WriteLine("Please enter the Employee ID whose name you would like to change.");
                    var employeeId = Console.ReadLine();
                    Console.WriteLine("What would you like to change their name to?");
                    var newName          = Console.ReadLine();
                    var employeeModifier = new EmployeeModifier();
                    var changeName       = employeeModifier.UpdateEmployee(int.Parse(employeeId), newName);
                    if (changeName)
                    {
                        Console.WriteLine($"Congratulations, you updated the name of employee ID {employeeId} to {newName}!");
                    }
                    Console.WriteLine("press enter to continue.");
                    Console.ReadLine();
                    break;
                }
            }

            ConsoleKeyInfo MainMenu()
            {
                View mainMenu = new View()
                                .AddMenuOption("Show invoices associated with each sales agent.")
                                .AddMenuOption("See invoice data for all invoices.")
                                .AddMenuOption("See number of invoice line items for each invoice.")
                                .AddMenuOption("Add anew invoice.")
                                .AddMenuOption("Update an employee name.")
                                .AddMenuText("Press 0 to exit.");

                Console.Write(mainMenu.GetFullMenu());
                ConsoleKeyInfo userOption = Console.ReadKey();

                return(userOption);
            }
        }