public ActionResult PassResetForm(UserPassword userPassword, FormCollection collection)
        {
            //if (ModelState.IsValid)
            //{
                string newPass = collection["nPass"];
                string newPassConfirm = collection["nPassConfirm"];

                if (newPass == newPassConfirm)
                {
                    userPassword.Password = newPass;
                    userPassword.IsReset = false;
                    db.Entry(userPassword).State = EntityState.Modified;
                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                    return RedirectToAction("Index", "Home");
                }
            //}

            return BreadCrum.RedirectToPreviousAction(Session, ControllerName);
        }
        public ActionResult Register(FormCollection collection, UserContract userContract)
        {
            try
            {
                var translation = TranslationDictionary;
                if (!ModelState.IsValid)
                {
                    return View(userContract);
                }

                var valid = true;
                if (collection["Password"] != collection["PasswordConfirm"] || string.IsNullOrEmpty(collection["Password"]))
                {
                    ModelState.AddModelError("User.UserPassword.Password", "!");
                    valid = false;
                }

                //if (string.IsNullOrEmpty(collection["UserName"]))
                //{
                //    ModelState.AddModelError("User.UserPassword.UserName", "!");
                //    valid = false;
                //}

                if (string.IsNullOrEmpty(userContract.User.Firstname))
                {
                    ModelState.AddModelError("User.FirstName", "!");
                    valid = false;
                }

                if (string.IsNullOrEmpty(userContract.User.Lastname))
                {
                    ModelState.AddModelError("User.LastName", "!");
                    valid = false;
                }

                if (string.IsNullOrEmpty(userContract.User.EmailAddress))
                {
                    ModelState.AddModelError("User.EmailAddress", "!");
                    valid = false;
                }

                if (string.IsNullOrEmpty(userContract.Uri))
                {
                    ModelState.AddModelError("Uri", "!");
                    valid = false;
                }

                if (!valid)
                    return View(userContract);

                if (userContract.Contract == null)
                {
                    var contract = db.Contracts.SingleOrDefault(row => row.Id.Equals(userContract.ContractId));
                    userContract.Contract = contract;
                }

                if (!userContract.eId.HasValue())
                {
                    userContract.eId = Utilities.GetRandomSalt(5);
                }
                if (userContract.User.UserRole == null)
                {
                    var role = db.UserRoles.SingleOrDefault(row => row.Id.Equals(userContract.User.UserRoleId));
                    userContract.User.UserRole = role;
                }

                var password = collection["Password"];
                var userName = userContract.User.EmailAddress;//collection["UserName"];
                var userPassword = db.UserPasswords.SingleOrDefault(row => row.UserName == userName);
                if (userPassword != null)
                {
                    ModelState.AddModelError("","User already exists".TranslateString(ref translation));
                    return View();
                }
                userPassword = new UserPassword()
                {
                    Id = Guid.NewGuid(),
                    Password = password,
                    UserName = userContract.User.EmailAddress,//userName,
                    FullName = userContract.User.ContactFullName,
                    UserId = userContract.UserId,
                    IsAccountAdmin = true,
                    IsReset = false,
                    EmailAddress = userContract.User.EmailAddress
                };
                userContract.User.UserPasswords.Add(userPassword);

                if (userContract.Id == Guid.Empty)
                {
                    userContract.Id = Guid.NewGuid();
                }
                db.UserContracts.Add(userContract);
                db.SaveChanges();
                db.UserContracts.Remove(userContract);
                db.SaveChanges();
                ClientTools.SendUserRegisteredMail("NL", userPassword.Id);

                return RedirectToAction("LogIn");
            }
            catch (DbEntityValidationException ex)
            {
                ModelState.AddModelError("", ex);
                return View(userContract);
                throw ex;
            }
        }
 public ActionResult PassResetForm(UserPassword userPassword)
 {
     return View(userPassword);
 }