public IActionResult addStudent(Student student) { bool result = _dbService.AddStudent(student); if (result == true) { return(Ok("Added!")); } return(BadRequest("Something went wrong!")); }
public IActionResult AddStudent(Student student) { Enrollment response; try { response = _dbService.AddStudent(student); }catch (Exception e) { return(BadRequest(e.Message)); } return(Created("Created", response)); }
public async Task <IActionResult> AddStudent(AddStudentRequest req) { int res = await _service.AddStudent(req); if (res == -1) { return(BadRequest()); } else { return(Ok("Student was added")); } }
public IActionResult EnrollStudent(EnrollStudentRequest request) { var student = new Student() { FirstName = request.FirstName, LastName = request.LastName, DateOfBirth = request.BirthDate, Faculty = request.Studies, IndexNumber = request.IndexNumber }; var enrollment = _studentsDbService.AddStudent(student); if (enrollment == null) { return(BadRequest()); } return(Ok(enrollment)); }
public IActionResult CreateStudent(Student student) { student.IndexNumber = $"s{new Random().Next(1, 20000)}"; _studentsDbService.AddStudent(student); return(Ok(student)); }