public ActionResult Create(customer customer) { if (ModelState.IsValid) { db.customers.AddObject(customer); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.groupId = new SelectList(db.customer_group, "groupId", "name", customer.groupId); ViewBag.postalAddressId = new SelectList(db.addresses, "addressId", "town", customer.postalAddressId); ViewBag.visitingAddressId = new SelectList(db.addresses, "addressId", "town", customer.visitingAddressId); ViewBag.contactPersonId = new SelectList(db.contact_person, "personId", "fName", customer.contactPersonId); ViewBag.contractId = new SelectList(db.contracts, "contractId", "contractId", customer.contractId); return View(customer); }
public ActionResult Edit(customer customer) { if (ModelState.IsValid) { db.customers.Attach(customer); db.ObjectStateManager.ChangeObjectState(customer, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.postalAddressId = new SelectList(db.addresses, "addressId", "town", customer.postalAddressId); ViewBag.visitingAddressId = new SelectList(db.addresses, "addressId", "town", customer.visitingAddressId); ViewBag.contactPersonId = new SelectList(db.contact_person, "personId", "fName", customer.contactPersonId); ViewBag.contractId = new SelectList(db.contracts, "contractId", "contractId", customer.contractId); return View(customer); }
private void Fixupcustomer(customer previousValue) { if (IsDeserializing) { return; } if (previousValue != null && previousValue.customer_site.Contains(this)) { previousValue.customer_site.Remove(this); } if (customer != null) { if (!customer.customer_site.Contains(this)) { customer.customer_site.Add(this); } customerId = customer.customerId; } if (ChangeTracker.ChangeTrackingEnabled) { if (ChangeTracker.OriginalValues.ContainsKey("customer") && (ChangeTracker.OriginalValues["customer"] == customer)) { ChangeTracker.OriginalValues.Remove("customer"); } else { ChangeTracker.RecordOriginalValue("customer", previousValue); } if (customer != null && !customer.ChangeTracker.ChangeTrackingEnabled) { customer.StartTracking(); } } }