예제 #1
0
        public ActionResult Create(Company company)
        {
            if (ModelState.IsValid)
            {
                company.CompanyId = Guid.NewGuid();
                //db.Companies.AddObject(company);
                db.Companies.Add(company);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(company);
        }
예제 #2
0
 public ActionResult Edit(Company company)
 {
     if (ModelState.IsValid)
     {
         db.Companies.Attach(company);
         //db.ObjectStateManager.ChangeObjectState(company, EntityState.Modified);
         db.Entry(company).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(company);
 }