Ejemplo n.º 1
0
        public async Task EditAsyncTest()
        {
            OneTimeSetUp();
            var expectGrade = _gradesRepositoryMock.Object.All().FirstOrDefault();
            var newGrade    = new GradeModifyInputModel()
            {
                Id    = expectGrade.Id,
                Grade = new GradeInputModel()
                {
                    StudentId = expectGrade.StudentSubject.StudentId,
                    Period    = GradePeriod.SecondTerm,
                    Type      = GradeType.Normal,
                },
            };

            await _gradesService.EditAsync(newGrade);

            expectGrade.Should().NotBe(newGrade);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> EditGrade(GradeModifyInputModel inputModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(inputModel));
            }

            try
            {
                await _gradesService.EditAsync(inputModel);

                return(RedirectToAction("SubjectsList", "Subjects", new { area = string.Empty }));
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"An exception occured during student UPDATE operation for grade with id {inputModel.Id}. Ex: {e.Message}");
                return(RedirectToAction("Error", "Home"));
            }
        }