public static int CountProducts() { using (var db = new TradeDb()) { return db.Products.Count(); } }
public static void PrintCustomers() { using (var db = new TradeDb()) { foreach (var customer in db.Customers) { Console.WriteLine(customer.Id + " , " + customer.Name+"\n" + customer.Address); } } }
private static void PrintProducts() { using (var db = new TradeDb()) { foreach (var product in db.Products) { Console.WriteLine($"Id: {product.Id}, Name: {product.Name}, Price: {product.Price}, Desc: {product.Description}"); } } }
private static void AddNewCustomer() { Console.WriteLine("Please specify Name: "); var name = Console.ReadLine(); Console.WriteLine("Please specify Address:\nSplit street and city/zipcode with a \",\""); var address = Console.ReadLine(); using (var db = new TradeDb()) { db.Customers.Add(new Customer() {Address = address, Name = name}); db.SaveChanges(); } }