public async Task CreateAbsenceAsync() { OneTimeSetUp(); var newAbsence = new AbsenceInputModel() { Period = AbsencePeriod.FirstTerm, Type = AbsenceType.Full, TeacherId = TestTeacherDBId, StudentId = StudentCorrectId, SubjectId = SubjectCorrectId, }; await _absencesService.CreateAsync(newAbsence); _absencesRepositoryMock.Object.All().Count().Should().Be(1); }
public async Task <IActionResult> AddAbsence(AbsenceCreateInputModel inputModel) { if (!ModelState.IsValid) { return(View(inputModel)); } try { await _absencesService.CreateAsync(inputModel.Absence); return(RedirectToAction("ById", "Subjects", new { area = string.Empty, id = inputModel.Absence.SubjectId })); } catch (Exception e) { _logger.LogError(e, $"An exception occured during new absence record creation. Ex: {e.Message}"); return(RedirectToAction("Error", "Home")); } }