public void AddItemToCart(int ProductID) { //Get Product Data Product_table ProductInfo = context.Product_table.FirstOrDefault(s => s.Product_Id == ProductID); //creating Empty CartItem List //Add Product to CartItem MycartItems.ProductData = ProductInfo; MycartItems.ProductQty = 1; MycartItems.ProductTotalPrice = MycartItems.ProductData.Product_Price; CartModel MyCart = new CartModel(); bool oldCartCheck = checkForOldCart(); if (oldCartCheck == false) { MyCart = addToNewCart(); } else { MyCart = addToOldCart(ProductID); } // Add Cart to session HttpContext.Current.Session["cart"] = MyCart; RecalculateTotalPrice(); //return RedirectToAction("Home", "category"); }
public void AdminApprove(int id, string status) { Product_table product = new Product_table(); product = context.Product_table.Where(x => x.Product_Id == id).FirstOrDefault(); product.State = status; context.SaveChanges(); }
public List <Product_table> BestSellingForVendor(int VendorID) { var result = context.OrderDetails_table.GroupBy(e => e.Pro_Id) // group the list by country .OrderByDescending( // then sort by the summed values DESC g => g.Sum(e => e.Quantity)) .Select( // e.g. List.TopX(3) would return... r => new { ProID = r.Key, Sum = r.Sum(e => e.Quantity) }).ToList(); for (int i = 0; i < result.Count; i++) { int x = result[i].ProID; Product_table pro = context.Product_table.FirstOrDefault(s => s.Product_Id == x && s.Vendor_id == VendorID); if (pro != null) { selecttopProducts.Add(pro); } } return(selecttopProducts); }
public static void addnewproduct(ProductModel newproduct, string cat_name, int userid) { byte[] fileData = null; var binaryReader = new BinaryReader(newproduct.insertedimg.InputStream); fileData = binaryReader.ReadBytes(newproduct.insertedimg.ContentLength); using (CraftsEntities context = new CraftsEntities()) { var catid = int.Parse((from c in context.Category_table where c.Cat_Name == cat_name select c.Cat_Id).FirstOrDefault().ToString()); var pro = new Product_table { Product_Name = newproduct.Product_Name, Product_Description = newproduct.Product_Description, Product_Price = newproduct.Product_Price, Cat_id = catid, Image = fileData, Add_Date = DateTime.Now, Vendor_id = userid, State = "pending" }; context.Product_table.Add(pro); context.SaveChanges(); } }