/// <summary>
 /// Create a new Order object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="userName">Initial value of the userName property.</param>
 /// <param name="placed_at">Initial value of the placed_at property.</param>
 public static Order CreateOrder(global::System.Int32 id, global::System.String userName, global::System.DateTime placed_at)
 {
     Order order = new Order();
     order.id = id;
     order.userName = userName;
     order.placed_at = placed_at;
     return order;
 }
 public static bool SubmitOrder(string username)
 {
     var proxy = new ShoppingCartProxy.ShoppingCartServiceClient();
     var cartItems = proxy.GetCartItems(username);
     bool success = false;
     if (cartItems != null && cartItems.Length > 0)
     using (var db = new OrderSystemEntities())
     {
         var order = new Order {placed_at = DateTime.Now, userName = username};
         db.AddToOrders(order);
         foreach (var cartItem in cartItems)
         {
             var orderItem = new OrderItem();
             orderItem.Created = cartItem.Created;
             orderItem.ItemName = cartItem.Item;
             orderItem.Modified = cartItem.Modified;
             orderItem.Price = cartItem.Price;
             orderItem.Quantity = cartItem.Quantity;
             orderItem.Order = order;
             order.OrderItems.Add(orderItem);
             db.AddToOrderItems(orderItem);
         }
         success = db.SaveChanges() > 0;
     }
     if(success)
     {
         proxy.RemoveCartByUsername(username);
     }
     proxy.Close();
     return success;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Orders EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToOrders(Order order)
 {
     base.AddObject("Orders", order);
 }