public async Task <Response <List <CategoryDto> > > GetAllAsync() { var spesification = new BaseSpesification <Category>(null); spesification.AddInclude(p => p.Courses); var categories = await _categoryRepository.GetListWithSpecQuery(spesification); return(Response <List <CategoryDto> > .Success(_mapper.Map <List <CategoryDto> >(categories), 200)); }
public async Task <Response <List <CourseDto> > > GetCoursesWithFeatureAsync() { var spesification = new BaseSpesification <Course>(null); spesification.AddInclude(p => p.Features); var courses = await _courseRepository.GetListWithSpecQuery(spesification); return(Response <List <CourseDto> > .Success(_mapper.Map <List <CourseDto> >(courses), 200)); }
public async Task <Response <CategoryDto> > GetByIdAsync(int id) { var spesification = new BaseSpesification <Category>(p => p.Id == id); spesification.AddInclude(p => p.Courses); var category = await _categoryRepository.GetWithSpecQuery(spesification); if (category == null) { var errors = new List <string>(); errors.Add("Category Not Found!"); return(Response <CategoryDto> .Fail(errors, 404)); } return(Response <CategoryDto> .Success(_mapper.Map <CategoryDto>(category), 200)); }
public async Task <Response <List <CourseDto> > > GetByCategoryIdAsync(int id) { var categoryResponse = await _categoryService.GetByIdAsync(id); if (categoryResponse.StatusCode == 404) { var errors = new List <string>(); errors.Add("No category!"); return(Response <List <CourseDto> > .Fail(errors.FirstOrDefault(), 404)); } var spesification = new BaseSpesification <Course>(p => p.CategoryId == id); spesification.AddInclude(p => p.Category); var courses = await _courseRepository.GetListWithSpecQuery(spesification); return(Response <List <CourseDto> > .Success(_mapper.Map <List <CourseDto> >(courses), 200)); }