/// <summary>
 /// Create a new Order object.
 /// </summary>
 /// <param name="orderID">Initial value of the OrderID property.</param>
 /// <param name="numberOfSeatsReserved">Initial value of the NumberOfSeatsReserved property.</param>
 /// <param name="totalPrice">Initial value of the TotalPrice property.</param>
 /// <param name="perfomanceID">Initial value of the PerfomanceID property.</param>
 /// <param name="userID">Initial value of the UserID property.</param>
 public static Order CreateOrder(global::System.Int32 orderID, global::System.Int32 numberOfSeatsReserved, global::System.Decimal totalPrice, global::System.Int32 perfomanceID, global::System.Guid userID)
 {
     Order order = new Order();
     order.OrderID = orderID;
     order.NumberOfSeatsReserved = numberOfSeatsReserved;
     order.TotalPrice = totalPrice;
     order.PerfomanceID = perfomanceID;
     order.UserID = userID;
     return order;
 }
 /// <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);
 }
Example #3
0
        //Method that submits the order
        public UserOrderDTO CreateOrder(UserOrderDTO NewOrder)
        {
            UserOrderDTO OrderOut = new UserOrderDTO();
            Order OrderIn = new Order();

            using (TransactionScope Trans = new TransactionScope())
            {
                try
                {
                    using (var context = new CinemaEntities())
                    {
                        OrderIn.NumberOfSeatsReserved = NewOrder.NumberOfSeats;
                        OrderIn.TotalPrice = NewOrder.TotalPrice;
                        OrderIn.UserID = NewOrder.UserID;
                        OrderIn.PerfomanceID = NewOrder.PerformanceID;

                        if (OrderIn.EntityState == EntityState.Detached)
                        {
                            context.Orders.AddObject(OrderIn);
                        }
                        context.SaveChanges();

                        OrderOut.OrderID = OrderIn.OrderID;
                    }
                }
                catch
                {
                    OrderOut.isValid = false;
                    Trans.Dispose();
                    return OrderOut;
                }
                OrderOut.isValid = true;
                Trans.Complete();
                return OrderOut;
            }
        }