private void MasterTextSelected(object sender, string selectedValue) { if (selectedValue != "") { productList.Items.Clear(); List <Product> queryResult = new List <Product>(); var _db = new fashionUtilityApplication.Models.ProductContext(); IQueryable <Product> query = _db.Products; //List listView1..Clear(); // clear list items before adding // filter the items match with search key and add result to list view System.Diagnostics.Debug.WriteLine(selectedValue); queryResult.AddRange(query.Where(i => i.ProductName.Contains(selectedValue) || i.Category.CategoryName.Contains(selectedValue) || i.Company.CompanyName.Contains(selectedValue) || i.Description.Contains(selectedValue) || i.Gender.GenderName.Contains(selectedValue) || i.Size.SizeName.Contains(selectedValue) || i.Color.ColorName.Contains(selectedValue) || i.UnitPrice.ToString().Contains(selectedValue)). ToArray()); productList.DataSource = (from row in queryResult select row).ToList(); productList.DataBind(); } else { productList.Items.Clear(); IQueryable itemList = GetProducts(); productList.DataSource = (from row in GetProducts() select row).ToList(); productList.DataBind(); } }
public IQueryable GetProducts() { var _db = new fashionUtilityApplication.Models.ProductContext(); IQueryable query = _db.Products; return(query); }
public void UpdateShoppingCartDatabase(String cartId, ShoppingCartUpdates[] CartItemUpdates) { using (var db = new fashionUtilityApplication.Models.ProductContext()) { try { int CartItemCount = CartItemUpdates.Count(); List <CartItem> myCart = GetCartItems(); foreach (var cartItem in myCart) { // Iterate through all rows within shopping cart list for (int i = 0; i < CartItemCount; i++) { if (cartItem.Product.ProductID == CartItemUpdates[i].ProductId) { if (CartItemUpdates[i].PurchaseQuantity < 1 || CartItemUpdates[i].RemoveItem == true) { RemoveItem(cartId, cartItem.ProductId); } else { UpdateItem(cartId, cartItem.ProductId, CartItemUpdates[i].PurchaseQuantity); } } } } } catch (Exception exp) { throw new Exception("ERROR: Unable to Update Cart Database - " + exp.Message.ToString(), exp); } } }
public IQueryable <Custom> GetCustoms() { var _db = new fashionUtilityApplication.Models.ProductContext(); IQueryable <Custom> query = _db.Customs; return(query); }
public IQueryable <Company> GetCompanies() { var _db = new fashionUtilityApplication.Models.ProductContext(); IQueryable <Company> query = _db.Compaines; return(query); }
public IQueryable <Size> GetSizes() { var _db = new fashionUtilityApplication.Models.ProductContext(); IQueryable <Size> query = _db.Sizes; return(query); }
public IQueryable <Gender> GetGenders() { var _db = new fashionUtilityApplication.Models.ProductContext(); IQueryable <Gender> query = _db.Genders; return(query); }
public IQueryable <Category> GetCategories() { var _db = new fashionUtilityApplication.Models.ProductContext(); IQueryable <Category> query = _db.Categories; query = query.Where(p => p.CategoryID != 12 && p.CategoryID != 4 && p.CategoryID != 9 && p.CategoryID != 11); return(query); }
public IQueryable <Product> GetProduct([QueryString("productID")] int?productId) { var _db = new fashionUtilityApplication.Models.ProductContext(); IQueryable <Product> query = _db.Products; if (productId.HasValue && productId > 0) { query = query.Where(p => p.ProductID == productId); } else { query = null; } return(query); }
public IQueryable <Product> GetProducts() { int categoryID = -1; if (Request.QueryString["id"] != null) { categoryID = Convert.ToInt32(Request.QueryString["id"]); } var _db = new fashionUtilityApplication.Models.ProductContext(); IQueryable <Product> query = _db.Products; if (categoryID != -1 && categoryID > 0) { query = query.Where(p => p.CategoryID == categoryID); Session["categoryid"] = categoryID; } return(query); }
public void UpdateItem(string updateCartID, int updateProductID, int quantity) { using (var _db = new fashionUtilityApplication.Models.ProductContext()) { try { var myItem = (from c in _db.ShoppingCartItems where c.CartId == updateCartID && c.Product.ProductID == updateProductID select c).FirstOrDefault(); if (myItem != null) { myItem.Quantity = quantity; _db.SaveChanges(); } } catch (Exception exp) { throw new Exception("ERROR: Unable to Update Cart Item - " + exp.Message.ToString(), exp); } } }
public void RemoveItem(string removeCartID, int removeProductID) { using (var _db = new fashionUtilityApplication.Models.ProductContext()) { try { var myItem = (from c in _db.ShoppingCartItems where c.CartId == removeCartID && c.Product.ProductID == removeProductID select c).FirstOrDefault(); if (myItem != null) { // Remove Item. _db.ShoppingCartItems.Remove(myItem); _db.SaveChanges(); } } catch (Exception exp) { throw new Exception("ERROR: Unable to Remove Cart Item - " + exp.Message.ToString(), exp); } } }
protected void RemoveProductButton_Click(object sender, EventArgs e) { using (var _db = new fashionUtilityApplication.Models.ProductContext()) { int productId = Convert.ToInt16(DropDownRemoveProduct.SelectedValue); var myItem = (from c in _db.Products where c.ProductID == productId select c).FirstOrDefault(); if (myItem != null) { _db.Products.Remove(myItem); _db.SaveChanges(); // Reload the page. string pageUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.Count() - Request.Url.Query.Count()); Response.Redirect(pageUrl + "?ProductAction=remove"); } else { LabelRemoveStatus.Text = "Unable to locate product."; } } }
public void sortList_SelectedIndexChanged(object sender, EventArgs e) { System.Diagnostics.Debug.WriteLine(sortList.SelectedValue); System.Diagnostics.Debug.WriteLine("monster"); productList.Items.Clear(); var _db = new fashionUtilityApplication.Models.ProductContext(); IQueryable <Product> query = _db.Products; switch (sortList.SelectedValue) { case "plth": System.Diagnostics.Debug.WriteLine(sortList.SelectedValue); query = query.OrderBy(o => o.UnitPrice); break; case "phtl": query = query.OrderByDescending(o => o.UnitPrice); break; case "Name Asc": query = query.OrderBy(o => o.ProductName); break; case "Name Des": query = query.OrderByDescending(o => o.ProductName); break; case "Product ID Asc": query = query.OrderBy(o => o.ProductID); break; case "Product ID Des": query = query.OrderByDescending(o => o.ProductID); break; } productList.DataSource = query.ToList(); productList.DataBind(); }