public async Task CreateGradeAsync_HappyPath() { OneTimeSetUp(); var newAbsence = new GradeInputModel() { Period = GradePeriod.FirstTerm, Type = GradeType.Final, TeacherId = TestTeacherDBId, StudentId = StudentCorrectId, SubjectId = SubjectCorrectId, }; await _gradesService.CreateAsync(newAbsence); _gradesRepositoryMock.Object.All().Count().Should().Be(1); }
public async Task <IActionResult> AddGrade(GradeCreateInputModel inputModel) { if (!ModelState.IsValid) { return(View(inputModel)); } try { await _gradesService.CreateAsync(inputModel.Grade); return(RedirectToAction("ById", "Subjects", new { area = string.Empty, id = inputModel.Grade.SubjectId })); } catch (Exception e) { _logger.LogError(e, $"An exception occured during new grade record creation. Ex: {e.Message}"); return(RedirectToAction("Error", "Home")); } }