Ejemplo n.º 1
0
        public ActionResult Search(string q, int? ofs)
        {
            var _books = Book.Search(q.TrimOrNull() ?? "").OrderBy(o => o.Category.Id);
            var _page = _books.Skip(ofs ?? 0).Take(GlobalConfig.Get().ItemsPerPage);

            var books = Mapper.Map<BookModel[]>(_page);
            var pageOffset = new PageOffset(ofs ?? 0, GlobalConfig.Get().ItemsPerPage, _books.Count());

            var view = new BookViewSearchContainer { Books = books, Query = q.TrimOrNull(), PageOffset = pageOffset };

            return View(view);
        }
        public ActionResult Index(int? ofs)
        {
            var _books = Book.Get().OrderBy(o => o.Category.Id);
            var _page = _books.Skip(ofs ?? 0).Take(GlobalConfig.Get().ItemsPerPage);

            var books = Mapper.Map<BookModel[]>(_page);
            var pageOffset = new PageOffset(ofs ?? 0, GlobalConfig.Get().ItemsPerPage, _books.Count());

            var view = new BookViewAllContainer { Books = books, PageOffset = pageOffset};

            return View(view);
        }
        public ActionResult View(int? id, int? ofs)
        {
            var _category = Category.Get(id ?? 0);
            var _books = _category.GetBooks();
            var _page = _books.Skip(ofs ?? 0).Take(GlobalConfig.Get().ItemsPerPage);

            var category = Mapper.Map<CategoryModel>(_category);
            var books = Mapper.Map<BookModel[]>(_page);
            var pageOffset = new PageOffset(ofs ?? 0, GlobalConfig.Get().ItemsPerPage, _books.Count());

            var view = new BookViewCategoryContainer { Books = books, Category = category, PageOffset = pageOffset };

            return View(view);
        }
Ejemplo n.º 4
0
        public ActionResult View(int? id, int? ofs)
        {
            var _tag = Tag.Get(id ?? 0);
            var _books = _tag.GetBooks();
            var _page = _books.Skip(ofs ?? 0).Take(GlobalConfig.Get().ItemsPerPage);

            var tag = Mapper.Map<TagModel>(_tag);
            var books = Mapper.Map<BookModel[]>(_books);
            var pageOffset = new PageOffset(ofs ?? 0, GlobalConfig.Get().ItemsPerPage, _books.Count());

            var view = new BookViewTagContainer { Books = books, Tag = tag, PageOffset = pageOffset };

            return View(view);
        }