Beispiel #1
0
        /**
         * Kontroler do drugiego menu, po zalogowaniu
         **/
        public CalendarController(User user)
        {
            this.user = user;
            while (true)
            {
                var mainView = new MainView();
                mainView.user  = user;
                mainView.score = GetFromDB.GetScore(user);
                mainView.Show();
                switch (mainView.Selected)
                {
                case 0:     //add
                    if (AddActivity())
                    {
                        Back.Clear();
                        string s      = "Activity added";
                        int    middle = (Console.WindowWidth - s.Length) / 2;
                        Console.SetCursorPosition(middle, Console.CursorTop);
                        Console.WriteLine(s);
                    }
                    else
                    {
                        Back.Clear();
                        string s      = "Something goes wrong, activity not added";
                        int    middle = (Console.WindowWidth - s.Length) / 2;
                        Console.SetCursorPosition(middle, Console.CursorTop);
                        Console.WriteLine(s);
                    }
                    break;

                case 1:     //search
                    var search = Search.Choose();
                    if (search == 0)
                    {
                        Back.Clear();
                        break;
                    }
                    var searchlist = GetSearchList(search);
                    if ((searchlist == null) || (searchlist.Count == 0))
                    {
                        Search.Empty();
                    }
                    else
                    {
                        var searchactivitiesController = new ActivitiesController(searchlist);
                    }
                    break;

                case 2:     //show
                    var activitiesController = new ActivitiesController(GetFromDB.LoadList(user));
                    break;

                case 3:     //logout
                    user = null;
                    Logout.Done();
                    return;

                case 4:     //changegoal
                    Goal.GetValues();
                    if (Check.CheckGoal(user, Goal.Newgoal))
                    {
                        Goal.Done();
                    }
                    else
                    {
                        Goal.BadValue();
                    }
                    break;

                case 5:     //setdivider
                    var whichdivider = Divider.WhichDivider();
                    if (whichdivider == 0)
                    {
                        Back.Clear();
                        break;
                    }
                    Divider.GetValues();
                    switch (whichdivider)
                    {
                    case 1:
                        if (Check.CheckBikeDivider(user, Divider.Divide))
                        {
                            Divider.Done();
                        }
                        else
                        {
                            Divider.BadValue();
                        }
                        break;

                    case 2:
                        if (Check.CheckSwimDivider(user, Divider.Divide))
                        {
                            Divider.Done();
                        }
                        else
                        {
                            Divider.BadValue();
                        }
                        break;
                    }
                    break;

                case 6:     //changepassword
                    ChangePassword.Change();
                    if (Check.CheckPassword(user, ChangePassword.Password, ChangePassword.Repassword))
                    {
                        ChangePassword.Done();
                    }
                    else
                    {
                        ChangePassword.WrongData();
                    }
                    break;

                case 7:     //Show values
                    Values.ShowValues(user, GetFromDB.GetScore(user), GetFromDB.GetNumberOfActivities(user), GetFromDB.GetLastDate(user));
                    Back.Clear();
                    break;

                case 8:     //exit
                    Environment.Exit(0);
                    break;

                default:
                    break;
                }
            }
        }