Beispiel #1
0
        public async Task CreateStudent_Success()
        {
            var newStudent = new Student {
                FirstName = "FName", LastName = "LName"
            };
            var result = await _studentRepository.CreateStudent(newStudent);

            var addedStudent = _universityDbContext.Students.FirstOrDefault(s => s.Id.Equals(result.Id));

            Assert.IsNotNull(addedStudent);
            Assert.AreEqual(newStudent.FirstName, addedStudent.FirstName);
            Assert.AreEqual(newStudent.LastName, addedStudent.LastName);
        }
        public async Task <IActionResult> Post([FromRoute] int classId, [FromBody] CreateStudentDto studentDto)
        {
            var studentId = await _repository.CreateStudent(classId, studentDto);

            return(Created($"api/classes/{classId}/students/{studentId}", null));
        }