public ActionResult <IEnumerable <CoursesDto> > GetCourses(Guid authorId) { var authors = _courseLibraryRepository.AuthorExist(authorId); if (!authors) { return(NotFound()); } var coursesFromRepo = _courseLibraryRepository.GetCourses(authorId); return(Ok(_mapper.Map <IEnumerable <CoursesDto> >(coursesFromRepo))); }
public ActionResult <IEnumerable <CoursesDTO> > GetCoursesForAuthor(int authorId) { try { var AuthorsCourses = _courseLibrary.GetCourses(authorId); if (AuthorsCourses == null) { return(NotFound(new JsonResponse <string>() { Success = false, ErrorMessage = "Author does Not exist, Invalid Id." })); } var CoursesforAuthor = _mapper.Map <IEnumerable <CoursesDTO> >(AuthorsCourses); // return body format for the Api with right statusCode return(Ok(new JsonResponse <CoursesDTO>() { Success = true, Results = CoursesforAuthor })); } catch (Exception ex) { //log ex return(StatusCode(500, "Something went wrong, pls try again later")); } }
public ActionResult <IEnumerable <CourseDTO> > GetCoursesForAuthor(Guid authorId) { if (!_courseLibraryRepository.AuthorExists(authorId)) { return(NotFound()); } return(Ok(_mapper.Map <IEnumerable <CourseDTO> >(_courseLibraryRepository.GetCourses(authorId)))); }
public ActionResult <IEnumerable <CourseDto> > GetCoursesForAuthor(Guid authorId) { var author = _repository.GetAuthor(authorId); return(author == null ? (ActionResult <IEnumerable <CourseDto> >)NotFound() : Ok(_mapper.Map <IEnumerable <CourseDto> >(_repository.GetCourses(authorId)))); }
public ActionResult <IEnumerable <CoursesDto> > GetCourseForAuthors(Guid authorId) { if (_courseLibraryRepository.AuthorExists(authorId)) { var getCouseFromRepo = _courseLibraryRepository.GetCourses(authorId); return(Ok(_mapper.Map <IEnumerable <CoursesDto> >(getCouseFromRepo))); } return(NotFound()); }
public IActionResult GetCourses(Guid authorId) { if (!_courseLibraryRepository.AuthorExists(authorId)) { return(NotFound()); } var courses = _courseLibraryRepository.GetCourses(authorId); return(Ok(_mapper.Map <CourseDto>(courses))); }
public ActionResult <IEnumerable <CourseDto> > GetCoursesForAuthor(Guid authorId) { if (!courseLibraryRepository.AuthorExists(authorId)) { return(NotFound()); } var coursesFromRepository = courseLibraryRepository.GetCourses(authorId); return(Ok(mapper.Map <IEnumerable <CourseDto> >(coursesFromRepository))); }
public IActionResult GetCoursesForAuthor(Guid authorId) { var coursesForAuthors = _coursesLibraryRepository.GetCourses(authorId); if (!_coursesLibraryRepository.AuthorExists(authorId)) { return(NotFound()); } return(Ok(_mapper.Map <IEnumerable <CourseDto> >(coursesForAuthors))); }
public ActionResult <IEnumerable <CourseDto> > GetCoursesForAuthor(Guid authorId) { if (!courseRepo.AuthorExists(authorId)) { return(NotFound()); } var courses = courseRepo.GetCourses(authorId); return(Ok(mapper.Map <IEnumerable <CourseDto> >(courses))); }
public ActionResult <IEnumerable <CourseDto> > GetAllCourses(Guid authorid) { if (!_repo.AuthorExists(authorid)) { return(NotFound()); } var courses = _repo.GetCourses(authorid); return(Ok(_map.Map <IEnumerable <CourseDto> >(courses))); }
public ActionResult <IEnumerable <CourseDto> > Get(Guid authorId) { if (!_repository.AuthorExists(authorId)) { return(NotFound()); } var courses = _repository.GetCourses(authorId); return(Ok(_mapper.Map <IEnumerable <CourseDto> >(courses))); }
public IEnumerable <CourseDto> GetCoursesForAuthor(Guid authId) { if (!_repo.AuthorExists(authId)) { return(null); } var x = _repo.GetCourses(authId); return(_mapper.Map <IEnumerable <CourseDto> >(x)); }
public ActionResult <IEnumerable <CourseDto> > GetCoursesForAuthor(Guid authorId) // IActionResult renvoi le résultat d'une méthode d'action { if (!_courseLibraryRepository.AuthorExists(authorId)) { return(NotFound()); } var coursesForAuthorFromRepo = _courseLibraryRepository.GetCourses(authorId); return(Ok(_mapper.Map <IEnumerable <CourseDto> >(coursesForAuthorFromRepo))); }
public ActionResult <IEnumerable <CourseDto> > GetCoursesForAuthor(Guid authorId) { if (!_courseLibraryRepository.AuthorExists(authorId)) //check if author exist { return(NotFound()); } var coursesForAuthorFromRepo = _courseLibraryRepository.GetCourses(authorId); return(Ok(_mapper.Map <IEnumerable <CourseDto> >(coursesForAuthorFromRepo))); }
public ActionResult <IEnumerable <CourseDto> > GetCoursesForAuthor(Guid authorId) { if (!_courseLibraryRepository.AuthorExists(authorId)) { return(NotFound()); } var courseForAuthorFormRepo = _courseLibraryRepository.GetCourses(authorId); return(Ok(courseForAuthorFormRepo)); }
public IActionResult GetCoursesForAuthor(Guid authorId) { var coursesForAuthorFromRepo = _courseLibraryRepository.GetCourses(authorId); var res = _mapper.Map <IEnumerable <CourseDto> >(coursesForAuthorFromRepo); if (res.Count() == 0) { return(NotFound()); } return(Ok(res)); }
public ActionResult <IEnumerable <CoursesDto> > GetAuthorCourses(Guid authorId) { //Check if author exists if (!_courseLibraryRepository.AuthorExists(authorId)) { return(NotFound()); } var authorCourses = _courseLibraryRepository.GetCourses(authorId); return(Ok(_mapper.Map <IEnumerable <CoursesDto> >(authorCourses))); }
public ActionResult <IEnumerable <CourseDto> > GetCourses(Guid authorId) { if (!_courseLibraryRepository.AuthorExists(authorId)) { return(NotFound()); } var courses = _courseLibraryRepository.GetCourses(authorId); var coursesDto = _mapper.Map <IEnumerable <CourseDto> >(courses); return(Ok(coursesDto)); }
public ActionResult <IEnumerable <CourseDTO> > GetCoursesFromAuthor(Guid authorId) { if (!_clRepo.AuthorExists(authorId)) { return(NotFound()); } var courses = _clRepo.GetCourses(authorId); var result = _mapper.Map <IEnumerable <CourseDTO> >(courses); return(Ok(result)); }
public ActionResult <IEnumerable <CourseDto> > GetCoursesForAuthor(Guid authorId) { //throw new Exception("Terrible error occurred"); if (!_courseLibraryRepository.AuthorExists(authorId)) { return(NotFound()); } var coursesForAuthorFromRepo = _courseLibraryRepository.GetCourses(authorId); return(Ok(_mapper.Map <IEnumerable <CourseDto> >(coursesForAuthorFromRepo))); }
public async Task <ActionResult <IEnumerable <CourseDto> > > getCoursesForAuthor(Guid authorId) { if (!_courseLibaryService.AuthorExists(authorId)) { return(NotFound()); } var courses = await _courseLibaryService.GetCourses(authorId); var CourseResult = _mapper.Map <IEnumerable <CourseDto> >(courses); return(Ok(CourseResult)); }
public ActionResult <IEnumerable <CourseDTO> > GetCoursesForAuthors(Guid createrId) { if (!courseLibraryRepository.AuthorExists(createrId)) { return(NotFound()); } var courseForAuthorsFromRepo = courseLibraryRepository.GetCourses(createrId); return(Ok(_mapper.Map <IEnumerable <CourseDTO> >(courseForAuthorsFromRepo))); }
public ActionResult <IEnumerable <CoursesDto> > GetCoursesForAuthor(Guid authorId) { if (!_courselibraryRepository.AuthorExists(authorId)) { return(NotFound()); } var courses = _courselibraryRepository.GetCourses(authorId); if (courses == null) { return(NotFound()); } return(Ok(_mapper.Map <IEnumerable <CoursesDto> >(courses))); }
public ActionResult <IEnumerable <CourseDto> > GetCoursesForAuthor(Guid authorId) { try { if (!_courseLibraryRepository.AuthorExists(authorId)) { return(NotFound()); } return(Ok(_courseLibraryRepository.GetCourses(authorId))); } catch (Exception ex) { _logger.LogError(ex, $"{ex.Message}"); return(StatusCode(500, "Internal server error, try again later.")); } }
public ActionResult <IEnumerable <CourseDTO> > GetCourses(Guid authorId) { if (!_courseLibrary.AuthorExists(authorId)) { return(NotFound()); } var courses = _courseLibrary.GetCourses(authorId); if (courses is null) { return(NotFound()); } return(Ok(_mapper.Map <IEnumerable <CourseDTO> >(courses))); }
public async Task <ActionResult <IEnumerable <CourseForReturn> > > GetCourses(Guid authorId) { if (!await _repository.AuthorExists(authorId)) { return(NotFound("Author Not Found")); } var coursesFromRepo = await _repository.GetCourses(authorId); if (coursesFromRepo == null) { return(NotFound("this author has no courses")); } var courses = _mapper.Map <IEnumerable <CourseForReturn> >(coursesFromRepo); return(Ok(courses)); }
public ActionResult <IEnumerable <CourseDto> > GetCoursesForAuthor(Guid authorId) { try { if (!_courseLibraryRepository.AuthorExists(authorId)) { return(NotFound()); } var CoursesFromRepo = _courseLibraryRepository.GetCourses(authorId); return(Ok(_mapper.Map <IEnumerable <CourseDto> >(CoursesFromRepo))); } catch (Exception) { return(StatusCode(500, "Internal server error")); } }
public IActionResult GetCoursesForAuthor( [FromRoute] Guid authorId, [FromQuery] string fields) { if (!AuthorExists(authorId)) { return(NotFound()); } if (!_propertyCheckerService.TypeHasProperties <CourseDto>(fields)) { return(BadRequest()); } // TODO: Add Courses Pagination IEnumerable <Course> coursesFromRepo = _courseLibraryRepository.GetCourses(authorId); return(Ok(_mapper.Map <IEnumerable <Course> >(coursesFromRepo).ShapeData(fields))); }
public ActionResult <IEnumerable <CourseDto> > GetCoursesForAuthor(Guid authorId) { try { //Validate {authorId} if (!_courseLibraryRepository.AuthorExists(authorId)) { return(NotFound()); } var GetCourses = _courseLibraryRepository.GetCourses(authorId); return(Ok(_mapper.Map <IEnumerable <CourseDto> >(GetCourses))); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Database Failure __")); } }
public ActionResult <IEnumerable <CourseDto> > GetCoursesForAuthor(Guid authorId) { return(_context.AuthorExists(authorId) ? Ok(_mapper.Map <IEnumerable <CourseDto> >(_context.GetCourses(authorId))) : (ActionResult)NotFound()); }