Beispiel #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)));
        }
Beispiel #2
0
        public ActionResult <StudentDto> Get(int id)
        {
            var student = _studentService.GetStudentById(id);

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

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

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