/// <summary> /// Deprecated Method for adding a new object to the Transactions EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToTransactions(Transaction transaction) { base.AddObject("Transactions", transaction); }
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 Transaction object. /// </summary> /// <param name="transactionID">Initial value of the TransactionID property.</param> /// <param name="userId">Initial value of the UserId property.</param> /// <param name="creationTime">Initial value of the CreationTime property.</param> /// <param name="transactionUID">Initial value of the TransactionUID property.</param> /// <param name="countryCode">Initial value of the CountryCode property.</param> /// <param name="exchangeRate">Initial value of the ExchangeRate property.</param> public static Transaction CreateTransaction(global::System.Int32 transactionID, global::System.Int32 userId, global::System.DateTime creationTime, global::System.String transactionUID, global::System.String countryCode, global::System.Double exchangeRate) { Transaction transaction = new Transaction(); transaction.TransactionID = transactionID; transaction.UserId = userId; transaction.CreationTime = creationTime; transaction.TransactionUID = transactionUID; transaction.CountryCode = countryCode; transaction.ExchangeRate = exchangeRate; return transaction; }