示例#1
0
        public async Task <StudentVm> CreateNewStudentAsync(NewStudentVm studentVm)
        {
            var student = new Student
            {
                FirstName = studentVm.FirstName,
                LastName  = studentVm.LastName,
                Address   = studentVm.Address
            };

            await _context.Student.AddAsync(student);

            await _context.SaveChangesAsync();

            var responseStudent = new StudentVm
            {
                Address  = student.Address,
                FullName = $"{student.FirstName} {student.LastName}"
            };

            return(await Task.FromResult(responseStudent));
        }
示例#2
0
 public async Task <StudentVm> CreateNewStudentAsync([FromBody] NewStudentVm studentVm)
 {
     return(await _studentService.CreateNewStudentAsync(studentVm));
 }