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 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; } }