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))); }
public ActionResult <StudentDto> Get(int id) { var student = _studentService.GetStudentById(id); if (student == null) { return(NotFound()); } return(Ok(StudentDto.FromModel(student))); }
public ActionResult <IEnumerable <StudentDto> > Get() { return(Ok(_studentService.GetAllStudents().Select(student => StudentDto.FromModel(student)))); }
public ActionResult <StudentDto> Post([FromBody] StudentDto student) { var createdStudent = _studentService.CreateStudent(student.ToModel()); return(Accepted(StudentDto.FromModel(createdStudent))); }