コード例 #1
0
        public ActionResult Registration([Bind(Exclude = "IsEmailVerried,ActivationCode")] Registration Registration)
        {
            bool   Status  = false;
            String message = "";

            // Mode validation
            if (ModelState.IsValid)
            {
                //email is alredey code
                var isExist = IsEmailExist(Registration.E_Mail);
                if (isExist)
                {
                    ModelState.AddModelError("EmailExist", "Email Already Exist");
                    return(View(Registration));
                }
                //Genarete active code
                Registration.ActivationCode = Guid.NewGuid();

                //password hasshin
                Registration.Password        = Crypto.Hash(Registration.Password);
                Registration.ConfrimPassword = Crypto.Hash(Registration.ConfrimPassword);

                Registration.IsEmailVerried = false;

                using (SheekerEntities1 dc = new SheekerEntities1())
                {
                    dc.Registrations.Add(Registration);
                    dc.SaveChanges();


                    // SendVerificationLinkEmail(Registration.E_Mail,Registration.ActivationCode.ToString());
                    message = "Registration Sucessfully done.Account activication link" +
                              "has been send your email id:" + Registration.E_Mail;

                    Status = true;
                }
            }
            else
            {
                message = "Invalid Request";
            }
            //send user
            ViewBag.Message = message;
            ViewBag.Status  = Status;
            return(View(Registration));
        }
コード例 #2
0
        public ActionResult VerifyAccount(string id)
        {
            bool Status = false;

            using (SheekerEntities1 dc = new SheekerEntities1())
            {
                dc.Configuration.ValidateOnSaveEnabled = false;
                var v = dc.Registrations.Where(a => a.ActivationCode == new Guid(id)).FirstOrDefault();
                if (v != null)
                {
                    v.IsEmailVerried = true;
                    dc.SaveChanges();
                    Status = true;
                }
                else
                {
                    ViewBag.Message = "Invalid Request";
                }
            }
            ViewBag.Status = Status;
            return(View());
        }