/// <summary> /// Deprecated Method for adding a new object to the QuoteDetails EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToQuoteDetails(QuoteDetail quoteDetail) { base.AddObject("QuoteDetails", quoteDetail); }
//Method that adds new details row to the QuoteDetail ****ADD DETAILS BUTTON*** public bool CreateNewQuoteDetail(QuoteDetailToCreateDTO QuoteDetailNew) { bool check = false; using (TransactionScope transaction = new TransactionScope()) { try { QuoteDetail QuoteDetailIn = new QuoteDetail(); //Data transfer to the object that will be added to the DB QuoteDetailIn.Text = QuoteDetailNew.Text; QuoteDetailIn.Value = QuoteDetailNew.Value; using (var context = new RFQEntities()) { //Finding references for the Foreign Keys Quote existingQuote = context.Quotes.Single(qd => qd.QuoteID == QuoteDetailNew.QuoteID); //Adding refernces QuoteDetailIn.Quote = existingQuote; if (QuoteDetailIn.EntityState == EntityState.Detached) { context.QuoteDetails.AddObject(QuoteDetailIn); } context.SaveChanges(); } } catch (Exception e) { transaction.Dispose(); check = false; return check; } transaction.Complete(); check = true; return check; } }
/// <summary> /// Create a new QuoteDetail object. /// </summary> /// <param name="quoteDetailID">Initial value of the QuoteDetailID property.</param> /// <param name="quoteID">Initial value of the QuoteID property.</param> /// <param name="text">Initial value of the Text property.</param> /// <param name="value">Initial value of the Value property.</param> public static QuoteDetail CreateQuoteDetail(global::System.Int32 quoteDetailID, global::System.Int32 quoteID, global::System.String text, global::System.Decimal value) { QuoteDetail quoteDetail = new QuoteDetail(); quoteDetail.QuoteDetailID = quoteDetailID; quoteDetail.QuoteID = quoteID; quoteDetail.Text = text; quoteDetail.Value = value; return quoteDetail; }