public ActionResult Create(contact_person contact_person)
        {
            if (ModelState.IsValid)
            {
                db.contact_person.AddObject(contact_person);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.addressId = new SelectList(db.addresses, "addressId", "town", contact_person.addressId);
            return View(contact_person);
        }
 public ActionResult Edit(contact_person contact_person)
 {
     if (ModelState.IsValid)
     {
         db.contact_person.Attach(contact_person);
         db.ObjectStateManager.ChangeObjectState(contact_person, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.addressId = new SelectList(db.addresses, "addressId", "town", contact_person.addressId);
     return View(contact_person);
 }
Ejemplo n.º 3
0
        private void Fixupcontact_person(contact_person previousValue)
        {
            if (IsDeserializing)
            {
                return;
            }

            if (previousValue != null && previousValue.customer_site.Contains(this))
            {
                previousValue.customer_site.Remove(this);
            }

            if (contact_person != null)
            {
                if (!contact_person.customer_site.Contains(this))
                {
                    contact_person.customer_site.Add(this);
                }

                contactPersonId = contact_person.personId;
            }
            if (ChangeTracker.ChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("contact_person")
                    && (ChangeTracker.OriginalValues["contact_person"] == contact_person))
                {
                    ChangeTracker.OriginalValues.Remove("contact_person");
                }
                else
                {
                    ChangeTracker.RecordOriginalValue("contact_person", previousValue);
                }
                if (contact_person != null && !contact_person.ChangeTracker.ChangeTrackingEnabled)
                {
                    contact_person.StartTracking();
                }
            }
        }