Exemplo n.º 1
0
        private DatatableDTO <ProductDTO> CreateDatatableDTO(List <ProductDTO> products, DataTable datatable)
        {
            DatatableDTO <ProductDTO> datatableDTO = new DatatableDTO <ProductDTO>()
            {
                draw            = datatable.Draw,
                recordsTotal    = datatable.RecordsTotal,
                recordsFiltered = datatable.RecordFiltered,
                data            = products
            };

            return(datatableDTO);
        }
Exemplo n.º 2
0
        public ActionResult GetProducts()
        {
            List <Product> Products = dgrosStore.Products
                                      .Where(p => p.State == STATE).OrderBy(p => p.ProductId).ToList();

            DataTable Datatable = CreateDatatableObjectWithRequestValues(Request);

            Datatable.RecordsTotal = Products.Count();

            if (!String.IsNullOrEmpty(Datatable.Search))
            {
                Products = GetProductByParam(Datatable.Search);
            }

            Datatable.RecordFiltered = Products.Count();

            List <ProductDTO>         productDTOlist = GetOrderedAndPagedProductDTOList(Products, Datatable);
            DatatableDTO <ProductDTO> datatableDTO   = CreateDatatableDTO(productDTOlist, Datatable);

            return(Json(datatableDTO, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public ActionResult GetProductByCategory(string category)
        {
            List <Product> categoryProducts = dgrosStore.Products
                                              .Include(p => p.Category)
                                              .Where(p => p.Category.Name == category)
                                              .Where(p => p.State == STATE)
                                              .ToList();

            DataTable Datatable = CreateDatatableObjectWithRequestValues(Request);

            Datatable.RecordsTotal = categoryProducts.Count();

            if (!String.IsNullOrEmpty(Datatable.Search))
            {
                categoryProducts = GetProductAndCategoryByParam(category, Datatable.Search);
            }

            Datatable.RecordFiltered = categoryProducts.Count();
            //order,paging
            List <ProductDTO>         productDTOlist = GetOrderedAndPagedProductDTOList(categoryProducts, Datatable);
            DatatableDTO <ProductDTO> datatableDTO   = CreateDatatableDTO(productDTOlist, Datatable);

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