Пример #1
0
        /**
         * dodawanie aktywnosci
         **/
        private bool AddActivity()
        {
            var type = GetFromUser.GetTypeFromUser();

            if (type == null)
            {
                return(false);
            }

            var d_date = GetFromUser.GetDateFromUser();

            if (d_date == null)
            {
                return(false);
            }
            DateTime date = d_date.Value;

            var d_distance = GetFromUser.GetDistanceFromUser();

            if (d_distance == null)
            {
                return(false);
            }
            var distance = d_distance.Value;

            var note = GetFromUser.GetNoteFromUser();

            if (note == "esc")
            {
                return(false);
            }

            return(SaveDB.AddActivityToDB(user, type, distance, date, note));
        }
Пример #2
0
        /**
         * Wyszukiwanie
         * Ten sam mechanizm co przy dodawaniu
         **/
        private List <Models.Activity> GetSearchList(int search)
        {
            var activities = new List <Models.Activity>();

            switch (search)
            {
            case 1:     //date
                DateTime?d_date = GetFromUser.GetDateFromUser();
                if (d_date == null)
                {
                    return(null);
                }
                DateTime date = d_date.Value;
                activities = SearchDB.SearchDate(date, user);
                break;

            case 2:     //type
                var type = GetFromUser.GetTypeFromUser();
                if (type == null)
                {
                    return(null);
                }
                activities = SearchDB.SearchType(type, user);
                break;

            case 3:     //distance
                var d_distance = GetFromUser.GetDistanceFromUser();
                if (d_distance == null)
                {
                    return(null);
                }
                var distance = d_distance.Value;
                activities = SearchDB.SearchDistance(distance, user);
                break;

            case 4:     //note
                var note = GetFromUser.GetNoteFromUser();
                if (note == "esc")
                {
                    return(null);
                }
                activities = SearchDB.SearchNote(note, user);
                break;
            }
            return(activities);
        }
Пример #3
0
        /**
         * Kotroler do wyswietlania i edycji aktywnosci
         **/

        public ActivitiesController(List <Activity> activities)
        {
            Back.Clear();
            Activities = activities;
            var stringactivitiesList = new List <string>();

            while (true)
            {
                /**
                 * Tutaj, bo przy edycji musi sie zaktualizowac,
                 * wiec za kazdym razem trzeba czyscic i tworzyc liste stringow na nowo
                 **/
                stringactivitiesList.Clear();
                stringactivitiesList.Add("Back");
                foreach (var activity in Activities)
                {
                    stringactivitiesList.Add(activity.ToString());
                }
                /** END  **/

                var mainView = new MainView(stringactivitiesList);
                if (mainView.Selected == 0) //back
                {
                    Back.Clear();
                    return;
                }

                var info            = new Info();
                var currentactivity = Activities[mainView.Selected - 1];
                info.ShowValue(currentactivity); //wyswietl dane o wybranej aktywnosci
                switch (info.Selected)
                {
                case 0:
                    //edit
                    switch (Edit.Choose())
                    {
                    case 0:         //back
                        Back.Clear();
                        break;

                    case 1:         //type
                        if (SaveDB.SaveEditType(currentactivity, GetFromUser.GetTypeFromUser()))
                        {
                            Edit.Done();
                        }
                        else
                        {
                            Edit.Error();
                        }
                        break;

                    case 2:         //distance
                        if (SaveDB.SaveEditDistance(currentactivity, GetFromUser.GetDistanceFromUser()))
                        {
                            Edit.Done();
                        }
                        else
                        {
                            Edit.Error();
                        }
                        break;

                    case 3:         //date
                        if (SaveDB.SaveEditDate(currentactivity, GetFromUser.GetDateFromUser()))
                        {
                            Edit.Done();
                        }
                        else
                        {
                            Edit.Error();
                        }
                        break;

                    case 4:         //note
                        if (SaveDB.SaveEditNote(currentactivity, GetFromUser.GetNoteFromUser()))
                        {
                            Edit.Done();
                        }
                        else
                        {
                            Edit.Error();
                        }
                        break;
                    }
                    break;

                case 1:     //delete
                    if (SaveDB.DeleteActivity(currentactivity, Activities))
                    {
                        Delete.Deleted();
                        currentactivity = null;
                    }
                    else
                    {
                        Delete.Error();
                    }
                    break;

                case 2:     //back
                    Back.Clear();
                    break;
                }
            }
        }