public PagedList <CartItemOverviewModel> GetPagedCartItemOverviewModels( int pageIndex = 0, int pageSize = 2147483647, //Int32.MaxValue IList <int> productIds = null, IList <int> userIds = null, string name = null, CartItemSortingType orderBy = CartItemSortingType.IdAsc) { var list = GetCartItemLoadPaged( pageIndex, pageSize, productIds, userIds, name, orderBy); var items = new Collection <CartItemOverviewModel>(); for (int i = 0; i < list.Items.Count; i++) { var item = BuildCartItemOverviewModel(list.Items[i]); items.Add(item); } return(new PagedList <CartItemOverviewModel>(items, pageIndex, pageSize, list.TotalCount)); }
private void LoadProducts() { int[] userIds = null; int[] productIds = null; string name = null; CartItemSortingType orderBy = CartItemSortingType.IdDesc; userIds = new int[] { QueryUserId }; if (HasState("OrderBy")) { orderBy = (CartItemSortingType)GetIntState("OrderBy"); } if (HasState(PRODUCT_ID_FILTER)) { string value = GetStringState(PRODUCT_ID_FILTER); int temp; productIds = value.Split(',') .Where(x => int.TryParse(x.ToString(), out temp)) .Select(x => int.Parse(x)) .ToArray(); } if (HasState(NAME_FILTER)) { name = GetStringState(BRAND_NAME_FILTER); } var result = CartService.GetPagedCartItemOverviewModels( pageIndex: gvCart.CustomPageIndex, pageSize: gvCart.PageSize, productIds: productIds, userIds: userIds, name: name, orderBy: orderBy); if (result != null) { gvCart.DataSource = result.Items; gvCart.RecordCount = result.TotalCount; gvCart.CustomPageCount = result.TotalPages; if (result.Items.Count > 0) { phSendEmailAbdnCart.Visible = true; } else { phSendEmailAbdnCart.Visible = false; } } gvCart.DataBind(); }
public PagedList <CartItem> GetCartItemLoadPaged( int pageIndex = 0, int pageSize = 2147483647, //Int32.MaxValue IList <int> productIds = null, IList <int> userIds = null, string name = null, CartItemSortingType orderBy = CartItemSortingType.IdAsc) { var pName = GetParameter("Name", name); var pOrderBy = GetParameter("OrderBy", (int)orderBy, true); var pPageIndex = GetParameter("PageIndex", pageIndex, true); var pPageSize = GetParameter("PageSize", pageSize); var pTotalRecords = GetParameterIntegerOutput("TotalRecords"); if (productIds != null && productIds.Contains(0)) { productIds.Remove(0); } string commaSeparatedProductIds = productIds == null ? "" : string.Join(",", productIds); var pProductIds = GetParameter("ProductIds", commaSeparatedProductIds); if (userIds != null && userIds.Contains(0)) { userIds.Remove(0); } string commaSeparatedUserIds = userIds == null ? "" : string.Join(",", userIds); var pUserIds = GetParameter("UserIds", commaSeparatedUserIds); var items = _dbContext.ExecuteStoredProcedureList <CartItem>( "CartItem_LoadPaged", pProductIds, pUserIds, pName, pOrderBy, pPageIndex, pPageSize, pTotalRecords); //return accounts int totalRecords = (pTotalRecords.Value != DBNull.Value) ? Convert.ToInt32(pTotalRecords.Value) : 0; return(new PagedList <CartItem>(items, pageIndex, pageSize, totalRecords)); }