コード例 #1
0
ファイル: CompanyManager.cs プロジェクト: BizzyQuote/BQ2013
        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;
        }
コード例 #2
0
 public ActionResult Edit(Company company)
 {
     using (var cm = new CompanyManager())
     {
         company = cm.Edit(company);
     }
     return RedirectToAction("List");
 }
コード例 #3
0
ファイル: CompanyManager.cs プロジェクト: BizzyQuote/BQ2013
        public Company Create(Company company)
        {
            company.CreatedOn = DateTime.Now;
            company.ModifiedOn = DateTime.Now;

            db.Companies.InsertOnSubmit(company);
            db.SubmitChanges();
            return company;
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 partial void DeleteCompany(Company instance);
コード例 #6
0
 partial void UpdateCompany(Company instance);
コード例 #7
0
 partial void InsertCompany(Company instance);
コード例 #8
0
 public ActionResult Suppliers(Company company)
 {
     return RedirectToAction("List");
 }