public ActionResult Edit(Customer customer, FullNameEdit name, FullAddressEdit ha)
 {
     if (ModelState.IsValid)
     {
         db.Entry(name.UpdateFullName(db.FullNames.Find(name.fnID))).State    = EntityState.Modified;
         db.Entry(ha.UpdateFullAddress(db.FullAddresses.Find(ha.faID))).State = EntityState.Modified;
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges(); // save modifications to the database
         return(RedirectToAction("Index"));
     }
     customer = db.Customers.Include(c => c.Name).Include(c => c.HomeAddress).SingleOrDefault(c => c.ID == customer.ID);
     return(View(customer));
 }
예제 #2
0
 public ActionResult Edit(Contact contact, FullNameEdit name, FullAddressEdit ha)
 {
     if (ModelState.IsValid)
     {
         var personID = (Guid)Session["id"];
         db.Entry(name.UpdateFullName(db.FullNames.Find(name.fnID))).State    = EntityState.Modified;
         db.Entry(ha.UpdateFullAddress(db.FullAddresses.Find(ha.faID))).State = EntityState.Modified;
         db.Entry(contact).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", new { id = personID }));
     }
     ViewBag.BranchID = new SelectList(db.Branches, "ID", "Name", contact.BranchID);
     contact          = db.Contacts.Include(c => c.Name).Include(c => c.HomeAddress).SingleOrDefault(c => c.ID == contact.ID);
     return(View(contact));
 }
        public ActionResult Edit(Employee employee, FullNameEdit name, FullAddressEdit ha)
        {
            if (ModelState.IsValid)
            {
                db.Entry(name.UpdateFullName(db.FullNames.Find(name.fnID))).State    = EntityState.Modified;
                db.Entry(ha.UpdateFullAddress(db.FullAddresses.Find(ha.faID))).State = EntityState.Modified;
                db.Entry(employee).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            ViewBag.BranchID          = new SelectList(db.Branches, "ID", "Name", employee.BranchID);
            ViewBag.ID                = new SelectList(db.FullNames, "ID", "Title", employee.ID);
            ViewBag.ReportRecipientID = new SelectList(db.Employees, "ID", "Role", employee.ReportRecipientID);
            employee = db.Employees.Include(e => e.Name).Include(e => e.HomeAddress).SingleOrDefault(e => e.ID == employee.ID);
            return(View(employee));
        }