public string Binding() { GridRequestParameters param = GridRequestParameters.Current; List <Context.MasterProduct> items = RepoProduct.FindAll(param.Skip, param.Take, (param.Sortings != null ? param.Sortings.ToList() : null), param.Filters); List <Product> ListModel = new List <Product>(); foreach (Context.MasterProduct item in items) { ListModel.Add(new Product(item)); } int total = RepoProduct.Count(param.Filters); return(new JavaScriptSerializer().Serialize(new { total = total, data = ListModel })); }
public IEnumerable <Product> GetFilteredProduct(Filter filter) { if (filter.CurrentPage < 0 || filter.ItemsPrPage < 0) { throw new InvalidDataException("CurrentPage and ItemsPage must be zero or above"); } if ((filter.CurrentPage - 1 * filter.ItemsPrPage) >= _productRepo.Count()) { throw new InvalidDataException("Index is out of bounds"); } return(_productRepo.ReadAllProducts(filter)); }