public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {
                // ChangePassword will throw an exception rather
                // than return false in certain failure scenarios.
                bool changePasswordSucceeded;
                try
                {
                    MembershipProviderCustom MPC = new MembershipProviderCustom(true);

                    changePasswordSucceeded =  MPC.ChangePassword(User.Identity.Name.ToUpper(), model.OldPassword.ToUpper(), model.NewPassword.ToUpper());
                }
                catch (Exception)
                {
                    changePasswordSucceeded = false;
                }

                if (changePasswordSucceeded)
                {
                    return RedirectToAction("ChangePasswordSuccess");
                }
                else
                {
                    ModelState.AddModelError("", "A senha Atual está INCORRETA ou a Nova Senha é Inválida.");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
        public ActionResult LogOn(LogOnModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                MembershipProviderCustom MPC = new MembershipProviderCustom(true);

             //   RoleProviderCustom RPC = new RoleProviderCustom();

                if (MPC.ValidateUser(model.UserName, model.Password.ToUpper()))
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, false);

                    Session.Add("usuario", MPC.GetNomeCompleto(model.UserName.ToUpper()));

                    if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
                        && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    {
                        return Redirect(returnUrl);
                    }
                    else
                    {
                        return RedirectToAction("Index", "Home");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "O usuário ou Senha fornecidos estão incorretos.");
                }
            }
            // If we got this far, something failed, redisplay form
            return View(model);
        }