Esempio n. 1
0
        public int GetRoutineId()
        {
            _informationProvider.ShowSingleMessage("Choose Day of a week: ");

            var informationToShowList = new List <string>();

            _routineService.Items.ForEach(routine => informationToShowList.Add($"{routine.Id} - {routine.Name}"));
            _informationProvider.ShowMultipleInformation(informationToShowList);

            var id = _informationProvider.GetNumericInputKey();

            return(id);
        }
Esempio n. 2
0
        public int AddNewExercise()
        {
            var addNewExerciseMenu = _actionService.GetMenuActionsByMenuName("AddNewExerciseMenu");


            var menuActionsToShow = new List <string>();

            addNewExerciseMenu.ForEach(menuAction => menuActionsToShow.Add($"{menuAction.Id}. {menuAction.Name}"));

            _informationProvider.ShowMultipleInformation(menuActionsToShow);

            bool isValidInput = false;
            int  typeId       = 0;

            while (!isValidInput)
            {
                _informationProvider.ShowSingleMessage("Please select exercise type:");

                typeId = _informationProvider.GetNumericInputKey();

                isValidInput = typeId != 0 && typeId <= menuActionsToShow.Count;
            }

            isValidInput = false;
            string name = string.Empty;

            while (!isValidInput)
            {
                _informationProvider.ShowSingleMessage("\nPlease insert name for item: ");

                name = _informationProvider.GetInputString();

                isValidInput = !string.IsNullOrWhiteSpace(name);
            }

            var lastId = _exerciseService.GetLastId();

            var exercise = new Exercise(lastId + 1, name, typeId);

            _exerciseService.AddItem(exercise);

            return(exercise.Id);
        }