public async Task <GradeDto> Create(GradeCreationDto gradeCreationDto) { var exam = await examService.GetById(gradeCreationDto.ExamId); var student = await studentService.GetStudentById(gradeCreationDto.StudentId); Domain.Entities.Grade grade = gradeMapper.Map(gradeCreationDto, student, exam); student.Grades.Add(grade); await writeRepository.AddNewAsync(grade); await writeRepository.SaveAsync(); return(gradeMapper.Map(grade)); }
public void Map_ShouldReturnGrade_WhenArgumentsAreGradeCreationDtoStudentAndExam() { // Act var result = gradeMapper.Map(gradeCreationDto, StudentTestUtils.GetStudent(), ExamTestUtils.GetExam()); // Assert result.Should().BeEquivalentTo(grade, options => options.Excluding(g => g.Id)); }
public async Task <List <StudentFetchingGradeDto> > GetCheckedInStudents(Guid examId) { var exam = await this.readRepository.GetByIdAsync <Domain.Entities.Exam>(examId); if (exam == null) { throw new ExamNotFoundException(examId); } var grades = await this.readRepository.GetAll <Domain.Entities.Grade>().Include(g => g.Student) .Include(g => g.Exam).Where(g => g.Exam.Id == examId).ToListAsync(); return(grades.Select(g => studentMapper.Map(g.Student, gradeMapper.Map(g))).ToList()); }