예제 #1
0
        public ActionResult AuthorList(int authorId, string sortField, int pageIndex = 1, SortOrder sortOrder = SortOrder.Asc)
        {
            BookCategoryList  categoryList   = new BookCategoryList();
            PagedBookListInfo pagedBooksInfo = new PagedBookListInfo
            {
                Pagination = new PaginationInfo
                {
                    PageIndex = pageIndex,
                    SortField = sortField,
                    PageSize  = WebConfig.BookPageSize,
                    SortOrder = sortOrder
                },
                ActionName     = "AuthorList",
                ControllerName = "Book",
                PageParamName  = "authorId",
                PageParamValue = authorId
            };



            // 图书列表
            int total;

            pagedBooksInfo.Books = ResolveService <IBookService>().GetPagedAuthorBooks(authorId, pageIndex - 1, WebConfig.BookPageSize, sortField, sortOrder, out total);
            pagedBooksInfo.Total = total;

            ViewBag.BookCategoryList = categoryList;

            return(View("BookList", pagedBooksInfo));
        }
예제 #2
0
        public ActionResult SearchList(string key, string sortField, int pageIndex = 1, SortOrder sortOrder = SortOrder.Asc)
        {
            key = key ?? "";
            BookCategoryList  categoryList   = new BookCategoryList();
            PagedBookListInfo pagedBooksInfo = new PagedBookListInfo
            {
                Pagination = new PaginationInfo
                {
                    PageIndex = pageIndex,
                    SortField = sortField,
                    PageSize  = WebConfig.BookPageSize,
                    SortOrder = sortOrder
                },
                ActionName     = "SearchList",
                ControllerName = "Book",
                PageParamName  = "key",
                PageParamValue = key
            };

            // 图书列表
            int total;

            pagedBooksInfo.Books = ResolveService <IBookService>().GetPagedSearchBooks(key, pageIndex - 1, WebConfig.BookPageSize, sortField, sortOrder, out total);
            pagedBooksInfo.Total = total;

            ViewBag.BookCategoryList = categoryList;

            return(View("BookList", pagedBooksInfo));
        }
예제 #3
0
        public void DAT_Cut()
        {
            if (IsTestDbSQLite())
            {
                return;
            }

            using (RF.TransactionScope(BackUpDbSettingName))
                using (RF.TransactionScope(DbSettingName))
                {
                    var rawList = new BookCategoryList
                    {
                        new BookCategory
                        {
                            Name = "bc1"
                        }
                    };

                    var repo = RF.ResolveInstance <BookCategoryRepository>();
                    repo.Save(rawList);
                    Assert.AreEqual(1, repo.CountAll(), "新增数目为 1");

                    rawList = repo.GetAll();//由于数据库中存储的值可能与内存中的值有一定的差异,所以这里需要把这些数据重新读取出来再进行对比。

                    Archive(new List <ArchiveItem>
                    {
                        new ArchiveItem
                        {
                            AggregationRoot = typeof(BookCategory),
                            ArchiveType     = ArchiveType.Cut
                        },
                    });

                    Assert.AreEqual(0, repo.CountAll(), "执行数据归档后数目为 0");
                    using (RdbDataProvider.RedirectDbSetting(DbSettingName, BackUpDbSettingName))
                    {
                        Assert.AreEqual(1, repo.CountAll(), "数据归档数据库数目为 1");
                    }
                    AssertAllDataMigrated(rawList, repo);
                }
        }
예제 #4
0
        public ActionResult CategoryList(int?categoryId, string sortField, int pageIndex = 1, SortOrder sortOrder = SortOrder.Desc)
        {
            sortField = sortField ?? "salesvolume";
            BookCategoryList  categoryList   = new BookCategoryList();
            PagedBookListInfo pagedBooksInfo = new PagedBookListInfo
            {
                Pagination = new PaginationInfo
                {
                    PageIndex = pageIndex,
                    SortField = sortField,
                    PageSize  = WebConfig.BookPageSize,
                    SortOrder = sortOrder
                },
                ActionName     = "CategoryList",
                ControllerName = "Book",
                PageParamName  = "categoryId",
                PageParamValue = categoryId.HasValue ? (object)categoryId.Value : null
            };

            // 分类列表
            if (categoryId == null)
            {
                categoryList.Children = (from c in ResolveService <IBookCategoryService>().GetAll()
                                         where c.Parent == null
                                         select c).ToList();
            }
            else
            {
                var parent = ResolveService <IBookCategoryService>().GetByID(categoryId.Value);
                categoryList.SelectedCategory = parent;
                if (parent.Children.Count <= 0)
                {
                    categoryList.Parent   = parent.Parent;
                    categoryList.Children = parent.Parent == null ?
                                            (from c in ResolveService <IBookCategoryService>().GetAll()
                                             where c.Parent == null
                                             select c).ToList():
                                            parent.Parent.Children.ToList();
                }
                else
                {
                    categoryList.Parent   = parent;
                    categoryList.Children = parent.Children.ToList();
                }
            }

            // 图书列表
            int total;

            if (categoryId == null)
            {
                pagedBooksInfo.Books = ResolveService <IBookService>().GetPagedBooksOnFront(pageIndex - 1, WebConfig.BookPageSize, sortField, sortOrder, out total);
            }
            else
            {
                pagedBooksInfo.Books = ResolveService <IBookService>().GetPagedCategoryBooks(categoryId.Value, pageIndex - 1, WebConfig.BookPageSize, sortField, sortOrder, out total);
            }
            pagedBooksInfo.Total = total;

            ViewBag.BookCategoryList = categoryList;

            return(View("BookList", pagedBooksInfo));
        }