Пример #1
0
        static void Main(string[] args)
        {
            UsersList();
            //_menu.HomeScreen();

            while (true)
            {
                int menuChoice = _menu.LogInMenu();
                switch (menuChoice)
                {
                case 1:
                    Console.WriteLine("Enter username: "******"Enter password: "******"Enter your First Name: ");
                    string firstName = Console.ReadLine();
                    Console.WriteLine("Enter your Last Name: ");
                    string lastName = Console.ReadLine();
                    Console.WriteLine("Enter your userName: "******"Enter your password: "******"Enter your age: ");
                    int age = ValidationHelpers.TryParseNumber(Console.ReadLine(), 120);

                    var user = new User(firstName, lastName, nameUser, userPassword, age);

                    _currentUser = _userService.Register(user);
                    if (_currentUser == null)
                    {
                        MessageHelpers.Message("Unsuccesful registration please try again", ConsoleColor.Red);
                        Thread.Sleep(1500);
                        continue;
                    }
                    MessageHelpers.Message("You succesfully registered!", ConsoleColor.Green);
                    break;

                case 3:
                    Environment.Exit(0);
                    break;
                }

                bool isLoggedIn = true;
                while (isLoggedIn)
                {
                    Console.WriteLine($"Hi {_currentUser.FirstName} choose one of the following?");
                    int          choice          = _menu.MainMenu();
                    ActivityType currentActivity = (ActivityType)choice;
                    Console.Clear();
                    switch (choice)
                    {
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                        _activityServices.TrackingTime(currentActivity, _currentUser);
                        break;

                    case 5:
                        if (!ValidationHelpers.CheckIfListIsEmpty(_currentUser.ListOfActivities, "statistics"))
                        {
                            continue;
                        }
                        int statisticsMenu = _menu.StatisticsMenu();
                        _userService.UserStatistics(_currentUser, statisticsMenu);
                        break;

                    case 6:
                        int accountMenu = _menu.AccountMenu();
                        if (_userService.AccountSettings(_currentUser.Id, accountMenu, _currentUser))
                        {
                            isLoggedIn = !isLoggedIn;
                        }
                        break;

                    case 7:
                        isLoggedIn = !isLoggedIn;
                        break;

                    default:
                        break;
                    }
                }
            }
        }