/// <summary>
 /// Create a new OrderDetail object.
 /// </summary>
 /// <param name="orderDetailId">Initial value of the OrderDetailId property.</param>
 /// <param name="productId">Initial value of the ProductId property.</param>
 /// <param name="colorId">Initial value of the ColorId property.</param>
 /// <param name="orderDetailStatusId">Initial value of the OrderDetailStatusId property.</param>
 /// <param name="gift">Initial value of the Gift property.</param>
 /// <param name="quantity">Initial value of the Quantity property.</param>
 /// <param name="price">Initial value of the Price property.</param>
 /// <param name="addedDate">Initial value of the AddedDate property.</param>
 /// <param name="sizeId">Initial value of the SizeId property.</param>
 public static OrderDetail CreateOrderDetail(global::System.Int32 orderDetailId, global::System.Int32 productId, global::System.Int32 colorId, global::System.Int32 orderDetailStatusId, global::System.Boolean gift, global::System.Int32 quantity, global::System.Decimal price, global::System.DateTime addedDate, global::System.Int32 sizeId)
 {
     OrderDetail orderDetail = new OrderDetail();
     orderDetail.OrderDetailId = orderDetailId;
     orderDetail.ProductId = productId;
     orderDetail.ColorId = colorId;
     orderDetail.OrderDetailStatusId = orderDetailStatusId;
     orderDetail.Gift = gift;
     orderDetail.Quantity = quantity;
     orderDetail.Price = price;
     orderDetail.AddedDate = addedDate;
     orderDetail.SizeId = sizeId;
     return orderDetail;
 }
        public string OrderDetailAdd(FormCollection formCollection)
        {
            try
            {
                OrderDetail orderDetail = new OrderDetail();
                TryUpdateModel(orderDetail, formCollection);

                orderDetail.ProductId = Convert.ToInt16(formCollection["ProductId_VI"]);
                orderDetail.ColorId = Convert.ToInt16(formCollection["ColorId_VI"]);
                orderDetail.SizeId = Convert.ToInt16(formCollection["SizeId_VI"]);

                var product = hopeLingerieEntities.Products.Single(x=>x.ProductId == orderDetail.ProductId && x.Active);

                orderDetail.Price = product.CurrentPrice;

                if (orderDetail.SizeId == 0) throw new Exception();

                orderDetail.ProductId = Convert.ToInt32(formCollection["ProductID_VI"]);
                orderDetail.AddedDate = DateTime.Now;
                orderDetail.AddedBy = User.Identity.Name;
                orderDetail.OrderId = Convert.ToInt32(formCollection["orderId"]);

                hopeLingerieEntities.OrderDetails.AddObject(orderDetail);
                hopeLingerieEntities.SaveChanges();
            }
            catch (Exception)
            { }

            return "";
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the OrderDetails EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToOrderDetails(OrderDetail orderDetail)
 {
     base.AddObject("OrderDetails", orderDetail);
 }