Example #1
0
 public static int CountProducts()
 {
     using (var db = new TradeDb())
     {
         return db.Products.Count();
     }
 }
Example #2
0
 public static void PrintCustomers()
 {
     using (var db = new TradeDb())
     {
         foreach (var customer in db.Customers)
         {
             Console.WriteLine(customer.Id + " , " + customer.Name+"\n" + customer.Address);
         }
     }
 }
Example #3
0
 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}");
         }
     }
 }
Example #4
0
 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();
     }
 }