public void TrackingTime(ActivityType activity, User user, IUserService <User> userService)
        {
            Console.Clear();
            switch (activity)
            {
            case ActivityType.Reading:
                var reading = new Reading();
                reading.TrackTime();
                Console.WriteLine("Please enter how many pages you've read and what kind Of book you were reading:");
                Console.Write("Pages: ");
                reading.Pages    = ValidationHelpers.ParseNumber(Console.ReadLine(), int.MaxValue);
                reading.BookType = (BookType)menus.ShowBookTypes();
                reading.Id       = user.Id;

                user.ListOfActivities.Add(reading);
                userService.AddActivity(user, reading, user.ReadingActivities);

                MessageHelepers.Message("Activity is succesfully tracked!", ConsoleColor.Green);
                break;

            case ActivityType.Exercising:
                var exercising = new Exercising();
                exercising.TrackTime();
                Console.WriteLine("Please enter what kind of workout did you do");
                exercising.ExercisingType = (ExercisingType)menus.ShowExercisingTypes();

                user.ListOfActivities.Add(exercising);
                userService.AddActivity(user, exercising, user.ExercisingActivities);

                MessageHelepers.Message("Activity is succesfully tracked!", ConsoleColor.Green);
                break;

            case ActivityType.Working:
                var working = new Working();
                working.TrackTime();
                Console.WriteLine("Where were you working from?");
                working.WorkingFrom = (WorkingFrom)menus.ShowWorkingOptions();

                user.ListOfActivities.Add(working);
                userService.AddActivity(user, working, user.WorkingActivities);

                MessageHelepers.Message("Activity is succesfully tracked!", ConsoleColor.Green);
                break;

            case ActivityType.OtherHobbies:
                var otherHobbies = new OtherHobbies();
                otherHobbies.TrackTime();
                Console.WriteLine("Please enter the name of the hobby");
                otherHobbies.Hobby = Console.ReadLine();

                user.ListOfActivities.Add(otherHobbies);
                userService.AddActivity(user, otherHobbies, user.OtherHobbiesActivities);

                MessageHelepers.Message("Activity is succesfully tracked!", ConsoleColor.Green);
                break;

            default:
                break;
            }
        }
예제 #2
0
 public UserService()
 {
     _database    = new FileDatabase <T>();
     reading      = new Reading();
     exercising   = new Exercising();
     working      = new Working();
     otherHobbies = new OtherHobbies();
 }
 public void InsertOtherHobbies(OtherHobbies otherHobbie)
 {
     _otherHobbiesDb.InsertActivity(otherHobbie);
 }
        public void Tracking(ActivityType activity, User user)
        {
            switch (activity)
            {
            case ActivityType.Reading:
                var reading = new Reading();
                reading.TrackTimeSpendDoingActivity();
                user.TotalHoursReading.Add(reading.TRackedTime.TotalSeconds);
                Console.WriteLine("What kind of book did you read");
                reading.BookType = (BookType)menus.ShowReadingTypes();
                var readlino = Console.ReadLine();
                user.FavoriteTypeBook.Add(readlino);
                Console.WriteLine("And how many pages:");
                reading.Pages = int.Parse(Console.ReadLine());
                user.Activities.Add(reading);
                _userDb.UpdateUser(user);
                Console.WriteLine("Added...");
                Console.ReadLine();
                Console.Clear();
                break;

            case ActivityType.Puzzles:
                var puzzles = new Puzzles();
                puzzles.TrackTimeSpendDoingActivity();
                user.TotalHoursPuzzles.Add(puzzles.TRackedTime.TotalSeconds);
                Console.WriteLine("What kind of Puzzle did you do?");
                puzzles.PuzzlesType = (PuzzlesType)menus.ShowPuzzlesTypes();
                var readlines = Console.ReadLine();
                user.FavoriteTypePuzzle.Add(readlines);
                user.Activities.Add(puzzles);
                _userDb.UpdateUser(user);
                Console.WriteLine("Your information has been added to your statistics!");
                Console.ReadLine();
                Console.Clear();
                break;

            case ActivityType.Watching:
                var watching = new Watching();
                watching.TrackTimeSpendDoingActivity();
                user.TotalHoursWatching.Add(watching.TRackedTime.TotalSeconds);
                Console.WriteLine("What were you watching?");
                watching.WatchingType = (WatchingType)menus.ShowWatchingTypes();
                var readline = Console.ReadLine();
                user.FavoriteTypToWatch.Add(readline);
                user.Activities.Add(watching);
                _userDb.UpdateUser(user);
                Console.WriteLine("Your information has been added to your statistics!");
                Console.Clear();
                break;

            case ActivityType.OtherHobbies:
                var otherhobbies = new OtherHobbies();
                otherhobbies.TrackTimeSpendDoingActivity();
                user.TotalHoursOtherHobbies.Add(otherhobbies.TRackedTime.TotalSeconds);
                Console.WriteLine("Please enter what hobby were you doing");
                otherhobbies.Hobby = Console.ReadLine();
                user.Activities.Add(otherhobbies);
                _userDb.UpdateUser(user);
                Console.WriteLine("Your information has been added to your statistics!");
                Console.ReadLine();
                Console.Clear();
                break;

            default:
                break;
            }
        }
예제 #5
0
        static void Main(string[] args)
        {
            while (true)
            {
                Console.Clear();
                int registerOrLoginChoise = _menus.LogInOrRegisterMenu();
                while (true)
                {
                    if (registerOrLoginChoise == 1)
                    {
                        _user = _userService.LogIn();
                        if (_user == null)
                        {
                            Environment.Exit(0);
                        }
                        break;
                    }
                    else
                    {
                        Console.Clear();
                        _user = _userService.Register();
                        if (_user == null)
                        {
                            continue;
                        }
                        break;
                    }
                }
                Console.Clear();
                bool mainMenu = true;
                while (mainMenu)
                {
                    Console.Clear();
                    switch (_menus.MainMenu())
                    {
                    case 1:
                        //Track time
                        bool breakTrackMenu = true;
                        while (breakTrackMenu)
                        {
                            Console.Clear();
                            switch (_menus.TrackMenu())
                            {
                            case 1:
                                //Reading
                                Reading reading = new Reading();
                                reading.Stopwatch = _activitiesService.ActivityTime("reading");
                                MessageHelper.Color("Please enter number of pages that you have read", ConsoleColor.Green);
                                reading.Pages = ValidationHelper.ParsedNumber(Console.ReadLine());
                                switch (_menus.ReadingMenu())
                                {
                                case 1:
                                    reading.Type = Db.Enums.ReadingType.BellesLettres;
                                    break;

                                case 2:
                                    reading.Type = Db.Enums.ReadingType.Fiction;
                                    break;

                                case 3:
                                    reading.Type = Db.Enums.ReadingType.ProfessionalLiterature;
                                    break;
                                }
                                _readingService.InsertReading(reading);

                                MessageHelper.Color($"Mr.{_user.LastName} you have been reading for {reading.Stopwatch.Elapsed.Seconds} seconds and you read {reading.Pages} pages from the book that has genre {reading.Type}", ConsoleColor.Yellow);
                                Thread.Sleep(3000);
                                break;

                            case 2:
                                //Excercising
                                Exercising exercise = new Exercising();
                                exercise.Stopwatch = _activitiesService.ActivityTime("exercising");
                                switch (_menus.ExerciseMenu())
                                {
                                case 1:
                                    exercise.ExcercisingType = Db.Enums.ExcercisingType.General;
                                    break;

                                case 2:
                                    exercise.ExcercisingType = Db.Enums.ExcercisingType.Running;
                                    break;

                                case 3:
                                    exercise.ExcercisingType = Db.Enums.ExcercisingType.Sport;
                                    break;
                                }
                                _exercisingService.InsertExercise(exercise);
                                MessageHelper.Color($"Mr.{_user.LastName} you have been doing {exercise.ExcercisingType} exercise for {exercise.Stopwatch.Elapsed.Seconds}seconds", ConsoleColor.Yellow);
                                Thread.Sleep(3000);
                                break;

                            case 3:
                                //Working
                                Working working = new Working();
                                working.Stopwatch = _activitiesService.ActivityTime("working");
                                switch (_menus.WorkingMenu())
                                {
                                case 1:
                                    working.WorkingFrom = Db.Enums.WorkingFrom.Office;
                                    break;

                                case 2:
                                    working.WorkingFrom = Db.Enums.WorkingFrom.Home;
                                    break;
                                }
                                _workingService.InsertWork(working);
                                MessageHelper.Color($"Mr.{_user.LastName} you have been working from {working.WorkingFrom} for {working.Stopwatch.Elapsed.Seconds} seconds", ConsoleColor.Yellow);
                                Thread.Sleep(3000);
                                break;

                            case 4:
                                //Other Hobbies
                                OtherHobbies otherHobbie = new OtherHobbies();
                                MessageHelper.Color("It's nice to try something new. What's the name of the new Hobby?", ConsoleColor.Green);
                                otherHobbie.Name      = Console.ReadLine();
                                otherHobbie.Stopwatch = _activitiesService.ActivityTime(otherHobbie.Name);
                                _otherHobbiesService.InsertOtherHobbies(otherHobbie);
                                MessageHelper.Color($"Mr.{_user.LastName} you have been doing your new hobbie {otherHobbie.Name} for {otherHobbie.Stopwatch.Elapsed.Seconds} seconds", ConsoleColor.Yellow);
                                Thread.Sleep(3000);
                                break;

                            case 5:
                                MessageHelper.Color("Going back to Main Menu!", ConsoleColor.Green);
                                Thread.Sleep(2000);
                                breakTrackMenu = false;
                                break;
                            }
                        }
                        break;

                    case 2:
                        //Statistics
                        bool breakStatsMenu = true;
                        while (breakStatsMenu)
                        {
                            Console.Clear();
                            switch (_menus.StatsMenu())
                            {
                            case 1:
                                //Reading Stats
                                _readingService.Statistics();
                                MessageHelper.Color("Press any key to go back", ConsoleColor.Red);
                                Console.ReadLine();
                                break;

                            case 2:
                                //Exercising stats
                                _exercisingService.Statistics();
                                MessageHelper.Color("Press any key to go back", ConsoleColor.Red);
                                Console.ReadLine();
                                break;

                            case 3:
                                //Working stats
                                _workingService.Statistics();
                                MessageHelper.Color("Press any key to go back", ConsoleColor.Red);
                                Console.ReadLine();
                                break;

                            case 4:
                                //OtherHobbies stats
                                _otherHobbiesService.Statistics();
                                MessageHelper.Color("Press any key to go back", ConsoleColor.Red);
                                Console.ReadLine();
                                break;

                            case 5:
                                //Global stats
                                List <int> globalList = new List <int>
                                {
                                    _exercisingService.TotalSeconds(),
                                           _otherHobbiesService.TotalSeconds(),
                                           _readingService.TotalSeconds(),
                                           _workingService.TotalSeconds()
                                };
                                int favoriteActivity = globalList.Max();
                                Console.WriteLine($"Total activity time: {_activitiesService.TotalActivityTime(globalList)}seconds");
                                if (favoriteActivity != 0)
                                {
                                    if (favoriteActivity == _exercisingService.TotalSeconds())
                                    {
                                        Console.WriteLine("Favorite activity: Exercise");
                                    }
                                    else if (favoriteActivity == _otherHobbiesService.TotalSeconds())
                                    {
                                        Console.WriteLine("Favorite activity: Hobbie");
                                    }
                                    else if (favoriteActivity == _readingService.TotalSeconds())
                                    {
                                        Console.WriteLine("Favorite activity: Reading");
                                    }
                                    else
                                    {
                                        Console.WriteLine("Favorite activity: Working");
                                    }
                                }
                                else
                                {
                                    Console.WriteLine("You don't have favorite activity yet");
                                }
                                MessageHelper.Color("Press any key to go back", ConsoleColor.Red);
                                Console.ReadLine();
                                break;

                            case 6:
                                MessageHelper.Color("Going back to Main Menu!", ConsoleColor.Green);
                                Thread.Sleep(2000);
                                breakStatsMenu = false;
                                break;
                            }
                        }
                        break;

                    case 3:
                        //Acc Management
                        bool accMng = true;
                        while (accMng)
                        {
                            Console.Clear();
                            switch (_menus.AccManagement())
                            {
                            case 1:
                                //change password
                                Console.Clear();
                                Console.WriteLine($"Mr. {_user.LastName}, please enter new password");
                                _userService.ChangePassword(_user.Id, _user.Password, Console.ReadLine());
                                break;

                            case 2:
                                //change First and Last Name
                                Console.Clear();
                                Console.WriteLine("Please enter new First name");
                                string firstName = Console.ReadLine();
                                Console.WriteLine("Please enter new Last name");
                                string lastName = Console.ReadLine();
                                _userService.ChangeInfo(_user.Id, firstName, lastName);
                                break;

                            case 3:
                                Console.Clear();
                                _userService.RemoveUser(_user.Id);
                                Console.WriteLine("Deactivating the account. Thank you for using our service");
                                Styles.Spiner();
                                MessageHelper.Color("The account has been deactivated", ConsoleColor.Red);
                                mainMenu = false;
                                break;

                            case 4:
                                MessageHelper.Color("Going back to Main Menu!", ConsoleColor.Green);
                                Thread.Sleep(2000);
                                accMng = false;
                                break;
                            }
                        }
                        break;

                    case 4:
                        _user = null;
                        MessageHelper.Color("Thank you for using our application! Have a good day!", ConsoleColor.Green);
                        mainMenu = false;
                        break;
                    }
                }
            }
        }