public async Task EditAbsenceAsyncTest_HappyPath() { OneTimeSetUp(); var absence = _absencesRepositoryMock.Object.All().FirstOrDefault(); var newAbsence = new AbsenceModifyInputModel() { Id = absence.Id, Absence = new AbsenceInputModel() { StudentId = absence.StudentSubject.StudentId, Period = AbsencePeriod.SecondTerm, Type = AbsenceType.OneThird, }, }; await _absencesService.EditAsync(newAbsence); absence.Should().NotBe(newAbsence); }
public async Task <IActionResult> EditAbsence(AbsenceModifyInputModel inputModel) { if (!ModelState.IsValid) { return(View(inputModel)); } try { await _absencesService.EditAsync(inputModel); return(RedirectToAction("SubjectsList", "Subjects", new { area = string.Empty })); } catch (Exception e) { _logger.LogError(e, $"An exception occured during student UPDATE operation for absence with id {inputModel.Id}. Ex: {e.Message}"); return(RedirectToAction("Error", "Home")); } }