Exemplo n.º 1
0
        public ActionResult VerifyAccount(string id)
        {
            bool Status = false;

            using (Db_MawjoudEntities1 dc = new Db_MawjoudEntities1())
            {
                dc.Configuration.ValidateOnSaveEnabled = false; // This line I have added here to avoid
                                                                // Confirm password does not match issue on save changes
                var v = dc.Members.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());
        }
Exemplo n.º 2
0
 public void Add(Tbl_Entity entity)
 {
     _dbSet.Add(entity);
     _DBEntity.SaveChanges();
 }
Exemplo n.º 3
0
        public ActionResult Register([Bind(Exclude = "IsEmailVerified,ActivationCode")] RegisterViewModel model)
        {
            bool    Status  = false;
            string  message = "";
            Members user    = new Members();

            user.MemberId        = model.MemberId;
            user.Membercity      = model.Membercity;
            user.LastName        = model.LastName;
            user.IsEmailVerified = model.IsEmailVerified;
            user.IsActive        = model.IsActive;
            user.FirstName       = model.FristName;
            user.Email           = model.Email;
            user.CreatedOn       = model.CreatedOn;
            user.Memberphoto     = model.Memberphoto;
            user.ModifiedOn      = model.ModifiedOn;
            user.Password        = model.Password;

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


                #region Generate Activation code
                user.ActivationCode = Guid.NewGuid();
                #endregion


                #region Password  Hashing
                model.Password        = Crypto.Hash(model.Password);
                model.ConfirmPassword = Crypto.Hash(model.ConfirmPassword);

                #endregion


                user.IsEmailVerified = false;
                #region Save to Database
                using (Db_MawjoudEntities1 dc = new Db_MawjoudEntities1())
                {
                    dc.Members.Add(user);
                    dc.SaveChanges();

                    //Send Email to User
                    SendVerificationLinkEmail(user.Email, user.ActivationCode.ToString());
                    message = "Registration successfully done. Account activation link " +
                              " has been sent to your email id:" + user.Email;
                    Status = true;
                }
                #endregion
            }

            else
            {
                message = "Invalid request";
            }
            //Email is already Exist
            //Generate Activation Code
            //Password HAshing
            //Save data to Database
            //Send Email to user
            ViewBag.Message = message;
            ViewBag.Status  = Status;
            return(View(model));
        }
Exemplo n.º 4
0
 public void SaveChanges()
 {
     DBEntity.SaveChanges();
 }