public ActionResult Update(int id)
        {
            var bookCategory   = _bookCategoryService.GetById(id);
            var bookCategoryVm = Mapper.Map <BookCategory, BookCategoryViewModel>(bookCategory);

            return(View(bookCategoryVm));
        }
示例#2
0
        public ActionResult Category(int id, int page = 1)
        {
            int pageSize  = 12;
            int totalRow  = 0;
            var books     = _bookeService.GetPagingByCategoryId(page, pageSize, out totalRow, id);
            var booksVm   = Mapper.Map <IEnumerable <Book>, IEnumerable <BookViewModel> >(books);
            int totalPage = (int)Math.Ceiling((double)totalRow / pageSize);
            var model     = new PaginationSet <BookViewModel>()
            {
                items      = booksVm,
                Page       = page,
                MaxPage    = 4,
                TotalCount = totalRow,
                TotalPages = totalPage
            };
            var category   = _bookCategoriesService.GetById(id);
            var categoryVm = Mapper.Map <BookCategory, BookCategoryViewModel>(category);

            ViewBag.Category = categoryVm;
            return(View(model));
        }