Exemple #1
0
        /// <summary>
        /// Create a new Order_item object.
        /// </summary>
        /// <param name="item_id">Initial value of the item_id property.</param>
        /// <param name="order_number">Initial value of the order_number property.</param>
        /// <param name="product_desc">Initial value of the product_desc property.</param>
        /// <param name="quantity">Initial value of the quantity property.</param>
        public static Order_item CreateOrder_item(global::System.Int32 item_id, global::System.Int32 order_number, global::System.String product_desc, global::System.Int32 quantity)
        {
            Order_item order_item = new Order_item();

            order_item.item_id      = item_id;
            order_item.order_number = order_number;
            order_item.product_desc = product_desc;
            order_item.quantity     = quantity;
            return(order_item);
        }
        //Method #5
        //Creates an entry in the Items table.
        public static bool addItemToOrder(Order_item newItem)
        {
            using (var context = new CustomersEntities())
            {
                context.ContextOptions.LazyLoadingEnabled = false;
                context.Order_item.AddObject(newItem);

                bool sucess = context.SaveChanges() == 1;
                if (sucess)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
        //Method #6
        //Creates an entry in the Items table.
        public static bool removeItemFromOrder(Order_item deleteItem)
        {
            using (var context = new CustomersEntities())
            {
                context.ContextOptions.LazyLoadingEnabled = false;
                context.Attach(deleteItem);
                context.Order_item.DeleteObject(deleteItem);

                bool sucess = context.SaveChanges() == 1;
                if (sucess)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Exemple #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Order_item EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToOrder_item(Order_item order_item)
 {
     base.AddObject("Order_item", order_item);
 }