// GET: BookManage
        public ActionResult Index(string bookName, long searchselectedID = 0, bool? isAvaliable = null, Int32 pageIndex = 0)
        {
            if (!string.IsNullOrEmpty(bookName))
            {
                bookName = bookName.Trim();
            }

            BookManageIndexModel model = new BookManageIndexModel();

            BookInfoCondition condition = new BookInfoCondition();
            condition.BookName = bookName;
            condition.CategoryID = searchselectedID;
            condition.IsAvaliable = isAvaliable;

            IEnumerable<BookInfo> books = this.IBookInfoDataProvider.GetBookList(condition);

            PagingContentFormat2<BookInfo> paging = new PagingContentFormat2<BookInfo>(books, pageIndex, 6);

            foreach (var item in paging.EntityList)
            {
                model.BookModelList.Add(BookModel.GetViewModel(item, this.LoginUser()));
            }

            model.SearchBookName = bookName;
            model.SearchCategoryList = DropDownListHelper.GetCategorySelectListBySelectedID(searchselectedID);
            model.PagingContent = paging;

            return View(model);
        }
        // GET: BooksServer
        public JsonResult Index(string bookName, int pageIndex = 0)
        {
            List<BookServerModel> modelList = new List<BookServerModel>();

            BookInfoCondition condition = new BookInfoCondition();
            condition.BookName = bookName;

            IEnumerable<BookInfo> books = this.IBookInfoDataProvider.GetBookList(condition);

            PagingContent<BookInfo> paging = new PagingContent<BookInfo>(books, pageIndex);

            foreach (var item in paging.EntityList)
            {
                modelList.Add(BookServerModel.GetServerModel(item));
            }

            return Json(modelList, JsonRequestBehavior.AllowGet);
        }
Example #3
0
        public static PublisherModel GetViewModel(PublisherInfo publisher)
        {
            PublisherModel model = new PublisherModel();

            model.ID = publisher.ID;
            model.PublisherName = publisher.PublisherName;
            model.PublisherIntroduction = publisher.PublisherIntroduction;

            IBookInfoDataProvider iBookInfoDataProvider = new BookInfoDataProvider();
            BookInfoCondition condition = new BookInfoCondition();
            condition.Publisher = publisher;

            if ( iBookInfoDataProvider.GetBookList(condition).Count() > 0)
            {
                model.IsUse = true;
            }

            return model;
        }
        public IEnumerable<BookInfo> GetBookList(BookInfoCondition condition)
        {
            IEnumerable<BookInfo> bookList = this.DataSource.BookInfos;

            if (condition.CategoryID > 0)
            {
                var bcr = this.DataSource.BookAndCategoryRelation;
                var categorys = this.DataSource.CategoryInfos;
                bookList = from r in bcr
                           join b in bookList on r.Book_ID equals b.ID
                           join c in categorys on r.Category_ID equals c.ID
                           where c.ID == condition.CategoryID
                           select b;
            }

            if (!String.IsNullOrEmpty(condition.BookName))
            {
                bookList = bookList.Where(b => b.BookName.Contains(condition.BookName));
            }

            if (condition.Publisher != null)
            {
                bookList = bookList.Where(b => b.PublisherInfo.ID == condition.Publisher.ID);
            }

            if (condition.IsAvaliable.HasValue)
            {
                if (condition.IsAvaliable.Value)
                {
                    bookList = bookList.Where(b => b.Avaliable_Inventory > 0);
                }
            }

            bookList = bookList.OrderByDescending(b => b.Publish_Date);

            return bookList;
        }