コード例 #1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Quotes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToQuotes(Quote quote)
 {
     base.AddObject("Quotes", quote);
 }
コード例 #2
0
ファイル: QuoteService.cs プロジェクト: ometz2012/ometz2012
        //Method that creates new Quotation ****CREATE RFQ BUTTON***
        public QuoteAdded CreateNewQuoation(QuoteDTO QuoteNew)
        {
            bool check = false;
            QuoteAdded QuoteValidation = new QuoteAdded();
            using (TransactionScope transaction = new TransactionScope())
            {

                try
                {
                    Quote QuoteIn = new Quote();
                    //Data transfer to the the AddressIn
                    QuoteIn.StartDate = QuoteNew.StartDate;
                    QuoteIn.EndDate = QuoteNew.EndDate;
                    QuoteIn.Status = 1;

                    using (var context = new RFQEntities())
                    {
                        //Finding references for the Foreign Keys
                        Company existingCompany = context.Companies.Single(q => q.CompanyID == QuoteNew.CompanyID);

                        //Adding refernces
                        QuoteIn.Company = existingCompany;

                        if (QuoteIn.EntityState == EntityState.Detached)
                        {
                            context.Quotes.AddObject(QuoteIn);
                        }

                        context.SaveChanges();

                        int id = QuoteIn.QuoteID;
                        QuoteValidation.LastId = id;

                    }

                }

                catch (Exception e)
                {
                    transaction.Dispose();
                    check = false;
                    QuoteValidation.Added = check;
                    return QuoteValidation;

                }
                transaction.Complete();
                check = true;
                QuoteValidation.Added = check;
                return QuoteValidation;

            }
        }
コード例 #3
0
 /// <summary>
 /// Create a new Quote object.
 /// </summary>
 /// <param name="quoteID">Initial value of the QuoteID property.</param>
 /// <param name="companyID">Initial value of the CompanyID property.</param>
 /// <param name="startDate">Initial value of the StartDate property.</param>
 /// <param name="endDate">Initial value of the EndDate property.</param>
 /// <param name="status">Initial value of the Status property.</param>
 public static Quote CreateQuote(global::System.Int32 quoteID, global::System.Int32 companyID, global::System.DateTime startDate, global::System.DateTime endDate, global::System.Int16 status)
 {
     Quote quote = new Quote();
     quote.QuoteID = quoteID;
     quote.CompanyID = companyID;
     quote.StartDate = startDate;
     quote.EndDate = endDate;
     quote.Status = status;
     return quote;
 }