public ViewResult Products(string category, int page = 1) { if (category == null) { ProductsListView model = new ProductsListView() { Products = repository.Products .OrderBy(p => p.ProductID) .Skip((page - 1) * pageSize) .Take(pageSize) }; return(View(model)); } else { ProductsListView model = new ProductsListView() { Products = repository.Products .Where(p => p.Category == category) .OrderBy(p => p.ProductID) .Skip((page - 1) * pageSize) .Take(pageSize), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = pageSize, TotalItems = category == null? repository.Products.Count() : repository.Products.Where(product => product.Category == category).Count() }, CurrentCategory = category }; return(View(model)); } }
public ActionResult List(ShopCartItemServiceClient cart, string category, string subcategory, int page = 1, string name = null) { ProductsListView productsList = new ProductsListView { CurrentCategory = category, SubCategory = subcategory, ProductName = name, PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = name == null?dataRepository.GetList().Where(x => x.SubCategory == subcategory).Count() : dataRepository.GetList().Where(x => x.Name.Contains(name)).Count() }, ProductCatalog = subcategory != null?dataRepository.GetList() .Where(x => x.SubCategory == subcategory || x.SubCategory == null) .OrderBy(x => x.ID) .Skip((page - 1) * PageSize) .Take(PageSize) : dataRepository.GetList().Where(x => x.Name.Contains(name)) .OrderBy(x => x.ID).Skip((page - 1) * PageSize).Take(PageSize), Cart = cart }; productsList.CountActualProduct(); return(View(productsList)); }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { ProductsListView.DataBind(); } }
public void Index() { var view = new ProductsListView(); view.Products = _repository.GetProducts(); return(View(view)); }
public ActionResult Index(string filter, string category, int page = 1) { int PageSize = 12; ViewBag.keywords = string.Format(Helper.GetKeywords(category), string.Empty); ViewBag.description = string.Format(Helper.GetKeywords(category), string.Empty); ViewBag.IsActiveProduct = "active"; ViewBag.Category = category == null ? "Електротовари" : category; ViewBag.Filter = filter == null ? "Уся продукція" : filter; ProductsListView model = new ProductsListView { Products = new CachedProductsRepository().GetFiltersProducts(page, PageSize, category, filter), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = new CachedProductsRepository().GetTotalPages(category, filter) }, CurrentCategory = category, CurrentFilter = filter }; TempData["category"] = category == null ? "" : category; return(View(model)); }
private void cargarListViewProductos() { try { wsProducto.producto[] productos = productoClient.obtenerProducto(); ProductsListView.DataSource = productos; ProductsListView.DataBind(); //var listadto = productoClient.obtenerProducto(); //var nuevolistadto = (from o in listadto // orderby o.productoId // where o.categoriaProductoId == 1 //Puedes comprobar los id cambiando este valor // select new // { // Id = o.productoId, // Nombre = o.nombreProducto, // Imagen = o.imagenProdcuto, // Porciones = o.porcionesProdcuto, // Precio = o.precioProducto, // Descripción = o.descripcionProducto, // Disponibilidad = o.disponibilidadProducto // }).ToList(); //ProductsListView.DataSource = nuevolistadto; //ProductsListView.DataBind(); } catch (Exception ex) { } }
public void OnDelete(object sender, EventArgs e) { var mi = ((MenuItem)sender); WeekDayPageModel pageModel = (WeekDayPageModel)BindingContext; var product = (Food)mi.CommandParameter; ProductsListView.BeginRefresh(); var result = DatabaseConnection.Connection.DeleteAsync(product); result.Wait(); if (result.IsCompleted) { pageModel.RefreshList(); ProductsListView.EndRefresh(); } }
private void BindProducts(int subcategoryId, bool isSub, string orderBy, string searchValue) { try { lblProductMsg.Text = "No Products Found"; DataSet products = null; if (searchValue == string.Empty) { products = (new ProductsDAL()).GetProducts(subcategoryId, isSub, orderBy); } else { products = (new ProductsDAL()).GetProductSearch(subcategoryId, searchValue, orderBy); } if (products != null && products.Tables[0].Rows.Count > 0) { lblProductMsg.Text = ""; ProductsListView.DataSource = products; ProductsListView.DataBind(); dpProducts.Visible = true; } else { ProductsListView.DataSource = null; ProductsListView.DataBind(); dpProducts.Visible = false; } lblNavBar.Text = "All Categories"; if (ViewState["Category"] != null && ViewState["Category"].ToString() != string.Empty) { lblNavBar.Text += " >> " + ViewState["Category"].ToString(); } if (ViewState["SubCat"] != null && ViewState["SubCat"].ToString() != string.Empty) { lblNavBar.Text += " >> " + ViewState["SubCat"].ToString(); } } catch (Exception ex) { string strErrCode = ERROR_DISPLAY_MESSAGE + "," + (new Error_Log()).LogErrorIntoDB(ex, "BindProducts", subcategoryId.ToString(), isSub.ToString(), orderBy, searchValue); lblErr.Text = strErrCode; } }
public ViewResult List(string category, int page = 1) { ProductsListView model = new ProductsListView { Products = repository.Products.Where(p => category == null || p.Category == category) .OrderBy(p => p.ProductID) .Skip((page - 1) * PageSize) .Take(PageSize), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = category == null ? repository.Products.Count() : repository.Products.Where(e => e.Category == category).Count() }, CurrentCategory = category }; return View(model); }
private void GetAndBindProducts(string category) { if (!string.IsNullOrEmpty(SearchTextBox.Text.Trim())) { this.search = SearchTextBox.Text.Trim(); } if (string.IsNullOrEmpty(this.search)) { l1 = ProductsDAO.GetPRODUCTsByCategory(category); ProductsListView.DataSource = l1; ProductsListView.DataBind(); } else { l1 = ProductsDAO.GetPRODUCTsByCategorySearch(category, this.search.Trim()); ProductsListView.DataSource = l1; ProductsListView.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (HttpContext.Current.Session == null || HttpContext.Current.Session["admin"] == null) { Response.Redirect("~/LoginP.aspx"); } Page.Header.Title = "Fast food - Menu"; if (IsPostBack == false) { SearchTextBox.Text = ""; this.category = "Beverages"; CategoryTextBox.Text = this.category; l1 = ProductsDAO.GetPRODUCTsByCategory(this.category); ProductsListView.DataSource = l1; ProductsListView.DataBind(); } }
private void GetAndBindUnavailableProducts() { if (!string.IsNullOrEmpty(SearchTextBox.Text.Trim())) { this.search = SearchTextBox.Text.Trim(); } if (string.IsNullOrEmpty(this.search)) { l1 = ProductsDAO.GetUnavailablePRODUCTs(); ProductsListView.DataSource = l1; ProductsListView.DataBind(); } else { l1 = ProductsDAO.GetUnavailablePRODUCTsBySearch(this.search.Trim()); ProductsListView.DataSource = l1; ProductsListView.DataBind(); } }
protected void ProductsListView_ItemCommand(object sender, ListViewCommandEventArgs e) { switch (e.CommandName) { case "ShowInsertView": ProductsListView.InsertItemPosition = InsertItemPosition.LastItem; ProductsListView.DataBind(); ProductsListView.InsertItem.DataBind(); break; case "HideInsertView": ProductsListView.InsertItemPosition = InsertItemPosition.None; break; case "AddToCart": var cart = new ShoppingCart(); cart.AddProduct(Convert.ToInt32(e.CommandArgument)); break; case "Delete": ProductsDataSource.DeleteParameters.Add("ID", e.CommandArgument.ToString()); break; } }
private async void ProductsListView_OnRefreshing(object sender, EventArgs e) { await GetPosts(); ProductsListView.EndRefresh(); }
protected void ProductsDataSource_Deleted(object sender, ObjectDataSourceStatusEventArgs e) { ProductsListView.DataBind(); }
protected void ProductsDataSource_Inserted(object sender, ObjectDataSourceStatusEventArgs e) { ProductsListView.InsertItemPosition = InsertItemPosition.None; ProductsListView.DataBind(); }