Exemplo n.º 1
0
        public ActionResult GuestsFor29()
        {
            Trace.WriteLine("GET /GuestsFor29");
            GuestLogic guestLogic = new GuestLogic();

            List <Guest> guests = guestLogic.GetGuestsFor29();

            return(View(guests));
        }
        /// <summary>
        /// Choose menu 'LogIn'
        /// </summary>
        public static void ChooseLogIn()
        {
            string name, password;

            GuestLogic = new GuestLogic();

            while (true)
            {
                Console.Clear();
                Print.PrintHeader("LOG IN", ConsoleColor.DarkYellow);

                name     = Print.ReadInput("\nEnter user email: ");
                password = Print.ReadInput("\nEnter password: "******"\nThere is no such user, check name or password!");
                    string input = Print.ReadInput("\n[1] Try again\nor enter any other key to return");
                    if (input != "1")
                    {
                        return;
                    }
                }
                else
                {
                    break;
                }
            }

            Console.Clear();
            if (UserLogic.GetAccountType().Equals("USER"))
            {
                UserActions.UserMode();
            }
            else
            {
                UserActions.AdminMode();
            }

            while (true)
            {
                Print.PrintHeader($"{UserLogic.GetAccountType()}: {UserLogic.GetAccountName()}", ConsoleColor.Green);

                UserActions.GetActions();

                string input = Console.ReadLine();
                Console.Clear();
                Print.PrintHeader($"{UserLogic.GetAccountType()}: {UserLogic.GetAccountName()}", ConsoleColor.Green);
                if (input.ToLower() == "q")
                {
                    UserLogic.LogOut();
                    break;
                }

                UserActions.ChooseAction(input);
            }
        }
Exemplo n.º 3
0
        public ReservationSystemForm(User user)
        {
            InitializeComponent();
            _user         = user;
            _eventRepo    = new EventLogic(new EventOracleContext());
            _guestRepo    = new GuestLogic(new GuestOracleContext());
            _locationRepo = new LocationLogic(new LocationOracleContext());

            _events = _eventRepo.GetAllEvents();

            cmbEvents.DataSource    = _events;
            cmbEvents.SelectedIndex = 0;
        }
Exemplo n.º 4
0
        public void Setup()
        {
            context = new Mock <IDataContext>();

            context.Setup(x => x.UsersList).Returns(
                new List <User>()
            {
                new User()
                {
                    Id           = 1,
                    Name         = "user1",
                    Email        = "*****@*****.**",
                    Password     = "******",
                    ShoppingCart = new ShoppingCart(),
                    OrderList    = new List <Order>()
                }
            });

            context.Setup(x => x.ProductsList).Returns(new List <Product>()
            {
                new Product()
                {
                    Category = Category.Phones,
                    Name     = "Samsung Galaxy A51",
                    Price    = 300,
                    Id       = 1
                },
                new Product()
                {
                    Category = Category.Phones,
                    Name     = "Xiaomi Redmi Note 9 Pro",
                    Price    = 290,
                    Id       = 2
                },
                new Product()
                {
                    Category = Category.Notebooks,
                    Name     = "Lenovo IdeaPad 330",
                    Price    = 350,
                    Id       = 3
                }
            });

            guest = new GuestLogic(context.Object);
            user  = new UserLogic(context.Object);
            guest.LogIn(context.Object.UsersList[0].Email, context.Object.UsersList[0].Password);
        }
Exemplo n.º 5
0
        public ActionResult Create(Guest guest)
        {
            Trace.WriteLine("POST /GUEST");
            if (ModelState.IsValid)
            {
                Trace.WriteLine("ModelState valid");
                GuestLogic logic = new GuestLogic();

                logic.AddGuestFor29(guest);

                Trace.WriteLine("RedirectingToIndex");
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(guest));
            }
        }
Exemplo n.º 6
0
        public void Setup()
        {
            context = new Mock <IDataContext>();
            context.Setup(x => x.UsersList).Returns(new List <User>()
            {
                new User()
                {
                    Id           = 1,
                    Name         = "user1",
                    Email        = "*****@*****.**",
                    Password     = "******",
                    ShoppingCart = new ShoppingCart(),
                    OrderList    = new List <Order>()
                }
            });

            context.Setup(x => x.AdminsList).Returns(new List <Admin>()
            {
                new Admin()
                {
                    Id           = 1,
                    Name         = "admin",
                    Email        = "*****@*****.**",
                    Password     = "******",
                    ShoppingCart = new ShoppingCart(),
                    OrderList    = new List <Order>()
                }
            });

            context.Setup(x => x.ProductsList).Returns(new List <Product>()
            {
                new Product()
                {
                    Category = Category.Phones,
                    Name     = "Samsung Galaxy A51",
                    Price    = 300,
                    Id       = 1
                }
            });

            guest = new GuestLogic(context.Object);
        }
        /// <summary>
        /// Choose menu 'Register'
        /// </summary>
        public static void Register()
        {
            GuestLogic = new GuestLogic();
            string name, email, password, input;

            while (true)
            {
                Console.Clear();
                Print.PrintHeader("REGISTER", ConsoleColor.DarkYellow);

                name = Print.ReadInput("\nEnter your name (at least 3 characters): ");
                if (!ParseInput.IsCorrectName(name))
                {
                    Console.WriteLine("\nIncorrect name!");
                    input = Print.ReadInput("\n[1] Try again\nor enter any other key to return");
                    if (input != "1")
                    {
                        return;
                    }
                    else
                    {
                        continue;
                    }
                }

                email = Print.ReadInput("\nEnter user email (*****@***): ");
                if (!ParseInput.IsCorrectEmail(email))
                {
                    Console.WriteLine("\nIncorrect email!");
                    input = Print.ReadInput("\n[1] Try again\nor enter any other key to return");
                    if (input != "1")
                    {
                        return;
                    }
                    else
                    {
                        continue;
                    }
                }

                password = Print.ReadInput("\nEnter password (at least 3 characters): ");
                if (!ParseInput.IsCorrectPassword(password))
                {
                    Console.WriteLine("\nIncorrect password!");
                    input = Print.ReadInput("\n[1] Try again\nor enter any other key to return");
                    if (input != "1")
                    {
                        return;
                    }
                    else
                    {
                        continue;
                    }
                }
                if (!GuestLogic.Register(name, email, password))
                {
                    Console.WriteLine("\nUser with this email already exists!");
                    input = Print.ReadInput("\n[1] Try again\nor enter any other key to return");
                    if (input != "1")
                    {
                        return;
                    }
                }
                else
                {
                    break;
                }
            }

            GuestLogic.LogIn(email, password);

            Console.Clear();
            if (UserLogic.GetAccountType().Equals("USER"))
            {
                UserActions.UserMode();
            }
            else
            {
                UserActions.AdminMode();
            }

            while (true)
            {
                Print.PrintHeader($"{UserLogic.GetAccountType()}: {UserLogic.GetAccountName()}", ConsoleColor.Green);

                UserActions.GetActions();

                input = Console.ReadLine();
                Console.Clear();
                Print.PrintHeader($"{UserLogic.GetAccountType()}: {UserLogic.GetAccountName()}", ConsoleColor.Green);
                if (input.ToLower() == "q")
                {
                    UserLogic.LogOut();
                    break;
                }

                UserActions.ChooseAction(input);
            }
        }