Beispiel #1
0
 public bool IsEmailExist(string emailID)
 {
     using (LoginRegEntities1 dc = new LoginRegEntities1())
     {
         var v = dc.Registrations.Where(a => a.Email_ID == emailID).FirstOrDefault();
         return(v != null);
     }
 }
Beispiel #2
0
        public ActionResult RegistrationForm([Bind(Exclude = "isEmailVarified,ActivationCode")] Registration reg)
        {
            bool   Status  = false;
            string message = "";

            //
            //Model Validation
            if (ModelState.IsValid)
            {
                #region //Email is already exist
                var isExist = IsEmailExist(reg.Email_ID);
                if (isExist)
                {
                    ModelState.AddModelError("EmailExist", "Email is already exist");
                    return(View(reg));
                }
                #endregion

                #region Generate Activation Code
                reg.ActivationCode = Guid.NewGuid();
                #endregion

                #region Password Hasing
                reg.Password        = Crypto.Hash(reg.Password);
                reg.ConfirmPassword = Crypto.Hash(reg.ConfirmPassword); //
                reg.isEmailVarified = false;
                #endregion

                #region Save to Database
                using (LoginRegEntities1 dc = new LoginRegEntities1())
                {
                    dc.Registrations.Add(reg);
                    dc.SaveChanges();

                    //Send Email to User
                    SendVerificationLinkEmail(reg.Email_ID, reg.ActivationCode.ToString());
                }

                #endregion
            }
            else
            {
                message = "Invalid Requiest";
            }



            return(View(reg));
        }