示例#1
0
        public static TourGuide LogIn(TourGuide tg)
        {
            Project0RepoLayer p0Context = new Project0RepoLayer(); // create the context here to acceess it in all methods of this class                Console.Clear();
            Validator         validator = new Validator();

            Console.Clear();
            Console.Write("Great to see you again! You can quit to the main menu by entering '-2'. Enter your unique username: "******"-2")
            {
                tg.Result = validator.InputConstraints(tg.Result);
                User user = p0Context.FindUser(tg.Result);
                if (user == null)
                {
                    Console.Clear();
                    Console.WriteLine("We were not able to locate that user.\nWe will return you to the previous screen. Press enter to continue: ");
                    Console.ReadLine();
                    tg.Result = "0";
                }
                else
                {
                    List <string> acceptable = new List <string> {
                        "-1", "-2", "3", "4", "5", "6"
                    };
                    tg = new TourGuide($"Welcome {user.Username}!\n", "What would you like to do?\n\n3. View Floor\n4. Book a tour\n5. View Past Tours\n6. View Paintings\n\n\n-2. Logout\n-1. Quit Out", "0", acceptable, user);
                    return(tg);
                }
            }

            return(tg);
        }
示例#2
0
        public static TourGuide InitLogin(TourGuide tg)
        {
            Project0RepoLayer p0Context = new Project0RepoLayer();     // create the context here to acceess it in all methods of this class                Console.Clear();
            Validator         validator = new Validator();
            string            tmpCheckString;
            bool tmpCheck = true;

            string un = "0";
            string fn = "0";
            string ln = "0";           //usr/first/last name

            Console.WriteLine("We need some information before we start:");
            while (tg.Result != "-2")
            {
                //prompt for input
                Console.Write("\nEnter a unique name: ");
                un = validator.InputConstraints(Console.ReadLine());
                Console.Write("\nEnter your first name: ");
                fn = (Console.ReadLine());
                Console.Write("\nEnter your last name: ");
                ln = validator.InputConstraints(Console.ReadLine());

                if (un == "0" || fn == "0" || ln == "0")
                {
                    Console.WriteLine("Looks like you've inputted an incorrect format. We will take you back to the main menu. Press enter to continue.");
                    Console.ReadLine();
                    return(tg);
                }

                //confirm user create
                do
                {
                    Console.Clear();
                    Console.WriteLine($"Creating user with: \nUsername - {un}\tFirst Name - {fn}\tLast Nmae - {ln}");
                    Console.Write("\n\n\nEnter y to create this user and log in. Enter n to go back to the main menu: ");
                    tmpCheckString = Console.ReadLine();
                    if (tmpCheckString == "y")
                    {
                        User          user       = p0Context.CreateUser(un, fn, ln);
                        List <string> acceptable = new List <string> {
                            "-1", "-2", "3", "4", "5", "6", "7"
                        };
                        tg       = new TourGuide($"Welcome {user.Username}!", "What would you like to do?\n\n3. View Floor\n4. Book a tour\n5. View All Paintings\n6. View Past Tours\n\n\n-2. Logout\n-1. Quit Out", "-2", acceptable, user);
                        tmpCheck = true;
                    }
                    else if (tmpCheckString == "n")
                    {
                        tg        = new TourGuide();
                        tg.Result = "-2";
                        tmpCheck  = true;
                    }
                    else
                    {
                        tmpCheck = false;
                    }
                }while(!tmpCheck);
            }
            return(tg);
        }
示例#3
0
        public static TourGuide TourGuideHelper(TourGuide tg)
        {
            Project0RepoLayer p0Context = new Project0RepoLayer(); // create the context here to acceess it in all methods of this class

            switch (tg.Result)
            {
            case "-1":
                Console.Clear(); tg.Words = "Thank you for your stay at the abstract museum!";
                break;

            case "-2":
                Console.Clear();
                Console.WriteLine("Logging you out and taking you back to the main screen. Press enter to continue");
                Console.ReadLine();
                tg        = new TourGuide();
                tg.Result = "0";
                return(tg);

            case "1":
                tg = InitLogin(tg);
                break;

            case "2":
                tg = LogIn(tg);
                break;

            case "3":
                ViewFloor();
                break;

            case "4":
                ViewFloorTour(tg.User);
                break;

                    #nullable enable
            case "5":
                IEnumerable <FloorTourUsrLine>?usrTours = p0Context.GetUsersPastTour(tg.User);
                if (usrTours != null)
                {
                    Console.Clear();
                    IEnumerable <FloorTourUsrLine> uT = (IEnumerable <FloorTourUsrLine>)usrTours;
                    int count = 0;
                    foreach (var ut in uT)
                    {
                        Tour?t = p0Context.FindTour(ut.TourID);
                        if (t != null)
                        {
                            Tour tour = (Tour)t;
                            Console.WriteLine($"\n{++count}. Floor name: {t.LocationCodeName} - At row number:{t.RowNum}\tOn Date: {ut.TourTakenAt}");
                        }
                    }
                    Console.WriteLine("Press enter to continue");
                    Console.ReadLine();
                }
                break;
                    #nullable disable


            case "6":
                ViewAllPaintingsHelper();
                break;



            case "Admin":


                Validator validator = new Validator();
                Console.Write("Enter floor name: "); string     floorName  = Console.ReadLine();
                Console.Write("Enter floor size (max 7):"); int?floorSize  = validator.ValidateStringToInt(Console.ReadLine()) !;
                Console.Write("Enter floor size: "); int?       totalTours = validator.ValidateStringToInt(Console.ReadLine()) !;

                if (floorSize != null && totalTours != null)
                {
                    int x = (int)floorSize;
                    int y = (int)totalTours;
                    p0Context.DBCreateBaseFloor(floorName, x, y);
                }
                break;
            }
            return(tg);
        }