예제 #1
0
        public ActionResult <StudentDto> Post([FromBody] StudentDto student)
        {
            var result = _studentService.CreateStudent(student.ToModel());

            if (result.HasErrors)
            {
                return(BadRequest(result.Errors));
            }
            return(Accepted(StudentDto.FromModel(result.Result)));
        }
예제 #2
0
        public ActionResult <StudentDto> Get(int id)
        {
            var student = _studentService.GetStudentById(id);

            if (student == null)
            {
                return(NotFound());
            }

            return(Ok(StudentDto.FromModel(student)));
        }
예제 #3
0
 public ActionResult <IEnumerable <StudentDto> > Get()
 {
     return(Ok(_studentService.GetAllStudents().Select(student => StudentDto.FromModel(student))));
 }
예제 #4
0
        public ActionResult <StudentDto> Post([FromBody] StudentDto student)
        {
            var createdStudent = _studentService.CreateStudent(student.ToModel());

            return(Accepted(StudentDto.FromModel(createdStudent)));
        }