public static Manager MapManagerToE(Logic.Manager manager)
 {
     return(new Manager
     {
         ManagerId = manager.ManagerId,
         FirstName = manager.FirstName,
         LastName = manager.LastName,
         Email = manager.Email,
         Password = manager.Password
     });
 }
Ejemplo n.º 2
0
        public void ManagerTest()
        {
            Logic.Manager manager = new Logic.Manager
            {
                ManagerId = 1,
                FirstName = "Sam",
                LastName  = "Lin",
                Email     = "123@321",
                Password  = "******"
            };

            Assert.Equal(1, manager.ManagerId);
            Assert.Equal("Sam", manager.FirstName);
            Assert.Equal("Lin", manager.LastName);
            Assert.Equal("123@321", manager.Email);
            Assert.Equal("4321", manager.Password);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get All Manager Info
        ///</summary>
        ///<param name="Logic.Manager password"></param>

        public async Task <Logic.Manager> GetManager(int pass)
        {
            var entityManager = await _context.Manager.FirstAsync(m => m.ManagerId == pass);


            if (entityManager == null)
            {
                throw new InvalidOperationException();
            }
            else
            {
                var CheckedManager = new Logic.Manager()
                {
                    managerID = entityManager.ManagerId,
                    firstName = entityManager.FirstName,
                    lastName  = entityManager.LastName,
                };
                return(CheckedManager);
            }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            /// <summary>
            /// Entity Framework Logger
            /// Used To store any runtime error of the app
            /// </summary>
            Log.Logger = new LoggerConfiguration().WriteTo.File(@"C:\revature\phat-project0\Project0-Log\Log.txt").CreateLogger();
            Log.Information("Begin Program");

            bool menu = true; //flag = true;

            StoreApp.Logic.Customer getCustomer = new Logic.Customer();
            StoreApp.Logic.Store    getStore    = new Logic.Store();
            StoreApp.Logic.Order    inputOrder  = new Logic.Order();

            using var context = new StoreAppContext();

            Console.WriteLine("Hello Welcome To The ABC's Grocery Store");
            string userInput;
            string userChoice;

            Console.WriteLine("Are you:\n1. Manager\n2. Customer");
            userInput = Console.ReadLine();

            /// <summary>
            /// Try catch handle
            /// Used to catch non number error inputs
            /// </summary>
            try
            {
                userChoice = UserChoiceHandler.UserOptionHandler(Int32.Parse(userInput), 2);
            }
            catch (FormatException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Are you:\n1. Manager\n2. Customer");
                userChoice = Console.ReadLine();
            }
            if (userChoice == null)
            {
                Console.WriteLine("Are you:\n1. Manager\n2. Customer");
                userChoice = Console.ReadLine();
            }


            while (menu == true)
            {
                if (userChoice == "1") //Manager
                {
                    string managerID;
                    Console.WriteLine("Enter Your Password (Number Only): ");
                    managerID = Console.ReadLine();
                    StoreApp.Logic.Manager getManagerInfo = new Logic.Manager();
                    try
                    {
                        getManagerInfo = getDB.GetManagerDataFromId(Int32.Parse(managerID), context);
                    }
                    catch (FormatException e)
                    {
                        Console.WriteLine(e.Message + " Number ONLY");
                        menu = false;
                    }

                    if (getManagerInfo is null)
                    {
                        Console.WriteLine("Incorrect Password. Please Try It Again\n");
                        userChoice = "1";
                    }

                    else
                    {
                        if (getDB.CheckIDParsable(getManagerInfo.managerID))
                        {
                            try
                            {
                                Console.WriteLine("Welcome back, " + getManagerInfo.firstName + " " + getManagerInfo.lastName);
                                Console.WriteLine("Manager's Options:");
                                Console.WriteLine("1. View Order History Of A Store\n2. Add New Items To Stores\n3. Search User Information By Name \n4. Switch To Customer Menu\n5.Stop");
                                int    manOpt        = Int32.Parse(Console.ReadLine());
                                string managerChoice = UserChoiceHandler.UserOptionHandler(manOpt, 5);
                                if (managerChoice == null)
                                {
                                    Console.WriteLine("1. View Order History Of A Store\n2. Add New Items To Stores\n3. Search User Information By Name \n4. Switch To Customer Menu \n5.Stop");
                                    manOpt        = Int32.Parse(Console.ReadLine());
                                    managerChoice = UserChoiceHandler.UserOptionHandler(manOpt, 5);
                                }
                                if (manOpt == 1 || manOpt == 2 || manOpt == 3)
                                {
                                    Menu.ManagerMenu(context, manOpt);
                                }
                                else if (manOpt == 4)
                                {
                                    Console.WriteLine("Are you:\n1. Manager\n2. Customer");
                                    userInput  = Console.ReadLine();
                                    userChoice = UserChoiceHandler.UserOptionHandler(Int32.Parse(userInput), 2);
                                }
                                else if (manOpt == 5)
                                {
                                    Console.Clear();
                                    Console.WriteLine("See You Later. Please Press Any Key To Stop");
                                    menu = false;
                                }
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine("There Is An Error. Please Try It Again " + e.Message);
                            }
                        }
                    }
                }
                else if (userChoice == "2") //Customer
                {
                    //Will run code to make new customer, list of customer info, and place orders
                    Console.WriteLine("1. Sign Up  \n2. Login \n3. Exit to start menu \n4. Stop");
                    userChoice = Console.ReadLine();
                    try
                    {
                        userInput = UserChoiceHandler.UserOptionHandler(Int32.Parse(userChoice), 4);
                    }
                    catch (FormatException e)
                    {
                        Console.WriteLine(e.Message);
                        Console.WriteLine("1. Sign Up  \n2. Login \n3. Exit to start menu \n4. Stop");
                        userChoice = Console.ReadLine();
                    }
                    if (userInput == null)
                    {
                        Console.WriteLine("1. Sign Up  \n2. Login \n3. Exit to start menu \n4. Stop");
                        userChoice = Console.ReadLine();
                    }


                    if (userChoice == "3")
                    {
                        Console.WriteLine("Are you:\n1. Manager\n2. Customer");
                        userInput  = Console.ReadLine();
                        userChoice = UserChoiceHandler.UserOptionHandler(Int32.Parse(userInput), 2);
                    }
                    else if (userChoice == "4")
                    {
                        Console.Clear();
                        Console.WriteLine("See You Later. Please Press Any Key To Stop");
                        menu = false;
                    }
                    else if (userChoice == "1" || userChoice == "2")
                    {
                        Menu.CustomerMenu(context, Int32.Parse(userChoice));
                    }
                }
            }
        }