コード例 #1
0
        public static void Initialize(string userId, IUserService userService, CarPoolingEfContext context)
        {
            CurrentUserId = userId;

            UserService = userService;

            BookingService = new BookingService(context);

            CarServices = new CarServices(context);

            RideServices = new RideServices(context, BookingService);
        }
コード例 #2
0
        static void Main()
        {
            Console.Write(Constant.MainMenuOptions);
            MainMenu            option      = (MainMenu)Helper.ValidInteger();
            CarPoolingEfContext context     = new CarPoolingEfContext();
            IUserService        UserService = new UserService(context);

            switch (option)
            {
            case MainMenu.Login:
                try
                {
                    User user = UserService.Authentication(UserInput.GetCredential());
                    if (user != null)
                    {
                        AppService.Initialize(user.Id, UserService, context);
                        Menu menu = new Menu();
                        menu.UserMainMenu();
                    }
                    else
                    {
                        Console.WriteLine(Constant.InvalidCredentials);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }

                break;

            case MainMenu.Signup:
                UserService.AddNewUser(UserInput.NewUser(UserService));
                Main();

                break;

            case MainMenu.Exit:
                Environment.Exit(0);

                break;
            }
            Main();
        }