// 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); }
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); }
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); } }
public CourseDetailsDTO GetCourseById(int courseId) { var course = _repo.GetCourseById(courseId); return(course); }
public CourseDto GetCourseById(int id) { return(_coursesRepository.GetCourseById(id)); }