예제 #1
0
 public ActionResult Registration(Users model)
 {
     if (ModelState.IsValid)
     {
         using (var db = new MainDbContext())
         {
             var queryUser = db.Users.FirstOrDefault(u => u.Username == model.Username);
             if (queryUser == null)
             {
                 var encryptedPassword = CustomEnrypt.Encrypt(model.Password);
                 var user = db.Users.Create();
                 user.Email         = model.Email;
                 user.Password      = encryptedPassword;
                 user.Country       = model.Country;
                 user.Name          = model.Name;
                 user.Username      = model.Username;
                 user.Kategori      = model.Kategori;
                 user.Perusahaan_Id = model.Perusahaan_Id;
                 user.Telpon        = model.Telpon;
                 user.Kecamatan     = model.Kecamatan;
                 db.Users.Add(user);
                 db.SaveChanges();
             }
             else
             {
                 return(RedirectToAction("Registration"));
             }
         }
     }
     else
     {
         ModelState.AddModelError("", "One or more fields have been");
     }
     return(View());
 }
예제 #2
0
 public ActionResult Registration(Users model)
 {
     if (ModelState.IsValid)
     {
         using (var db = new MainDbContext())
         {
             var encryptedPassword = CustomEnrypt.Encrypt(model.UserPass);
             var user = db.Users.Create();
             user.FName      = model.FName;
             user.LName      = model.LName;
             user.UserTypeId = model.UserTypeId;
             user.UserCode   = model.UserCode;
             user.UserEmail  = model.UserEmail;
             user.UserPass   = encryptedPassword;
             user.UStatusId  = model.UStatusId;
             user.UserPhone  = model.UserPhone;
             user.AddedOn    = DateTime.Now;
             user.EditedOn   = DateTime.Now;
             user.StatusId   = model.StatusId;
             db.Users.Add(user);
             db.SaveChanges();
         }
     }
     else
     {
         ModelState.AddModelError("", "One or more fields have been");
     }
     return(View());
 }
예제 #3
0
        /// <summary>
        /// registers a user to the system
        /// </summary>
        /// <param name="email"></param>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="password"></param>
        /// <param name="secretQuestion"></param>
        /// <param name="answer"></param>
        /// <param name="stakeholderDescrip"></param>
        /// <returns>positive user-id if user is created</returns>
        public static bool Register(string email, string firstName, string lastName, string password, string secretQuestion, string answer, string stakeholderDescrip)
        {
            ApplicationDBEntities ctx = new ApplicationDBEntities();

            try
            {
                var user = ctx.User.Create();
                user.Email                  = email;
                user.FirstName              = firstName;
                user.LastName               = lastName;
                user.PasswordHash           = CustomEnrypt.Encrypt(password);
                user.SecretQuestion         = secretQuestion;
                user.Answer                 = answer;
                user.StakeholderDescription = stakeholderDescrip;
                user = ctx.User.Add(user);
                ctx.SaveChanges();
                return(true);
            }catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            ctx.Dispose();
            return(false);
        }
예제 #4
0
        public ActionResult Registration(Users model)
        {
            if (ModelState.IsValid)
            {
                using (var db = new MainDbContext())
                {
                    var queryUser = db.Users.FirstOrDefault(u => u.Email == model.Email);
                    if (queryUser == null)
                    {
                        var encryptedPassword = CustomEnrypt.Encrypt(model.Password);
                        var user = db.Users.Create();
                        user.Email    = model.Email;
                        user.Password = encryptedPassword;
                        user.Username = !String.IsNullOrEmpty(model.Username) ? model.Username : "******";

                        db.Users.Add(user);
                        db.SaveChanges();
                        Success(string.Format("<b>{0}</b> was successfully created", user.Username), true);
                        return(RedirectToAction("Login"));
                    }
                    else
                    {
                        Danger("User with Email already exist. Please check your details and try again.", true);
                        return(RedirectToAction("Registration"));
                    }
                }
            }
            else
            {
                Danger("Error creating contact. Please check your form and try again.", true);
            }
            return(View());
        }
예제 #5
0
        public ActionResult ForgotPassword(ForgotPassword model, string ReturnUrl = "")
        {
            string message = "";
            bool   Status  = false;
            string type    = "Success";

            using (MyDatabaseEntities dc = new MyDatabaseEntities())
            {
                var user = dc.Users.Where(x => x.EmailID == model.EmailID).FirstOrDefault();
                if (user != null)
                {
                    string psw = Encryption.CustomEnrypt.GeneratePassword(10);
                    var    usr = new UserController();
                    while (!usr.checkPasswordStrengt(psw))
                    {
                        psw = Encryption.CustomEnrypt.GeneratePassword(10);
                    }
                    string NewkeyOne  = CustomEnrypt.RandomString(15);
                    string NewkeyTwo  = CustomEnrypt.RandomString(15);
                    string NewkeyTree = CustomEnrypt.RandomString(15);
                    user.Password = CustomEnrypt.Encrypt(psw, NewkeyOne);
                    //user.Password = Crypto.Hash(user.Password);
                    user.ConfirmPassword = CustomEnrypt.Encrypt(psw, NewkeyOne);
                    user.TempPasswordSet = true;
                    var crypto = dc.cryptokeys.Where(x => x.UserID == user.UserID).FirstOrDefault();
                    crypto.cryptone  = CustomEnrypt.Encrypt(NewkeyOne, NewkeyTwo);
                    crypto.crypttwo  = CustomEnrypt.Encrypt(NewkeyTwo, NewkeyTree);
                    crypto.crypttree = NewkeyTree;
                    try
                    {
                        dc.SaveChanges();
                        SendTempPassword(user, psw);
                        message = "temperary password send to given mail";
                        type    = "Success";
                        Status  = true;
                    }
                    catch (DbEntityValidationException ex)
                    {
                        foreach (var entityValidationErrors in ex.EntityValidationErrors)
                        {
                            foreach (var validationError in entityValidationErrors.ValidationErrors)
                            {
                                Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                            }
                        }
                    }
                }
                else
                {
                    message = "there are no user matching the given email address please contact administartor if error continues";
                    type    = "Error";
                    Status  = true;
                }
            }

            ViewBag.Message = message;
            ViewBag.Status  = Status;
            ViewBag.Type    = type;
            return(View());
        }
예제 #6
0
 public ActionResult Registration(Users model)
 {
     if (string.IsNullOrEmpty(model.Name))
     {
         ModelState.AddModelError("Name", "The Name field is required.");
     }
     if (ModelState.IsValid)
     {
         using (var db = new SeriesEntities())
         {
             var queryUser = db.Users.FirstOrDefault(u => u.Email == model.Email);
             if (queryUser == null)
             {
                 var encryptedPassword = CustomEnrypt.Encrypt(model.Password);
                 var user = db.Users.Create();
                 user.Email    = model.Email;
                 user.Password = encryptedPassword;
                 user.Name     = model.Name;
                 db.Users.Add(user);
                 db.SaveChanges();
             }
             else
             {
                 return(RedirectToAction("Registration"));
             }
         }
     }
     else
     {
         ModelState.AddModelError("", "One or more fields have been");
     }
     return(View());
 }
예제 #7
0
        public ActionResult Registration(CustomerRegistration model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (var db = new CuddlyWombatEntities())
                    {
                        var existingUser = (from u in db.Users
                                            where u.Email == model.Email
                                            select u).FirstOrDefault();

                        if (existingUser != null)
                        {
                            ModelState.AddModelError("", "Existing Internal User.");
                            return(View());
                        }
                        else
                        {
                            var existingCustomer = (from c in db.Customers
                                                    where c.Email == model.Email
                                                    select c).FirstOrDefault();

                            if (existingCustomer != null)
                            {
                                ModelState.AddModelError("", "Existing Customer.");
                                return(View());
                            }
                        }

                        var encryptedPassword = CustomEnrypt.Encrypt(model.Password);
                        var customer          = new Customer
                        {
                            Email       = model.Email,
                            Password    = encryptedPassword,
                            GivenName   = model.GivenName,
                            Surname     = model.Surname,
                            DateCreated = DateTime.Now
                        };
                        db.Customers.Add(customer);
                        db.SaveChanges();
                    }
                    return(RedirectToAction("Login", "Auth"));
                }
                else
                {
                    ModelState.AddModelError("", "One or more fields have been");
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Exception", ex.Message);
            }
            return(View());
        }
예제 #8
0
        public ActionResult Create([Bind(Include = "UserId,FName,LName,UserEmail,UserPass,UserTypeId,UserCode,UserPhone,UStatusId,AddedBy,AddedOn,EditedBy,EditedOn,StatusId")] Users users)
        {
            if (ModelState.IsValid)
            {
                var encryptedPassword = CustomEnrypt.Encrypt(users.UserPass);
                users.UserPass = encryptedPassword;

                //users.RowStatus = 1;
                db.Users.Add(users);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            // ViewBag.UserTypeId = new SelectList(db.UserTypes, "UserTypeId", "UserType", users.UserTypeId);
            return(View(users));
        }
예제 #9
0
        public ActionResult Edit([Bind(Include = "UserId,FName,LName,UserEmail,UserPass,UserTypeId,UserCode,UserPhone,UStatusId,EditedBy,EditedOn,StatusId", Exclude = "AddedBy,AddedOn")] Users users)
        {
            if (ModelState.IsValid)
            {
                db.Entry(users).State = EntityState.Modified;
                var encryptedPassword = CustomEnrypt.Encrypt(users.UserPass);
                users.UserPass = encryptedPassword;
                db.Entry(users).Property(uco => uco.AddedBy).IsModified = false;
                db.Entry(users).Property(uco => uco.AddedOn).IsModified = false;

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(users));
        }
예제 #10
0
        /// <summary>
        ///
        /// </summary>
        /// <returns>Returns null if login fails, else return UserObject</returns>
        public static User Login(string email, string password)
        {
            ApplicationDBEntities ctx = new ApplicationDBEntities();
            string      encryptedPw   = CustomEnrypt.Encrypt(password);
            List <User> uList         = ctx.User.AsNoTracking().Where(u => u.Email.ToLower() == email.ToLower() && u.PasswordHash == encryptedPw).ToList();

            ctx.Dispose();
            if (uList.Count > 0)
            {
                return(uList[0]);
            }
            else
            {
                return(null);
            }
        }
예제 #11
0
 public ActionResult Registration(Models.User model)
 {
     if (ModelState.IsValid)
     {
         using (var db = new MainDbContext())
         {
             var encryptedPassword = CustomEnrypt.Encrypt(model.Password);
             var user = db.UserDbContext.Create();
             user.UserEmail    = model.Email;
             user.UserPassword = encryptedPassword;
             db.UserDbContext.Add(user);
             db.SaveChanges();
         }
         return(RedirectToAction("Login", "Auth"));
     }
     else
     {
         ModelState.AddModelError("", "Missing Registration Information or Password Mismatch");
         return(View(model));
     }
 }
예제 #12
0
        public ActionResult Registration(User model)
        {
            if (ModelState.IsValid)
            {
                var emailExists    = EmailExists(model.Email);
                var usernameExists = UsernameExists(model.Name);


                if (emailExists)
                {
                    ModelState.AddModelError("Email", "Email already in use.");
                }
                if (usernameExists)
                {
                    ModelState.AddModelError("Username", "Username already in use.");
                }
                if (!usernameExists && !emailExists)
                {
                    using (var db = new MainDbContext())
                    {
                        var encryptedPassword = CustomEnrypt.Encrypt(model.Password);
                        var user = db.Users.Create();
                        user.Email    = model.Email;
                        user.Password = encryptedPassword;
                        user.Country  = model.Country;
                        user.Name     = model.Name;
                        db.Users.Add(user);
                        db.SaveChanges();

                        return(RedirectToAction("Login", "Auth"));
                    }
                }
            }
            else
            {
                ModelState.AddModelError("", "Invalid input");
            }
            return(View());
        }
예제 #13
0
 public ActionResult Registration(Users model)
 {
     if (ModelState.IsValid)
     {
         using (var db = new MainDbContext())
         {
             var encryptedPassword = CustomEnrypt.Encrypt(model.Password);
             var user = db.Users.Create();
             user.Email    = model.Email;
             user.Password = encryptedPassword;
             user.Country  = model.Country;
             user.Name     = model.Name;
             db.Users.Add(user);
             db.SaveChanges();
         }
     }
     else
     {
         ModelState.AddModelError("", "One or more fields have been");
     }
     return(View());
 }
예제 #14
0
        public ActionResult Registration(LoginModel model)
        {
            if (ModelState.IsValid)
            {
                using (var db = new MainDbContext())
                {
                    var queryUser = db.Users.FirstOrDefault(u => u.Username == model.Users.Username);
                    if (queryUser == null)
                    {
                        var encryptedPassword = CustomEnrypt.Encrypt(model.Users.Password);
                        var user = db.Users.Create();
                        var role = db.Role.Create();
                        user.Username = model.Users.Username;
                        user.Password = encryptedPassword;
                        role.RoleType = "administrator";
                        db.Role.Add(role);
                        db.SaveChanges();

                        user.Key_Role = role.Id;
                        db.Users.Add(user);
                        db.SaveChanges();

                        return(RedirectToAction("Login", "Auth"));
                    }
                    else
                    {
                        return(RedirectToAction("Registration", "Auth"));
                    }
                }
            }
            else
            {
                ModelState.AddModelError("", "One or more fields have been");
            }
            return(View());
        }
예제 #15
0
        public ActionResult CreatePatient(PatientModel model)
        {
            if (ModelState.IsValid)
            {
                using (var db = new MainDbContext())
                {
                    var queryUser = db.Users.FirstOrDefault(u => u.Username == model.Users.Username);
                    if (queryUser == null)
                    {
                        var encryptedPassword = CustomEnrypt.Encrypt(model.Users.Password);

                        var patient = db.Patient.Create();
                        var address = db.Address.Create();
                        var contact = db.Contact.Create();
                        var user    = db.Users.Create();
                        var role    = db.Role.Create();
                        patient.FirstName     = model.Patient.FirstName;
                        patient.MiddleName    = model.Patient.MiddleName;
                        patient.LastName      = model.Patient.LastName;
                        patient.Email         = model.Patient.Email;
                        patient.DateBirth     = model.Patient.DateBirth;
                        patient.Sex           = model.Patient.Sex;
                        patient.MaritalStatus = model.Patient.MaritalStatus;
                        patient.HoursWorked   = model.Patient.HoursWorked;
                        patient.CompanyName   = model.Patient.CompanyName;
                        patient.Occupation    = model.Patient.Occupation;
                        address.AddressType   = model.Address.AddressType;
                        address.City          = model.Address.City;
                        address.Province      = model.Address.Province;
                        address.Zipcode       = model.Address.Zipcode;
                        user.Username         = model.Users.Username;
                        user.Password         = encryptedPassword;
                        user.Password         = encryptedPassword;
                        contact.MobileNo      = model.Contact.MobileNo;
                        contact.PhoneNo       = model.Contact.PhoneNo;

                        db.Address.Add(address);
                        db.Contact.Add(contact);
                        db.Role.Add(role);
                        db.SaveChanges();

                        user.Key_Role = role.Id;
                        db.Users.Add(user);
                        db.SaveChanges();

                        patient.Key_Address = address.Id;
                        patient.Key_Contact = contact.Id;
                        db.Patient.Add(patient);
                        db.SaveChanges();

                        return(RedirectToAction("CreatePatient", "FDR"));
                    }
                    else
                    {
                        return(RedirectToAction("CreatePatient", "FDR"));
                    }
                }
            }
            else
            {
                ModelState.AddModelError("", "One or more fields have been");
            }
            return(View());
        }
        public ActionResult Registration([Bind(Exclude = "IsEmailVerified,ActivationCode")] User user)
        {
            bool   Status  = false;
            string message = "";

            //
            // Model Validation
            if (ModelState.IsValid)
            {
                #region //Email is already Exist
                var isExist = IsEmailExist(user.EmailID);
                if (isExist)
                {
                    ModelState.AddModelError("EmailExist", "Email already exist");
                    return(View(user));
                }
                if (!checkPasswordStrengt(user.Password))
                {
                    message = "password does not match rules please include one uppercase letter, one number and one of these symbols !,@,#,$,%,^,&,*,?,_,~,-,£,(,)";
                    Status  = true;
                }
                else
                {
                    #endregion

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

                    #region  Password Hashing
                    string keyOne  = CustomEnrypt.RandomString(15);
                    string keyTwo  = CustomEnrypt.RandomString(15);
                    string keyTree = CustomEnrypt.RandomString(15);
                    user.Password = CustomEnrypt.Encrypt(user.Password, keyOne);
                    //user.Password = Crypto.Hash(user.Password);
                    user.ConfirmPassword = CustomEnrypt.Encrypt(user.ConfirmPassword, keyOne);
                    #endregion
                    user.IsEmailVerified = false;

                    #region Save to Database
                    using (MyDatabaseEntities dc = new MyDatabaseEntities())
                    {
                        User new_user = dc.Users.Create();
                        new_user = user;
                        cryptokey crypto = dc.cryptokeys.Create();
                        crypto.cryptone  = CustomEnrypt.Encrypt(keyOne, keyTwo);
                        crypto.crypttwo  = CustomEnrypt.Encrypt(keyTwo, keyTree);
                        crypto.crypttree = keyTree;
                        dc.Users.Add(new_user);
                        dc.cryptokeys.Add(crypto);
                        try
                        {
                            dc.SaveChanges();
                        }
                        catch (DbEntityValidationException ex)
                        {
                            foreach (var entityValidationErrors in ex.EntityValidationErrors)
                            {
                                foreach (var validationError in entityValidationErrors.ValidationErrors)
                                {
                                    Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                                }
                            }
                        }

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

            ViewBag.Message = message;
            ViewBag.Status  = Status;
            return(View(user));
        }
예제 #17
0
        public ActionResult CreateDoctor(DoctorModel model)
        {
            if (ModelState.IsValid)
            {
                using (var db = new MainDbContext())
                {
                    var queryUser = db.Users.FirstOrDefault(u => u.Username == model.Users.Username);
                    if (queryUser == null)
                    {
                        var encryptedPassword = CustomEnrypt.Encrypt(model.Users.Password);

                        var doctor  = db.Doctor.Create();
                        var address = db.Address.Create();
                        var contact = db.Contact.Create();
                        var user    = db.Users.Create();
                        var role    = db.Role.Create();
                        doctor.FirstName      = model.Doctor.FirstName;
                        doctor.MiddleName     = model.Doctor.MiddleName;
                        doctor.LastName       = model.Doctor.LastName;
                        doctor.Email          = model.Doctor.Email;
                        doctor.DateBirth      = model.Doctor.DateBirth;
                        doctor.Sex            = model.Doctor.Sex;
                        doctor.SecQuestion    = model.Doctor.SecQuestion;
                        doctor.SecAnswer      = model.Doctor.SecAnswer;
                        doctor.EmployeeId     = model.Doctor.EmployeeId;
                        doctor.LicenseNo      = model.Doctor.LicenseNo;
                        doctor.HospName       = model.Doctor.HospName;
                        doctor.Specialization = model.Doctor.Specialization;
                        address.AddressType   = model.Address.AddressType;
                        address.City          = model.Address.City;
                        address.Province      = model.Address.Province;
                        address.Zipcode       = model.Address.Zipcode;
                        user.Username         = model.Users.Username;
                        user.Password         = encryptedPassword;
                        user.Password         = encryptedPassword;
                        role.RoleType         = "doctor";
                        contact.MobileNo      = model.Contact.MobileNo;
                        contact.PhoneNo       = model.Contact.PhoneNo;

                        db.Address.Add(address);
                        db.Contact.Add(contact);
                        db.Role.Add(role);
                        db.SaveChanges();

                        user.Key_Role = role.Id;
                        db.Users.Add(user);
                        db.SaveChanges();

                        doctor.Key_Users   = user.Id;
                        doctor.Key_Address = address.Id;
                        doctor.Key_Contact = contact.Id;
                        db.Doctor.Add(doctor);
                        db.SaveChanges();

                        return(RedirectToAction("CreateDoctor", "Admin"));
                    }
                    else
                    {
                        return(RedirectToAction("CreateDoctor", "Admin"));
                    }
                }
            }
            else
            {
                ModelState.AddModelError("", "One or more fields have been");
            }
            return(View());
        }
예제 #18
0
        public ActionResult EditProfile(NurseModel model)
        {
            if (ModelState.IsValid)
            {
                using (var db = new MainDbContext())
                {
                    string firstname = User.Identity.Name;

                    //Get Doctor
                    var NurseModel = db.Nurse.FirstOrDefault(u => u.FirstName.Equals(firstname));
                    NurseModel.HospName    = model.Nurse.HospName;
                    NurseModel.EmployeeId  = model.Nurse.EmployeeId;
                    NurseModel.LicenseNo   = model.Nurse.LicenseNo;
                    NurseModel.FirstName   = model.Nurse.FirstName;
                    NurseModel.MiddleName  = model.Nurse.MiddleName;
                    NurseModel.LastName    = model.Nurse.LastName;
                    NurseModel.Email       = model.Nurse.Email;
                    NurseModel.DateBirth   = model.Nurse.DateBirth;
                    NurseModel.Sex         = model.Nurse.Sex;
                    NurseModel.SecQuestion = model.Nurse.SecQuestion;
                    NurseModel.SecAnswer   = model.Nurse.SecAnswer;

                    db.Entry(NurseModel).State = EntityState.Modified;

                    // Get the Address
                    var searchKeyAdd      = db.Nurse.Select(u => u.Key_Address);
                    var materializeAddKey = searchKeyAdd.ToList();
                    var KeyAdd            = materializeAddKey[0];
                    var AddModel          = db.Address.FirstOrDefault(u => u.Id.Equals(KeyAdd));

                    AddModel.City        = model.Address.City;
                    AddModel.Province    = model.Address.Province;
                    AddModel.Zipcode     = model.Address.Zipcode;
                    AddModel.AddressType = model.Address.AddressType;

                    db.Entry(AddModel).State = EntityState.Modified;

                    // Get the Contact
                    var searchKeyCon      = db.Nurse.Select(u => u.Key_Contact);
                    var materializeConKey = searchKeyCon.ToList();
                    var KeyCon            = materializeConKey[0];
                    var ConModel          = db.Contact.FirstOrDefault(u => u.Id.Equals(KeyCon));

                    ConModel.MobileNo = model.Contact.MobileNo;
                    ConModel.PhoneNo  = model.Contact.PhoneNo;

                    db.Entry(ConModel).State = EntityState.Modified;

                    // Get the Users
                    var searchUserKey      = db.Nurse.Select(u => u.Key_Users);
                    var materializeUserKey = searchUserKey.ToList();
                    var KeyUser            = materializeUserKey[0];
                    var UsersModel         = db.Users.FirstOrDefault(u => u.Id.Equals(KeyUser));

                    var encryptedPassword = CustomEnrypt.Encrypt(model.Users.Password);
                    UsersModel.Username = model.Users.Username;
                    UsersModel.Password = encryptedPassword;

                    db.Entry(UsersModel).State = EntityState.Modified;


                    db.SaveChanges();

                    var identity = new ClaimsIdentity(new[] {
                        new Claim(ClaimTypes.Name, NurseModel.FirstName),
                        new Claim(ClaimTypes.Role, "FDR")
                    }, "ApplicationCookie");

                    var ctx = Request.GetOwinContext();

                    var authManager = ctx.Authentication;

                    authManager.SignIn(identity);


                    return(RedirectToAction("Index", "Nurse"));
                }
            }

            return(View(model));
        }
예제 #19
0
        public ActionResult ChangePassword(ChangePassword model, string ReturnUrl = "")
        {
            string message     = "";
            bool   Status      = false;
            string type        = "Success";
            var    userControl = new UserController();

            if (!userControl.checkPasswordStrengt(model.NewPassword))
            {
                message = "password does not match rules please include one uppercase letter, one number and one of these symbols !,@,#,$,%,^,&,*,?,_,~,-,£,(,)";
                Status  = true;
                type    = "Error";
            }
            else
            {
                var CurrentUserEmail = HttpContext.User.Identity.Name;
                using (MyDatabaseEntities dc = new MyDatabaseEntities())
                {
                    var user                  = dc.Users.Where(x => x.EmailID == CurrentUserEmail).FirstOrDefault();
                    var getPassword           = dc.Users.Where(u => u.EmailID == user.EmailID).Select(u => u.Password);
                    var materializePassword   = getPassword.ToList();
                    var password              = materializePassword[0];
                    var getCryptoOne          = dc.cryptokeys.Where(u => u.UserID == user.UserID).Select(u => u.cryptone);
                    var materializeCryptoOne  = getCryptoOne.ToList();
                    var CryptoOne             = materializeCryptoOne[0];
                    var getCryptoTwo          = dc.cryptokeys.Where(u => u.UserID == user.UserID).Select(u => u.crypttwo);
                    var materializeCryptoTwo  = getCryptoTwo.ToList();
                    var CryptoTwo             = materializeCryptoTwo[0];
                    var getCryptoTree         = dc.cryptokeys.Where(u => u.UserID == user.UserID).Select(u => u.crypttree);
                    var materializeCryptoTree = getCryptoTree.ToList();
                    var keyTree               = materializeCryptoTree[0];
                    var keyTwo                = CustomDecrypt.Decrypt(CryptoTwo, keyTree);
                    var keyOne                = CustomDecrypt.Decrypt(CryptoOne, keyTwo);
                    var decryptPassword       = CustomDecrypt.Decrypt(password, keyOne);

                    if ((string.Compare(model.Password, decryptPassword) == 0))
                    {
                        string NewkeyOne  = CustomEnrypt.RandomString(15);
                        string NewkeyTwo  = CustomEnrypt.RandomString(15);
                        string NewkeyTree = CustomEnrypt.RandomString(15);
                        user.Password = CustomEnrypt.Encrypt(model.NewPassword, NewkeyOne);
                        //user.Password = Crypto.Hash(user.Password);
                        user.ConfirmPassword = CustomEnrypt.Encrypt(model.ConfirmPassword, NewkeyOne);
                        var crypto = dc.cryptokeys.Where(x => x.UserID == user.UserID).FirstOrDefault();
                        crypto.cryptone  = CustomEnrypt.Encrypt(NewkeyOne, NewkeyTwo);
                        crypto.crypttwo  = CustomEnrypt.Encrypt(NewkeyTwo, NewkeyTree);
                        crypto.crypttree = NewkeyTree;
                        try
                        {
                            if (user.TempPasswordSet)
                            {
                                user.TempPasswordSet = false;
                                user.Failed_Logins   = 0;
                            }
                            dc.SaveChanges();
                            message = "Your password have been successfuly changed.";
                            Status  = true;
                        }
                        catch (DbEntityValidationException ex)
                        {
                            foreach (var entityValidationErrors in ex.EntityValidationErrors)
                            {
                                foreach (var validationError in entityValidationErrors.ValidationErrors)
                                {
                                    Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                                }
                            }
                        }
                    }
                    else
                    {
                        message = "Password does not match if Error continues contact administrator.";
                        Status  = true;
                        type    = "Error";
                    }
                }
            }

            ViewBag.Message = message;
            ViewBag.Status  = Status;
            ViewBag.Type    = type;
            return(View());
        }