Exemplo n.º 1
0
        public IActionResult addStudent(Student student)
        {
            bool result = _dbService.AddStudent(student);

            if (result == true)
            {
                return(Ok("Added!"));
            }
            return(BadRequest("Something went wrong!"));
        }
Exemplo n.º 2
0
        public IActionResult AddStudent(Student student)
        {
            Enrollment response;

            try
            {
                response = _dbService.AddStudent(student);
            }catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
            return(Created("Created", response));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> AddStudent(AddStudentRequest req)
        {
            int res = await _service.AddStudent(req);

            if (res == -1)
            {
                return(BadRequest());
            }
            else
            {
                return(Ok("Student was added"));
            }
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
 public IActionResult CreateStudent(Student student)
 {
     student.IndexNumber = $"s{new Random().Next(1, 20000)}";
     _studentsDbService.AddStudent(student);
     return(Ok(student));
 }