コード例 #1
0
ファイル: ProgramLoop.cs プロジェクト: jakubgerlee/courseApp
        public void Execute()
        {
            AddCommandsToDictionary();

            while (true)
            {
                ConsoleWriteHelper.CommandListText();

                Console.Write("Comand ");
                CommandLines = Console.ReadLine();

                if (commandDictionary.ContainsKey(CommandLines))
                {
                    foreach (var any in commandDictionary)
                    {
                        if (any.Key.Equals(CommandLines))
                        {
                            any.Value.Invoke();
                        }
                    }
                    CommandLines = "";
                }
                else
                {
                    while (!commandDictionary.ContainsKey(CommandLines))
                    {
                        ConsoleWriteHelper.CommandListText();
                        Console.WriteLine("Niewłaściwe polecenie!");
                        Console.Write("Wybierz dostepna komende: ");
                        CommandLines = Console.ReadLine();
                    }
                }
            }
        }
コード例 #2
0
ファイル: ProgramLoop.cs プロジェクト: jakubgerlee/courseApp
        } //metoda do sprawdzania czy pesel istnieje w bazie

        private void AddNewCourse()
        {
            var courseDto = new CourseDto();

            courseDto.CourseTitle       = ConsoleReadHelper.GetCourseName("np: C#_SII_20170424_JB " + "/n Tytul kursu: ");
            courseDto.Teacher           = ConsoleReadHelper.GetString("Nazwa prowadzacego: ");
            courseDto.DateStart         = ConsoleReadHelper.GetDate("Data rozpoczecia: ");
            courseDto.HomeworkThreshold = ConsoleReadHelper.GetInt("Prog dla prac domowych[%]: ");
            courseDto.PresenceThreshold = ConsoleReadHelper.GetInt("Prog dla obecnosci[%]: ");
            int noStudent = ConsoleReadHelper.GetInt("Liczba Studentów: ");

            courseDto.StudentDtosList = new List <StudentDto>();

            var succes = false;
            int i      = 0;

            do
            {
                //try
                //{

                var pesel = ConsoleReadHelper.GetLong("Podaj pesel studenta: ");
                // var success = _courseService.CheckIfStudentExists(pesel);
                var success = _studentService.GetStudentByPesel(pesel);

                if (success != null)
                {
                    var students = _courseService.GetStudentFromDl(pesel);
                    //student jest w bazie więc mozna go dodać
                    courseDto.StudentDtosList.Add(students);
                    i++;
                }
                //wróć do pętli i zapytaj jeszcze raz

                // }
                // catch (Exception e)
                // {
                //     Console.WriteLine("\nOsoba o podanym peselu, juz istnieje!!!\n");
                // }
            } while (i < noStudent);
            //   StudentDtoListToStudentList(StudentDtosList);
            _courseService.AddCourse(courseDto);
            succes = true;
            ConsoleWriteHelper.PrintOperationSuccessMessage(succes);
        } //dodaj kurs
コード例 #3
0
        public static void SelectOption(string[] options)
        {
            var index = Constants.Ints.DefaultZero;

            ConsoleKeyInfo keyInfo = new ConsoleKeyInfo();

            while (keyInfo.Key != ConsoleKey.Enter)
            {
                keyInfo = Console.ReadKey();
                NonCostants.ClearKeyBuffer();
                if (keyInfo.Key == ConsoleKey.UpArrow || keyInfo.Key == ConsoleKey.LeftArrow)
                {
                    index = index == 0 ? options.Length - 1 : index - 1;
                }
                if (keyInfo.Key == ConsoleKey.DownArrow || keyInfo.Key == ConsoleKey.RightArrow)
                {
                    index = Math.Abs((index + 1) % options.Length);
                }
                if (keyInfo.Key == ConsoleKey.Enter)
                {
                }
                ConsoleWriteHelper.ShowBodiContent(options, index);
            }
        }