public bool AddProduct() // ProductTable Methods { try { Product newproduct = new Product(); newproduct.Itemname = HttpContext.Current.Session["add_pname"].ToString(); newproduct.Itemfor = HttpContext.Current.Session["add_pfor"].ToString(); newproduct.Category = HttpContext.Current.Session["add_category"].ToString(); newproduct.Sizes = HttpContext.Current.Session["add_sizes"].ToString(); newproduct.Available = Convert.ToInt32(HttpContext.Current.Session["add_available"].ToString()); newproduct.Price = Convert.ToInt32(HttpContext.Current.Session["add_price"].ToString()); newproduct.Currency = HttpContext.Current.Session["add_currency"].ToString(); newproduct.Cost = Convert.ToInt32(HttpContext.Current.Session["add_cost"].ToString()); newproduct.Offer = Convert.ToInt32(HttpContext.Current.Session["add_offer"].ToString()); ProductTable.Add(newproduct); SaveChanges(); return(true); } catch (Exception ex) { Console.WriteLine(ex); return(false); } }
private void BuildTable(IEnumerable <Product> products) { foreach (var prod in products) { ProductTable.Add( new Product { Id = prod.Id, Name = prod.Name, Description = prod.Description, Quantity = prod.Quantity, Price = prod.Price, Unit = prod.Unit, CategoryId = prod.CategoryId, CategoryName = prod.CategoryName, }); } }