Beispiel #1
0
        public async Task <ActionResult <ICollection <BookDetailedViewModel> > > GetCategoryBooks(int id, int pageNo)
        {
            if (pageNo < 1)
            {
                return(BadRequest("Wrong page number."));
            }

            var books = await bookCategoryService.GetAll()
                        .Where(bc => bc.CategoryId == id)
                        .Skip((pageNo - 1) * ControllersConstants.ItemsOnPageCount)
                        .Take(ControllersConstants.ItemsOnPageCount)
                        .Include(bc => bc.Book)
                        .ThenInclude(b => b.Author)
                        .Select(bc => bc.Book)
                        .ToListAsync();

            if (books == null)
            {
                return(NotFound($"Page with number '{pageNo}' is empty."));
            }

            var bookViewModels = mapper.Map <ICollection <BookDetailedViewModel> >(books);

            foreach (var bookViewModel in bookViewModels)
            {
                var categories = await bookCategoryService.GetCategoriesAsync(bookViewModel.Id);

                bookViewModel.Categories = mapper.Map <ICollection <CategoryViewModel> >(categories);
            }

            return(Ok(bookViewModels));
        }
        public ActionResult <dynamic> GetBookCategories()
        {
            string id     = HttpContext.Request.Query["id"];
            var    result = _bookCategoryService.GetAll();

            return(Ok(result));
        }
Beispiel #3
0
 public async Task <List <BooksCategoryDto> > GetData()
 {
     return(await _bookscategorySvc.GetAll().Select(t => new BooksCategoryDto()
     {
         Id = t.Id,
         BooksCategory_Title = t.BooksCategory_Title
     }).ToListAsync());
 }
Beispiel #4
0
        public ActionResult MenuHeaderTheLoaiSach()
        {
            //var Execute = new BookCategoryRepository();
            //var modelTheLoaiSach = Execute.GetAll();

            var modelTheLoaiSach = _bookCategoryService.GetAll();

            return(PartialView(modelTheLoaiSach));
        }
Beispiel #5
0
        public async Task <IActionResult> GetBookGategories(int id)
        {
            var categories = await bookCategoryService.GetAll()
                             .Where(c => c.BookId == id)
                             .Include(c => c.Category)
                             .Select(c => c.Category)
                             .ToListAsync();

            if (categories == null)
            {
                return(NotFound($"There are no categories for specified book id: {id}."));
            }

            return(Ok(categories));
        }
Beispiel #6
0
 public async Task <ActionResult <ApiResponse> > Get()
 {
     return(new ApiResponse("Book Categories retrived",
                            mapper.Map <IEnumerable <BookCategoryDto> >(await bookCategoryService.GetAll())));
 }
Beispiel #7
0
 public IEnumerable <Entities.BookCategory> GetAll()
 {
     return(_service.GetAll());
 }
        public IActionResult GetAllBookCategory()
        {
            var model = _bookCategoryService.GetAll();

            return(new OkObjectResult(model));
        }
Beispiel #9
0
        public ActionResult TaoBangBenPhai()
        {
            var model = _bookCategoryService.GetAll();

            return(PartialView(model));
        }