public ActionResult Register([Bind(Include = "ID,FirstName,LastName,Password,ConfirmPassword,Captcha,Telephone,EmailAddress,RoleID,CountryID,UserAgeDescriptionID,capchadata")] RegisterViewModel model)
        {
            if (model.capchadata != model.Captcha)
            {
                ViewBag.Captcha = "false";
            }
            else
            {
                ViewBag.Captcha = "true";

                // Lets first check if the Model is valid or not
                if (ModelState.IsValid)
                {
                    User user = new User
                    {
                        LoginName    = model.EmailAddress,
                        Password     = model.Password,
                        FirstName    = model.FirstName,
                        LastName     = model.LastName,
                        EmailAddress = model.EmailAddress,
                        UserImage    = "",
                        //UserSignature = userVM.UserSignature,
                        IsActive    = false,
                        Phonenumber = model.Telephone,
                        // Fax = userVM.Fax,
                        CreatedDate          = DateTime.Now,
                        ModifiedDate         = DateTime.Now,
                        UserAgeDescriptionID = model.UserAgeDescriptionID,
                        RoleID             = model.RoleID,
                        SecurityTemplateID = model.RoleID,
                        CountryID          = model.CountryID
                    };

                    db.Users.Add(user);
                    db.SaveChanges();

                    string Link  = System.Web.HttpContext.Current.Request.Url.Scheme + "://" + System.Web.HttpContext.Current.Request.Url.Host + (System.Web.HttpContext.Current.Request.Url.Port == 80 ? string.Empty : ":" + System.Web.HttpContext.Current.Request.Url.Port) + Url.Action("ActivateLine", "Account", new { EmailId = user.LoginName });
                    string Check = GenFx.EmailToUserifComplaintAdded(user.LoginName, user.Password, Link);
                    if (Check == "1")
                    {
                        Session["siteMsgTyp"] = "success";
                        Session["siteMsg"]    = "You are register  successfully.Login confirmation link send your Email";
                        return(RedirectToAction("Login", "Account"));
                    }

                    else
                    {
                        Session["siteMsgTyp"] = "error";
                        Session["siteMsg"]    = "You are register  successfully.but Login confirmation link can not  send your Email.Please Contact";
                    }
                }
            }
            ViewBag.UserAgeDescriptionID = new SelectList(db.UserAgeDescriptions, "ID", "AgeDescription", model.UserAgeDescriptionID);
            ViewBag.RoleID    = new SelectList(db.Roles.Where(a => a.ID > 2), "ID", "RoleName", model.RoleID);
            ViewBag.CountryID = new SelectList(db.Countries, "ID", "Name", model.CountryID);
            //// If we got this far, something failed, redisplay form
            return(View(model));
        }
        public ActionResult ForgotPassword(ForgotPasswordViewModel model, string returnUrl)
        {
            // Lets first check if the Model is valid or not
            if (ModelState.IsValid)
            {
                using (DBAuthContext entities = new DBAuthContext())
                {
                    string username = model.EmailAddress;
                    string email    = model.EmailAddress;

                    // Now if our password was enctypted or hashed we would have done the
                    // same operation on the user entered password here, But for now
                    // since the password is in plain text lets just authenticate directly

                    var userPassword = entities.Users.Where(user => user.LoginName == username && user.EmailAddress == email).Select(user => user.Password).SingleOrDefault();

                    // User found in the database
                    if (userPassword != null)
                    {
                        string Link  = System.Web.HttpContext.Current.Request.Url.Scheme + "://" + System.Web.HttpContext.Current.Request.Url.Host + (System.Web.HttpContext.Current.Request.Url.Port == 80 ? string.Empty : ":" + System.Web.HttpContext.Current.Request.Url.Port) + Url.Action("ActivateLine", "Account", new { EmailId = username });
                        string Check = GenFx.EmailToUserifComplaintAdded(username, userPassword, "");
                        if (Check == "1")
                        {
                            Session["siteMsgTyp"] = "success";
                            Session["siteMsg"]    = "You are  Password send your Email Address.Check it";
                            return(RedirectToAction("Login", "Account"));
                        }

                        else
                        {
                            Session["siteMsgTyp"] = "error";
                            Session["siteMsg"]    = "You are  Password  cant not send your Email Address.Please try Again...";
                        }

                        //ModelState.AddModelError("", "Your Password is " + userPassword + ".");
                    }
                    else
                    {
                        ModelState.AddModelError("", "The user name or email address provided is incorrect.");
                    }
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }