public ActionResult VerifyAccount(string id) { bool Status = false; using (EWorkDatabaseEntities dc = new EWorkDatabaseEntities()) { dc.Configuration.ValidateOnSaveEnabled = false; //this line is added for to avoid the the //confirm password doesnt match issue //on save changes var v = dc.Customers.Where(a => a.ActivationCode == new Guid(id)).FirstOrDefault(); if (v != null) { v.IsEmailVerified = true; dc.SaveChanges(); Status = true; } else { ViewBag.Message = "Invalid Request"; } } ViewBag.Status = Status; return(View()); }
public ActionResult CustomerRegistration([Bind(Exclude = "IsEmailVerified,ActivationCode")] Customer customer) { bool status = false; string message = ""; //Model Validation if (ModelState.IsValid) { #region //Email is Already exists var isExist = false;// isEmailExist(user.EmailID); if (isExist) { ModelState.AddModelError("EmailExist", "Email is Already exist"); return(View(customer)); } #endregion #region// genrate Activation code customer.ActivationCode = Guid.NewGuid(); #endregion #region//Password hashing customer.Password = Crypto.Hash(customer.Password); customer.ConfirmPassword = Crypto.Hash(customer.ConfirmPassword); customer.IsEmailVerified = false; #endregion #region //save to database using (EWorkDatabaseEntities dc = new EWorkDatabaseEntities()) { dc.Customers.Add(customer); dc.SaveChanges(); //send Email to User sendVerificationEmailLink(customer.EmailID, customer.ActivationCode.ToString()); message = "Registration Sucessfully Done account verification is send to your email ID" + customer.EmailID; status = true; } #endregion } else { message = "Invalid Request"; } ViewBag.Message = message; ViewBag.Status = status; return(View()); }
public ActionResult ProfessionalRegistration([Bind(Exclude = "IsEmailVerified,ActivationCode")] Professional professional, HttpPostedFileBase file) { if (ModelState.IsValid) { try { if (file != null) { string path = Path.Combine(Server.MapPath("~/professional_img"), Path.GetFileName(file.FileName)); file.SaveAs(path); ViewBag.FileStatus = "File uploaded successfully."; } // ViewBag.FileStatus = "File uploaded successfully."; } catch (Exception) { ViewBag.FileStatus = "Error while file uploading."; } } bool status = false; string message = ""; //Model Validation if (ModelState.IsValid) { #region //Email is Already exists var isExist = false; // isEmailExist(user.EmailID); if (isExist) { ModelState.AddModelError("EmailExist", "Email is Already exist"); return(View(professional)); } #endregion /* * if (file != null && file.ContentLength > 0) { * System.Diagnostics.Debug.WriteLine("in the file name"); * string filename = Path.GetFileName(file.FileName); * string imgpath = Path.Combine(Server.MapPath("~/professional_img/"), filename); * professional.Prof_img = imgpath; * file.SaveAs(imgpath); * } */ #region // genrate Activation code professional.Prof_ActivationCode = Guid.NewGuid(); #endregion #region //Password hashing professional.Prof_Password = Crypto.Hash(professional.Prof_Password); professional.Prof_ConfirmPassword = Crypto.Hash(professional.Prof_ConfirmPassword); professional.Prof_IsEmailVerified = false; #endregion #region //save to database using (EWorkDatabaseEntities dc = new EWorkDatabaseEntities()) { System.Diagnostics.Debug.WriteLine(".........." + "file--" + (file != null) + "file path---"); dc.Professionals.Add(professional); dc.SaveChanges(); //send Email to User sendVerificationEmailLink(professional.Prof_EmailID, professional.Prof_ActivationCode.ToString()); message = "Registration Sucessfully Done account verification is send to your email ID" + professional.Prof_EmailID; status = true; } #endregion } else { message = "Invalid Request"; } ViewBag.Message = message; ViewBag.Status = status; return(View()); }