Example #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();
 }
Example #3
0
        public GradeDto Map(Guid gradeId, GradeEditingDto gradeEditingDto)
        {
            GradeDto gradeDto = new GradeDto(gradeId, gradeEditingDto.Value, gradeEditingDto.Pages,
                                             gradeEditingDto.Date, gradeEditingDto.Agree, gradeEditingDto.StudentId, gradeEditingDto.ExamId)
            {
                Id = gradeId
            };

            return(gradeDto);
        }
Example #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);
        }
Example #5
0
        public async Task <IActionResult> UpdateGrade(Guid gradeId, GradeEditingDto gradeEditingDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var existingGrade = await this.gradeService.Update(gradeId, gradeEditingDto);

                return(NoContent());
            }
            catch (GradeNotFoundException gradeNotFoundException)
            {
                return(NotFound(gradeNotFoundException.Message));
            }
        }
Example #6
0
        public async Task <GradeDto> Update(Guid existingGradeId, GradeEditingDto gradeEditingDto)
        {
            GradeDto gradeDto = this.gradeMapper.Map(existingGradeId, gradeEditingDto);
            var      grade    = GetGradeById(existingGradeId).Result;

            if (!grade.Value.Equals(gradeEditingDto.Value))
            {
                await this.SendGradeAddedEmail(existingGradeId);
            }

            if (grade.Agree == null && gradeEditingDto.Agree == false)
            {
                await this.SendStudentDoesNotAgreeEmail(existingGradeId);
            }
            this.writeRepository.Update(this.gradeMapper.Map(gradeDto, grade));
            await this.writeRepository.SaveAsync();

            return(gradeDto);
        }