public ActionResult Address(CustomerAddress customerAddress) { if (ModelState.IsValid) { using (CustomerAddressEntities caEntities = new CustomerAddressEntities()) { caEntities.Entry(customerAddress).State = EntityState.Modified; caEntities.SaveChanges(); return RedirectToAction("Address"); } } return View(); }
public ActionResult Register(Customer customer, CustomerAddress customerAddress, CustomerLogin customerLogin) { string viewChange = ""; try { if (ModelState.IsValid) { //encrypt the password customerLogin.password = HashKey.GetHashKey(customerLogin.password); //inserting into customers table using (CustomerEntities cEntityy = new CustomerEntities()) { cEntityy.Customers.Add(customer); cEntityy.SaveChanges(); } using (CustomerAddressEntities caEntity = new CustomerAddressEntities()) { customerAddress.customer_ID = customer.customer_ID; //inserting into customer address table caEntity.CustomerAddresses.Add(customerAddress); caEntity.SaveChanges(); } using (CustomerLoginEntities clEntity = new CustomerLoginEntities()) { customerLogin.customer_ID = customer.customer_ID; customerLogin.email = customer.email; customerLogin.dateCreated = DateTime.Now; //inserting into customer login table clEntity.CustomerLogins.Add(customerLogin); clEntity.SaveChanges(); return RedirectToAction("Index", "Customer"); } } else { viewChange = "LoginRegister"; } } catch(EntryPointNotFoundException ex){} catch (Exception ex) { viewChange = "LoginRegister"; } return View(viewChange); }