Пример #1
0
        public Supplier Edit(Supplier supplier)
        {
            supplier.ModifiedOn = DateTime.Now;
            Supplier dbSupplier = Single(supplier.ID);

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

            db.SubmitChanges();
            return dbSupplier;
        }
Пример #2
0
 public ActionResult Edit(Supplier supplier)
 {
     using (var cm = new SupplierManager())
     {
         supplier = cm.Edit(supplier);
     }
     return RedirectToAction("List");
 }
Пример #3
0
        public Supplier Create(Supplier supplier)
        {
            supplier.CreatedOn = DateTime.Now;
            supplier.ModifiedOn = DateTime.Now;

            db.Suppliers.InsertOnSubmit(supplier);
            db.SubmitChanges();
            return supplier;
        }
Пример #4
0
 partial void DeleteSupplier(Supplier instance);
Пример #5
0
 partial void UpdateSupplier(Supplier instance);
Пример #6
0
 partial void InsertSupplier(Supplier instance);