Пример #1
0
        private void UIAddGrade()
        {
            int    studentId, homeworkId, week, noExemptions;
            double grade;
            string feedback;

            try
            {
                Console.Write("Enter the id of the student: ");
                studentId = Convert.ToInt32(Console.ReadLine());
                Console.Write("Enter the id of the homework: ");
                homeworkId = Convert.ToInt32(Console.ReadLine());
                Console.Write("Enter the week: ");
                week = Convert.ToInt32(Console.ReadLine());
                Console.Write("Enter the number of exemptions: ");
                noExemptions = Convert.ToInt32(Console.ReadLine());
                Student  student  = studentService.FindStudent(studentId);
                Homework homework = homeworkService.FindHomework(homeworkId);
                if (student != null && homework != null)
                {
                    Console.WriteLine("The maximum grade is: " + gradeService.GetMaximumGradeForStudentOnHomeworkIntoWeek(student, homework, week, noExemptions));
                    Console.Write("Enter the grade: ");
                    grade = Convert.ToDouble(Console.ReadLine());
                    Console.Write("Enter the feedback: ");
                    feedback = Console.ReadLine();
                    Grade gradeObj = this.gradeService.AddGrade(new Grade(studentId, homeworkId, grade, week, feedback), noExemptions);
                    if (gradeObj == null)
                    {
                        Console.Write("Successfully added the grade!");
                    }
                    else
                    {
                        Console.Write("Failed to add the grade!");
                    }
                }
                else
                {
                    Console.Write("The student or the homework doesn't exist!");
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
        }