Ejemplo n.º 1
0
        public void GetStudentByIDTest()
        {
            // Act
            _studentsService.GetStudentByID(42);

            // Assert
            _mockIStudentRepository.Verify(rs => rs.GetStudentByID(It.Is <int>(i => i == 42)));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> EditAsync(int id, [Bind("StudentID,Group_ID,FirstName,LastName")] StudentsViewModel students)
        {
            if (id != students.StudentID)
            {
                return(NotFound());
            }

            var studentToUpdate = _servStudents.GetStudentByID(id);

            if (await TryUpdateModelAsync <Students>(studentToUpdate, "", s => s.FirstName, s => s.LastName, s => s.GroupID))
            {
                if (await _servStudents.TryUpdateAsync())
                {
                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    ModelState.AddModelError("", "Unable to save changes. " +
                                             "Try again, and if the problem persists, " +
                                             "see your system administrator.");
                }
            }
            return(View(studentToUpdate));
        }