/// <summary> /// Deprecated Method for adding a new object to the TransactionDetails EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToTransactionDetails(TransactionDetail transactionDetail) { base.AddObject("TransactionDetails", transactionDetail); }
protected string InsertTransaction() { if (Session["selectedUserValue"] != null && Session[WebConstants.Session.TROLLEY] != null) { int UserId = Int32.Parse(Session["selectedUserValue"].ToString()); Transaction transaction = new Transaction(); transaction.UserId = UserId; transaction.CountryCode = ShoppingCart.GetCurrentCurrency().CountryCode; transaction.ExchangeRate = ShoppingCart.GetCurrentCurrency().ExchangeRate1; transaction.CreationTime = DateTime.Now; transaction.TransactionUID = System.Guid.NewGuid().ToString(); transaction.TransactionDetails = new System.Data.Objects.DataClasses.EntityCollection<TransactionDetail>(); foreach (ShoppingItem shoppingItem in (List<ShoppingItem>)Session[WebConstants.Session.TROLLEY]) { TransactionDetail detail = new TransactionDetail(); detail.ProductID = shoppingItem.ProductEntity.ProductID; detail.ProductName = shoppingItem.ProductEntity.Name; detail.Quantity = shoppingItem.Quantity; detail.Duration = shoppingItem.DurationInMonths; detail.Price = shoppingItem.Price; if (shoppingItem.VersionEntity != null) { detail.VersionID = shoppingItem.VersionEntity.VersionID; detail.VersionName = shoppingItem.VersionEntity.Name; } if (shoppingItem.ProductDetailEntity != null) { detail.ProductDetailID = shoppingItem.ProductDetailEntity.ProductDetailID; detail.ProductDetailName = shoppingItem.ProductDetailEntity.ProductDetail1; } transaction.TransactionDetails.Add(detail); } DatabaseContext.AddToTransactions(transaction); DatabaseContext.SaveChanges(); return transaction.TransactionUID; } return null; }
/// <summary> /// Create a new TransactionDetail object. /// </summary> /// <param name="transactionDetailID">Initial value of the TransactionDetailID property.</param> /// <param name="transactionID">Initial value of the TransactionID property.</param> /// <param name="productID">Initial value of the ProductID property.</param> /// <param name="productName">Initial value of the ProductName property.</param> /// <param name="quantity">Initial value of the Quantity property.</param> /// <param name="duration">Initial value of the Duration property.</param> /// <param name="price">Initial value of the Price property.</param> public static TransactionDetail CreateTransactionDetail(global::System.Int32 transactionDetailID, global::System.Int32 transactionID, global::System.Int32 productID, global::System.String productName, global::System.Int32 quantity, global::System.Int32 duration, global::System.Double price) { TransactionDetail transactionDetail = new TransactionDetail(); transactionDetail.TransactionDetailID = transactionDetailID; transactionDetail.TransactionID = transactionID; transactionDetail.ProductID = productID; transactionDetail.ProductName = productName; transactionDetail.Quantity = quantity; transactionDetail.Duration = duration; transactionDetail.Price = price; return transactionDetail; }