public ActionResult Login(CustomerLogin customerLogin)
 {
     using(CustomerLoginEntities clEntity = new CustomerLoginEntities())
     {
         //hashing user entry password
         customerLogin.password = HashKey.GetHashKey(customerLogin.password);
         //checking database if user is valid
         bool userIsValid = clEntity.CustomerLogins.Any(loginTable=>loginTable.email == customerLogin.email && loginTable.password == customerLogin.password);
         //checking if user is valid
         if (userIsValid)
         {
             CustomerLogin customer = clEntity.CustomerLogins.Where(loginTable => loginTable.email == customerLogin.email && loginTable.password == customerLogin.password).FirstOrDefault<CustomerLogin>();
             customer.dateCreated = DateTime.Now;
             customer.password = customerLogin.password;
             clEntity.Entry(customer).State = EntityState.Modified;
             clEntity.SaveChanges();
             Session["customerID"] = customer.customer_ID;
             Session["customerEmail"] = customer.email;
             return RedirectToAction("Index", "Home", new{customer_ID = customer.customer_ID});
         }
         else
         { ModelState.AddModelError("", "Email or Password provided is incorrect!"); }
     }
     return RedirectToAction("Index", "Registration");
 }
 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);
 }