Beispiel #1
0
 public void Setup()
 {
     this.grade            = GradeTestUtils.GetInitialStateGrade();
     this.gradeDto         = GradeTestUtils.GetInitialGradeDto(grade.Id);
     this.gradeCreationDto = GradeTestUtils.GetGradeCreationDto();
     this.gradeEditingDto  = GradeTestUtils.GetGradeEditingDto();
     this.gradeMapper      = new GradeMapper();
 }
 public void Setup()
 {
     client                = new CustomWebApplicationFactory <Startup>().CreateClient();
     this.grade            = GradeTestUtils.GetInitialStateGrade();
     this.gradeDto         = GradeTestUtils.GetInitialGradeDto(grade.Id);
     this.gradeCreationDto = GradeTestUtils.GetGradeCreationDto();
     this.gradeEditingDto  = GradeTestUtils.GetGradeEditingDto();
 }
Beispiel #3
0
        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));
        }
Beispiel #4
0
        public void Setup()
        {
            this.initialStateGrade    = GradeTestUtils.GetInitialStateGrade();
            this.initialStateGradeDto = GradeTestUtils.GetInitialGradeDto(initialStateGrade.Id);
            this.gradeCreationDto     = GradeTestUtils.GetGradeCreationDto();
            this.gradeEditingDto      = GradeTestUtils.GetGradeEditingDto();
            this._mockReadRepository  = new Mock <IReadRepository>();
            this._mockWriteRepository = new Mock <IWriteRepository>();
            this._mockGradeMapper     = new Mock <IGradeMapper>();
            this._mockStudentService  = new Mock <IStudentService>();
            this._mockExamService     = new Mock <IExamService>();
            this._mockEmailService    = new Mock <IEmailService>();

            _gradeService = new GradeService(_mockReadRepository.Object, _mockWriteRepository.Object,
                                             _mockGradeMapper.Object, _mockStudentService.Object, _mockExamService.Object, _mockEmailService.Object);
        }
Beispiel #5
0
        public async Task <IActionResult> CreateGrade([FromBody] GradeCreationDto gradeCreationDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var grade = await gradeService.Create(gradeCreationDto);

                return(Ok(grade));
            }
            catch (ExamNotFoundException examNotFoundException)
            {
                return(NotFound(examNotFoundException.Message));
            }
            catch (StudentNotFoundException studentNotFoundException)
            {
                return(NotFound(studentNotFoundException.Message));
            }
        }
Beispiel #6
0
 public Domain.Entities.Grade Map(GradeCreationDto gradeCreationDto,
                                  Domain.Entities.Student student, Domain.Entities.Exam exam)
 {
     return(new Domain.Entities.Grade(student, exam));
 }