Esempio n. 1
0
        static void Main(string[] args)
        {
            Customers cu1 = new Customers(100, "Prathee", "Mysore", 8976543219);
            Customers cu2 = new Customers(101, "Thanu", "Bangalore", 7275643219);
            Customers cu3 = new Customers(102, "Savitha", "Pune", 9987123095);

            CustomerManager mgr = new CustomerManager();

            mgr.AddCustomer(cu1);
            mgr.AddCustomer(cu2);
            mgr.AddCustomer(cu3);
            mgr.GetAllCustomers();
            mgr.UpdateCustomer(100);
            mgr.GetAllCustomers();
            //string c= Console.ReadLine();
            //string del= mgr.DeleteCustomer(c);
            mgr.DeleteCustomer(100);

            string k = Console.ReadLine();

            Customers[] temp = mgr.FindCustomer(k);
            foreach (var item in temp)
            {
                Console.WriteLine(item.CustomerID);
                Console.WriteLine(item.CustomerName);
                Console.WriteLine(item.CustomerAddress);
                Console.WriteLine(item.CustomerNumber);
            }
        }
        static void Main(string[] args)
        {
            var customerDbManager    = new CustomerManager(Configuration);
            var deliverymanDbManager = new DeliverymanManager(Configuration);
            var deliveryDbManager    = new DeliveryManager(Configuration);
            var orderDbManager       = new OrderManager(Configuration);
            var cityDbManager        = new CityManager(Configuration);

            Console.WriteLine("Customer [C], Deliveryman [D]");
            string customerDeliverymanChoice = Console.ReadLine();


            if (customerDeliverymanChoice == "C")
            {
                Console.WriteLine("Already registered [1], New registration [2]");
                string registrationChoice = Console.ReadLine();
                if (registrationChoice == "1")
                {
                    Console.WriteLine("Username");
                    string usernameC = Console.ReadLine();


                    Console.WriteLine("Password");
                    string passwordC = Console.ReadLine();

                    int idCustomerTryingToConnect = customerDbManager.GetIdCustomer(usernameC);

                    //En fonction de l'id du customer
                    while (passwordC != customerDbManager.GetPassword(idCustomerTryingToConnect, usernameC))
                    {
                        Console.WriteLine(passwordC);
                        Console.WriteLine("Connection denied. Try again");

                        Console.WriteLine("Username");
                        usernameC = Console.ReadLine();

                        Console.WriteLine("Password");
                        passwordC = Console.ReadLine();

                        idCustomerTryingToConnect = customerDbManager.GetIdCustomer(usernameC);
                    }

                    Console.WriteLine("Connection successful");

                    Program.Suite(idCustomerTryingToConnect);
                }
                else
                {
                    Console.WriteLine("New registration !");

                    Console.WriteLine("Name : ");
                    string nameNewCustomer = Console.ReadLine();
                    Console.WriteLine("Lastname : ");
                    string lastNameNewCustomer = Console.ReadLine();
                    Console.WriteLine("City : ");
                    string cityNewCustomer = Console.ReadLine();
                    Console.WriteLine("ZIP : ");
                    string zipNewCustomer = Console.ReadLine();
                    int    idCity         = cityDbManager.GetIdCity(cityNewCustomer.ToLower(), zipNewCustomer);
                    if (idCity == 0)
                    {
                        cityDbManager.AddCity(new City {
                            Name = cityNewCustomer, Zip_code = int.Parse(zipNewCustomer)
                        });
                        idCity = cityDbManager.GetIdCity(cityNewCustomer.ToLower(), zipNewCustomer);
                    }
                    Console.WriteLine("Address : ");
                    string addressNewCustomer = Console.ReadLine();
                    Console.WriteLine("Login : "******"Password : "******"Congratulations, your account has been created ! You can now start ordering food !");

                    int idNewCustomer = customerDbManager.GetIdCustomer(LoginNewCustomer);
                    Program.Suite(idNewCustomer);
                }
            }
            else
            {
                Console.WriteLine("Welcome to the delivery management");

                Console.WriteLine("Username");
                string usernameDM = Console.ReadLine();

                Console.WriteLine("Password");
                string passwordDM = Console.ReadLine();

                int idDeliverymanTryingToConnect = deliverymanDbManager.GetIdDeliveryman(usernameDM);

                //En fonction de l'id du customer
                while (passwordDM != deliverymanDbManager.GetPassword(idDeliverymanTryingToConnect, usernameDM))
                {
                    Console.WriteLine("Connection denied. Try again");

                    Console.WriteLine("Username");
                    usernameDM = Console.ReadLine();

                    Console.WriteLine("Password");
                    passwordDM = Console.ReadLine();
                }

                Console.WriteLine("Connection successful");

                Console.WriteLine("Which delivery have you done ? Insert the ID");

                var deliverys = deliveryDbManager.GetAllDelivery(idDeliverymanTryingToConnect); //En fonction de l'id du deliveryman
                foreach (var delivery in deliverys)
                {
                    Console.WriteLine(delivery.ToString());
                }

                string deliveryDone = Console.ReadLine();
                Console.WriteLine("Thank you ! The delivery " + deliveryDbManager.GetDelivery(int.Parse(deliveryDone)) + " has been successfully executed");
                //deliveryDbManager.changeStatusDeliveryToDone(idDelivery);
            }
        }