示例#1
0
        public IActionResult CreateCatalogueGrade(int schoolId, int catalogueId, [FromBody] GradeDTO gradeDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            Student student = _schoolRepository.GetStudent(gradeDTO.StudentId, schoolId);
            Course  course  = _schoolRepository.GetCourse(gradeDTO.CourseId, schoolId);
            Mentor  mentor  = _schoolRepository.GetMentor(gradeDTO.MentorId, schoolId);
            Grade   grade   = new Grade()
            {
                Student = student,
                Mark    = gradeDTO.Mark,
                Course  = course,
                Mentor  = mentor,
                Date    = gradeDTO.Date
            };

            _schoolRepository.AddCatalogueGrade(grade, schoolId, catalogueId);
            return(CreatedAtRoute("GetCatalogueGrade",
                                  new { schoolId, catalogueId, gradeId = grade.Id }, grade));
        }