public ActionResult ConfirmUK(String email) { try { Customer customerModel = new Customer(); Encryption objDeco = new Encryption(); using (CustomerConsentEntities dbModel = new CustomerConsentEntities()) { customerModel.email = objDeco.EmailDecrypt(email); customerModel.active = true; customerModel.created = DateTime.Now; customerModel.lastUpdate = DateTime.Now; customerModel.distributionGroup = "Windymains Stock Grid"; if (!dbModel.Customers.Any(c => c.email == customerModel.email && c.distributionGroup == customerModel.distributionGroup)) { dbModel.Customers.Add(customerModel); dbModel.SaveChanges(); } } ViewBag.ErrorMessage = ""; } catch (Exception e) { ViewBag.ErrorMessage = e.Message; } return(View("ConfirmUK")); }
public ActionResult Unsubscribe(String email) { try { Customer customerModel = new Customer(); Encryption objDeco = new Encryption(); String emailDecrypt = objDeco.EmailDecrypt(email); using (CustomerConsentEntities dbModel = new CustomerConsentEntities()) { dbModel.Database.Connection.Open(); var update = dbModel.Customers.SingleOrDefault(c => c.email == emailDecrypt && c.distributionGroup == emailGroup); update.active = false; update.lastUpdate = DateTime.Now; dbModel.Customers.Add(update); dbModel.SaveChanges(); } ViewBag.ErrorMessage = ""; } catch (Exception e) { ViewBag.ErrorMessage = e.Message; } return(View("Unsubscribe")); }