public Company Edit(Company company) { company.ModifiedOn = DateTime.Now; Company dbCompany = Single(company.ID); // get the database columns which need to be updated var databaseMembers = db.Mapping.MappingSource.GetModel(typeof(BizzyQuoteDataContext)).GetMetaType(typeof(Company)).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 dbCompany.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(dbCompany, propertyInfo.GetValue(company, null), null); } db.SubmitChanges(); return dbCompany; }
public ActionResult Edit(Company company) { using (var cm = new CompanyManager()) { company = cm.Edit(company); } return RedirectToAction("List"); }
public Company Create(Company company) { company.CreatedOn = DateTime.Now; company.ModifiedOn = DateTime.Now; db.Companies.InsertOnSubmit(company); db.SubmitChanges(); return company; }
public void CreateCompanyTest() { var company = new Company { Address = "460 South Marion pkwy apt 1402", City = "Denver", Email = "*****@*****.**", Name = "Third Company", Phone = "815-919-5371", State = "CO", Zip = "80209" }; using (var cm = new CompanyManager()) { company = cm.Create(company); } Assert.IsTrue(company.ID > 0); }
partial void DeleteCompany(Company instance);
partial void UpdateCompany(Company instance);
partial void InsertCompany(Company instance);
public ActionResult Suppliers(Company company) { return RedirectToAction("List"); }