Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Seed();

            while (true)
            {
                if (_currentUser == null)
                {
                    int loginChoice = _uiService.LogInMenu();
                    if (loginChoice == 1)
                    {
                        int      roleChoice = _uiService.RoleMenu();
                        UserRole role       = (UserRole)roleChoice;
                        Console.Clear();
                        Console.WriteLine("Enter username:"******"Enter password:"******"Enter first name:");
                        newUser.FirstName = Console.ReadLine();
                        Console.WriteLine("Enter last name:");
                        newUser.LastName = Console.ReadLine();
                        Console.WriteLine("Enter username:"******"Enter password:"******"Train":
                    int trainChoice = 1;
                    if (_currentUser.Role == UserRole.Premium)
                    {
                        trainChoice = _uiService.TrainMenu();
                    }
                    if (trainChoice == 1)
                    {
                        int           trainingItem = _uiService.TrainMenuItems(_videoTrainings.GetTrainings());
                        VideoTraining training     = _videoTrainings.GetTrainings()[trainingItem - 1];
                        Console.WriteLine(training.Title);
                        Console.WriteLine($"Link: {training.Link}");
                        Console.WriteLine($"Raiting: {training.CheckRating()}");
                        Console.WriteLine($"Time: {training.Time} minutes");
                        Console.ReadLine();
                    }
                    if (trainChoice == 2)
                    {
                        int          trainingItem = _uiService.TrainMenuItems(_liveTrainings.GetTrainings());
                        LiveTraining training     = _liveTrainings.GetTrainings()[trainingItem - 1];
                        Console.WriteLine(training.Title);
                        Console.WriteLine($"THE TRAINING STARTS AT: {training.NextSession}");
                        Console.WriteLine($"Raiting: {training.CheckRating()}");
                        Console.WriteLine($"Time: {training.Time} minutes");
                        Console.ReadLine();
                    }
                    break;

                case "Upgrade to Premium":
                    _uiService.UpgradeToPremium();
                    break;

                case "Reschedule Training":
                    List <LiveTraining> trainings = _liveTrainings.GetTrainings().Where(x => x.Trainer.Id == _currentUser.Id).ToList();
                    if (trainings.Count == 0)
                    {
                        Console.WriteLine("No Trainings!");
                        Console.ReadLine();
                    }
                    else
                    {
                        int trainingChoice = _uiService.ChooseEntitiesMenu(trainings);
                        Console.WriteLine("How many days do you want to reschedule the training:");
                        int days = ValidationHelper.ValidateNumber(Console.ReadLine(), 100);
                        _trainerUserSrvc.GetById(_currentUser.Id).ChangeSchedule(trainings[trainingChoice - 1], days);
                        Console.WriteLine("Schedule changed!");
                        Console.ReadLine();
                    }
                    break;

                case "Account":
                    int accountChoice = _uiService.AccountMenu(_currentUser.Role);
                    if (accountChoice == 1)
                    {
                        //Change Info
                        Console.WriteLine("Enter new First Name:");
                        string firstName = Console.ReadLine();
                        Console.WriteLine("Enter new Last Name:");
                        string lastName = Console.ReadLine();
                        switch (_currentUser.Role)
                        {
                        case UserRole.Standard:
                            _standardUserSrvc.ChangeInfo(_currentUser.Id, firstName, lastName);
                            break;

                        case UserRole.Premium:
                            _premiumUserSrvc.ChangeInfo(_currentUser.Id, firstName, lastName);
                            break;

                        case UserRole.Trainer:
                            _trainerUserSrvc.ChangeInfo(_currentUser.Id, firstName, lastName);
                            break;
                        }
                    }
                    else if (accountChoice == 2)
                    {
                        //CheckSubscription
                        Console.WriteLine($"Your subscription is : {_currentUser.Role}");
                        Console.ReadLine();
                    }
                    else if (accountChoice == 3)
                    {
                        // Change Password
                        Console.WriteLine("Enter old password:"******"Enter new password:"******"Log Out":
                    _currentUser = null;
                    break;

                default:
                    break;
                }
            }
        }