Beispiel #1
0
        public FAQ Edit(FAQ faq)
        {
            FAQ dbFAQ = Single(faq.ID);

            // get the database columns which need to be updated
            var databaseMembers =
                db.Mapping.MappingSource.GetModel(typeof(BizzyQuoteDataContext)).GetMetaType(typeof(FAQ)).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 dbFAQ.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(dbFAQ, propertyInfo.GetValue(faq, null), null);
            }

            db.SubmitChanges();
            return dbFAQ;
        }
Beispiel #2
0
        public FAQ Create(FAQ faq)
        {
            db.FAQs.InsertOnSubmit(faq);
            db.SubmitChanges();

            return faq;
        }
Beispiel #3
0
 public ActionResult Edit(FAQ faq)
 {
     using (var fm = new FAQManager())
     {
         faq = fm.Edit(faq);
     }
     return RedirectToAction("List");
 }
 partial void DeleteFAQ(FAQ instance);
 partial void UpdateFAQ(FAQ instance);
 partial void InsertFAQ(FAQ instance);