Ejemplo n.º 1
0
        public async Task <CursosResponse> AddStudent(string id, string studentId)
        {
            var existingCourse = await _cursosRepository.FindByIdAsync(id);

            if (existingCourse == null)
            {
                return(new CursosResponse("The student must have an existing course id"));
            }

            existingCourse.id_estudiante.Add(studentId);

            try
            {
                _cursosRepository.Update(existingCourse);
                return(new CursosResponse(existingCourse));
            }
            catch (Exception ex)
            {
                return(new CursosResponse($"An error occurred adding the student to the course: {ex.Message}"));
            }
        }