Esempio n. 1
0
        public GridData Data(GridRequest request)
        {
            var total = decimal.Divide(_service.AllProducts().Count(), request.Rows);
            var data  = new GridData
            {
                Total = (int)Math.Ceiling(total),
                Page  = request.Page
            };
            var products = _service.AllProducts()
                           .Skip(request.Index * request.Rows)
                           .Take(request.Rows);

            products
            .Select(x => new GridRow
            {
                Id          = x.Id,
                Name        = x.Name,
                Description = new string(x.Description.Take(50).ToArray()),
                Quantity    = x.Quantity
            })
            .Each(data.AddRow);
            return(data);
        }
Esempio n. 2
0
        public GridData Data(GridRequest request)
        {
            var total = decimal.Divide(_service.AllProducts().Count(), request.Rows);
            var data = new GridData
                           {
                               Total = (int) Math.Ceiling(total),
                               Page = request.Page
                           };
            var products = _service.AllProducts()
                .Skip(request.Index * request.Rows)
                .Take(request.Rows);

            products
                .Select(x => new GridRow
                                 {
                                     Id = x.Id,
                                     Name = x.Name,
                                     Description = new string(x.Description.Take(50).ToArray()),
                                     Quantity = x.Quantity
                                 })
                .Each(data.AddRow);
            return data;
        }