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


            var jsonData = new
            {
                total   = jqGridDataList.Total,
                page    = jqGridDataList.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));
        }
예제 #2
0
        public JsonResult OrdersForGrid(string sidx, string sord, int page, int rows)
        {
            if (!isAuth)
            {
                return(new JsonResult());
            }
            if (string.IsNullOrWhiteSpace(sidx))
            {
                sidx = "Id";
            }
            JqGridDataList jqGridDataList = new JqGridDataList();
            List <Order>   list           = jqGridDataList.GetOrdersByUser(sidx, sord, page, rows, CurrentUser.Id);


            var jsonData = new
            {
                total   = jqGridDataList.Total,
                page    = jqGridDataList.Page,
                records = list.Count,
                rows    = (
                    from order in list
                    select new
                {
                    order.Id,
                    Creation_Date = order.Creation_Date.ToString(),
                    order.Cost
                }
                    ).ToArray()
            };

            return(Json(jsonData
                        , JsonRequestBehavior.AllowGet));
        }
예제 #3
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));
        }
예제 #4
0
        public JsonResult AuthorForGrid(string sidx, string sord, int page, int rows)
        {
            if (!isAuth)
            {
                return(new JsonResult());
            }
            if (string.IsNullOrWhiteSpace(sidx))
            {
                sidx = "Id";
            }
            JqGridDataList jqGridDataList = new JqGridDataList();
            List <Author>  list           = jqGridDataList.GetAuthors(sidx, sord, page, rows);


            var jsonData = new
            {
                total   = jqGridDataList.Total,
                page    = page,
                records = list.Count,
                rows    = (
                    from a in list
                    select new
                {
                    AuthorId = a.Id,
                    a.Person.Name,
                    a.Person.Surname,
                    Books = (from ab in a.Authors_Books
                             select new
                    {
                        ab.Book_Id,
                        ab.Book.Name
                    }).ToArray()
                }
                    ).ToArray()
            };

            return(Json(jsonData
                        , JsonRequestBehavior.AllowGet));
        }
예제 #5
0
        public JsonResult UsersForGrid(string sidx, string sord, int page, int rows)
        {
            if (!isAuth)
            {
                return(new JsonResult());
            }
            if (string.IsNullOrWhiteSpace(sidx))
            {
                sidx = "Id";
            }
            JqGridDataList jqGridDataList = new JqGridDataList();
            List <User>    list           = jqGridDataList.GetUsers(sidx, sord, page, rows);


            var jsonData = new
            {
                total = jqGridDataList.Total,
                page,
                records = list.Count,
                rows    = (
                    from user in list
                    select new
                {
                    user.Id,
                    user.Person.Name,
                    user.Person.Surname,
                    Birthday = user.Person.BirthDay.ToString("yyyy MM dd"),
                    user.Email,
                    user.CartNumber,
                    Role = user.Role.Value
                }
                    ).ToArray()
            };

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