Beispiel #1
0
        public JsonResult BookForGrid(string sidx, string sord, int page, int rows)
        {
            /*if (!isAuth)
             *      return new JsonResult();*/
            if (string.IsNullOrWhiteSpace(sidx))
            {
                sidx = "ISBN";
            }
            JqGridDataList jqGridDataList = new JqGridDataList();
            List <Book>    list           = jqGridDataList.GetBooks(sidx, sord, page, rows);


            var jsonData = new
            {
                total   = jqGridDataList.Total,
                page    = page,
                records = list.Count,
                rows    = (
                    from books in list
                    select new
                {
                    books.ISBN,
                    books.Name,
                    Cost = (books.Cost != null)?books.Cost.Value.ToString() : ""
                }
                    ).ToArray()
            };

            return(Json(jsonData
                        , JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        public JsonResult BookForGrid(string sidx, string sord, int page, int rows)
        {
            if (!isAuth)
            {
                return(new JsonResult());
            }
            if (string.IsNullOrWhiteSpace(sidx))
            {
                sidx = "ISBN";
            }
            JqGridDataList jqGridDataList = new JqGridDataList();
            List <Book>    list           = jqGridDataList.GetBooks(sidx, sord, page, rows);


            var jsonData = new
            {
                total = jqGridDataList.Total,
                page,
                records = list.Count,
                rows    = (
                    from books in list
                    select new
                {
                    books.ISBN,
                    books.FilePath,
                    books.ISBN_Tome,
                    books.Description,
                    NextPart = (books.Nextpart == null ? "" : books.Nextpart.Name),
                    PreviousPart = (books.PreviousBook == null ? "" : books.PreviousBook.Name),
                    books.RealiseYear,
                    books.Cover,
                    books.Name,
                    Cost = (books.Cost != null) ? books.Cost.Value.ToString() : "",
                    Authors = (from ab in books.Authors_Books
                               select new
                    {
                        ab.Author_Id,
                        Name = string.Format("{0} {1}", ab.Author.Person.Name, ab.Author.Person.Surname)
                    })
                }
                    ).ToArray()
            };

            return(Json(jsonData
                        , JsonRequestBehavior.AllowGet));
        }