public async Task UpdateStudentGrade_Valid_Ok() { var enrollmentId = 45; var obj = new UpdateGrade { Grade = (decimal?)27.8 }; await _enrollmentLogic.UpdateStudentGrade(enrollmentId, obj); var actual = await _enrollmentRepository.GetById(enrollmentId); Assert.AreEqual(actual.Grade, obj.Grade); }
public void Cancelar(int enrollmentId) { var enrollment = _enrollmentRepository.GetById(enrollmentId); BaseValidator.New() .When(enrollment == null, Resource.EnrollmentNotFound) .TriggersIfExceptionExists(); enrollment?.Cancel(); }
public void Concluir(int matriculaId, double notaDoAluno) { var matricula = _matriculaRepository.GetById(matriculaId); BaseValidator.New() .When(matricula == null, Resource.EnrollmentNotFound) .TriggersIfExceptionExists(); matricula?.ShowGrade(notaDoAluno); }
public async Task <IActionResult> Edit(long id) { try { var output = _enrollmentRepository.GetById(id); if (output != null) { return(Ok(output)); } else { return(NotFound(_NotFound)); } } catch (Exception e) { return(BadRequest(e)); } }
public async Task UpdateStudentGrade(int id, UpdateGrade updateGrade) { if (updateGrade.Grade.HasValue && (updateGrade.Grade.Value < 0 || updateGrade.Grade.Value > 100)) { throw new ArgumentException("Grade must be between 0 and 100"); } if (await _enrollmentRepository.GetById(id) == null) { throw new ArgumentException($"There's no enrollment with enrollmentId = {id}"); } var enrollment = new Enrollment { EnrollmentId = id, Grade = updateGrade.Grade }; await _enrollmentRepository.Update(id, enrollment); }
public Enrollment GetEnrollmentById(int Id) { return(enrollmentRepository.GetById(Id)); }