public ActionResult Edit(address address)
 {
     if (ModelState.IsValid)
     {
         db.addresses.Attach(address);
         db.ObjectStateManager.ChangeObjectState(address, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(address);
 }
        public ActionResult Create(address address)
        {
            if (ModelState.IsValid)
            {
                db.addresses.AddObject(address);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(address);
        }
Example #3
0
        private void Fixupaddress1(address previousValue)
        {
            if (IsDeserializing)
            {
                return;
            }

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

            if (address1 != null)
            {
                if (!address1.customer_site1.Contains(this))
                {
                    address1.customer_site1.Add(this);
                }

                postalAddressId = address1.addressId;
            }
            if (ChangeTracker.ChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("address1")
                    && (ChangeTracker.OriginalValues["address1"] == address1))
                {
                    ChangeTracker.OriginalValues.Remove("address1");
                }
                else
                {
                    ChangeTracker.RecordOriginalValue("address1", previousValue);
                }
                if (address1 != null && !address1.ChangeTracker.ChangeTrackingEnabled)
                {
                    address1.StartTracking();
                }
            }
        }
Example #4
0
        private void Fixupaddress(address previousValue, bool skipKeys = false)
        {
            if (IsDeserializing)
            {
                return;
            }

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

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

                addressId = address.addressId;
            }
            else if (!skipKeys)
            {
                addressId = null;
            }

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