예제 #1
0
        // GET: Admin/Courses/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Courses courses = _coursesRepository.GetCourseById(id.Value);

            if (courses == null)
            {
                return(HttpNotFound());
            }

            ViewBag.SubCourses     = _subCoursesRepository.GetAllSubCoursesByID(id.Value).ToList();
            ViewBag.SelectedGroups = courses.Selected_Category.ToList();
            ViewBag.categories     = _categoryRepository.GetAllCategories().ToList();
            return(View(courses));
        }
        public IActionResult getCourseById(int courseId)
        {
            var _course = _coursesRepository.GetCourseById(courseId);

            Response res = new Response();

            res.error   = false;
            res.data    = _course;
            res.message = "course data with course id " + courseId + " was successfully retreived!";

            return(Ok(res));
        }
        public CourseResponse GetCourseById(IdRequest request)
        {
            var response = new IdRequestValidator().Validate(request).ToResponse <CourseResponse>();

            if (!response.IsSuccessful)
            {
                return(response);
            }

            try
            {
                response.Course = _coursesRepository.GetCourseById(request.Id);
            }
            catch (Exception ex)
            {
                response.IsSuccessful = false;
                response.Errors.Add("An error has occurred while getting the specific course!");
                _logger.LogException(ex);
            }
            return(response);
        }
예제 #4
0
        public async Task <CourseForUpdateDto> UpdateCourse(Course course)
        {
            var currentCourse = await _coursesRepo.GetCourseById(course.Id);

            currentCourse.Name             = course.Name;
            currentCourse.StartDate        = course.StartDate.LocalDateTime;
            currentCourse.EndDate          = course.EndDate.LocalDateTime;
            currentCourse.TeacherId        = course.TeacherId;
            currentCourse.SpecializationId = course.SpecializationId;
            currentCourse.ClassId          = course.ClassId;

            var mappedCourse = _mapper.Map <CourseForUpdateDto>(currentCourse);

            return(mappedCourse);
        }
예제 #5
0
        public Grade TryAddGrade(int studentId, int courseId, GradeContract gradeContract, out string message)
        {
            if (!Utilities.IsValidGradeContract(gradeContract, out message))
            {
                return(null);
            }

            try
            {
                var student = _studentRepository.GetStudentById(studentId);
                if (student == null)
                {
                    message = "Student with matching id doesn't exist";
                    return(null);
                }

                var course = _coursesRepository.GetCourseById(courseId);
                if (course == null)
                {
                    message = "Course with matching id doesn't exist";
                    return(null);
                }

                var studentInCourse = _studentInCourseRepository.GetOrCreateStudentInCourse(studentId, courseId);

                var grade = new Grade
                {
                    TestGrade         = gradeContract.Grade,
                    StudentInCourseId = studentInCourse.Id
                };


                message = string.Empty;
                return(_gradesRepository.AddGrade(grade));
            }
            catch (DALException e)
            {
                // LOG
                throw new BLException("There was a problem adding new grade", e);
            }
        }
예제 #6
0
        public CourseDetailsDTO GetCourseById(int courseId)
        {
            var course = _repo.GetCourseById(courseId);

            return(course);
        }
예제 #7
0
 public CourseDto GetCourseById(int id)
 {
     return(_coursesRepository.GetCourseById(id));
 }