Exemple #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;
        }
 public ActionResult Edit(Supplier supplier)
 {
     using (var cm = new SupplierManager())
     {
         supplier = cm.Edit(supplier);
     }
     return RedirectToAction("List");
 }
Exemple #3
0
        public Supplier Create(Supplier supplier)
        {
            supplier.CreatedOn = DateTime.Now;
            supplier.ModifiedOn = DateTime.Now;

            db.Suppliers.InsertOnSubmit(supplier);
            db.SubmitChanges();
            return supplier;
        }
 partial void DeleteSupplier(Supplier instance);
 partial void UpdateSupplier(Supplier instance);
 partial void InsertSupplier(Supplier instance);