Example #1
0
        public Quote Create(Quote quote)
        {
            quote.CreatedOn = DateTime.Now;
            quote.ModifiedOn = DateTime.Now;

            db.Quotes.InsertOnSubmit(quote);
            db.SubmitChanges();

            return quote;
        }
Example #2
0
 public ActionResult Create()
 {
     // We create a shell of a quote and redirect to the edit
     var quote = new Quote();
     quote.CreatedOn = DateTime.Now;
     quote.ModifiedOn = DateTime.Now;
     quote.IsActive = false;
     using (var um = new UserManager())
     {
         var user = um.ByUsername(User.Identity.Name);
         if (user.CompanyID != null)
             quote.CompanyID = user.CompanyID;
         quote.EmployeeID = user.ID;
     }
     using (var qm = new QuoteManager())
     {
         quote = qm.Create(quote);
     }
     return RedirectToAction("Options", new { id = quote.ID});
 }
Example #3
0
 partial void DeleteQuote(Quote instance);
Example #4
0
 partial void UpdateQuote(Quote instance);
Example #5
0
 partial void InsertQuote(Quote instance);
Example #6
0
		private void detach_Quotes(Quote entity)
		{
			this.SendPropertyChanging();
			entity.User = null;
		}
Example #7
0
		private void attach_Quotes(Quote entity)
		{
			this.SendPropertyChanging();
			entity.User = this;
		}
Example #8
0
        public Quote Edit(Quote quote)
        {
            quote.ModifiedOn = DateTime.Now;
            Quote dbQuote = Single(quote.ID);

            // get the database columns which need to be updated
            var databaseMembers =
                db.Mapping.MappingSource.GetModel(typeof(BizzyQuoteDataContext)).GetMetaType(typeof(Quote)).DataMembers
                    .Where(d => d.IsAssociation == false && d.IsDbGenerated == false && d.IsPersistent == true);

            // reflect to get instances of the entity preoprties
            var editProperties =
                from p in dbQuote.GetType().GetProperties()
                join m in databaseMembers on p.Name equals m.Name
                select p;

            // copy the values
            PropertyInfo[] editProps = editProperties.ToArray();
            foreach (PropertyInfo propertyInfo in editProps)
            {
                propertyInfo.SetValue(dbQuote, propertyInfo.GetValue(quote, null), null);
            }

            db.SubmitChanges();
            return dbQuote;
        }
Example #9
0
 public void CreateQuoteTest()
 {
     Quote quote = new Quote();
     quote.Address = "460 South Marion pkwy apt 1402";
     quote.Amount = 47M;
 }
Example #10
0
 public ActionResult Edit(Quote quote)
 {
     quote.IsActive = true;
     using (var qm = new QuoteManager())
     {
         quote = qm.Edit(quote);
     }
     return RedirectToAction("List");
 }