public void AddOrder(Order order) { try { using (var db = new MMDatabaseEntities()) { db.Database.Connection.Open(); db.Orders.Add(order); db.SaveChanges(); } } catch (Exception e) { Console.WriteLine(e); throw; } }
public List <Customer> ListCustomers() { var customerList = new List <Customer>(); try { using (var db = new MMDatabaseEntities()) { db.Database.Connection.Open(); customerList = db.Customers.ToList(); } return(customerList); } catch (Exception e) { Console.WriteLine(e); throw; } }
public List <Product> ListProducts() { var productList = new List <Product>(); try { using (var db = new MMDatabaseEntities()) { db.Database.Connection.Open(); productList = db.Products.ToList(); } return(productList); } catch (Exception e) { Console.WriteLine(e); throw; } }
public void UpdateOrder(int id, int quantity) { try { using (var db = new MMDatabaseEntities()) { db.Database.Connection.Open(); Order order = db.Orders.SingleOrDefault((o) => o.Id == id); if (order != null) { order.Quantity = quantity; } db.SaveChanges(); } } catch (Exception e) { Console.WriteLine(e); throw; } }