public void UpDateProduct() { ConECommerceContext context = new ConECommerceContext(); var product = context.Products.Single(p => p.Name == "Parle G"); product.Price = 50; context.SaveChanges(); DisplayProduct(); }
public void RemoveData() { ConECommerceContext context = new ConECommerceContext(); var product = context.Products.Single(p => p.Id == 6); context.Remove(product); context.SaveChanges(); DisplayProduct(); }
public void AddProduct() { ConECommerceContext context = new ConECommerceContext(); Product obj_Product = new Product(); Console.WriteLine("Please Add Product's Name : - "); obj_Product.Name = Console.ReadLine(); Console.WriteLine("Please Add Product's Price : - "); obj_Product.Price = Convert.ToInt16(Console.ReadLine()); context.Add(obj_Product); context.SaveChanges(); }