public ActionResult ResetPassword(int pageId, string resetcode)
        {
            helperResetPassword helperPage = new helperResetPassword();
            pageShared ps = new pageShared(db);

            var pageItem = ps.getPageById(pageId);

            if (pageItem == null)
            {
                return null;
            }

            ps.pageTitleBind(pageItem, helperPage, langId);
            helperPage.setTitle(pageItem.name);
            helperPage.breadCrumbItem = getBreadCrumbStaticPage(pageItem.name);

            helperPage.detail = pageItem.detail;

            bool isErrorExist = false;

            if (string.IsNullOrWhiteSpace(resetcode))
            {

                helperPage.message = App_GlobalResources.lang.resetPasswordNull;
                isErrorExist = true;
            }
            else
            {
                var forgetPasswordItem = db.tbl_forgetPassword.Where(a => a.code == resetcode).FirstOrDefault();

                if (forgetPasswordItem != null)
                {
                    helperPage.resetCode = forgetPasswordItem.code;
                    helperPage.userId = forgetPasswordItem.userId;
                    return View(helperPage);

                }
                else
                {
                    helperPage.message = App_GlobalResources.lang.resetPasswordWrong;
                    isErrorExist = true;
                }

            }

            if (isErrorExist)
            {
                string forgetPasswordLink = "";
                var forgetPassPage = ps.getPageByType(pageType.forgetPassword, langId);

                if (forgetPassPage != null)
                {
                    forgetPasswordLink = getSiteName(Request) + langCode + "/" + forgetPassPage.url + ".html";
                }

                helperPage.message = helperPage.message.Replace("[forgetPasswordLink]", forgetPasswordLink);
                helperPage.isMessageExist = true;
                helperPage.isErrorExist = true;

                return View(helperPage);
            }

            return null;
        }
        public ActionResult ResetPassword(int pageId, helperResetPassword helperPage)
        {
            pageShared ps = new pageShared(db);
            userShared us = new userShared(db);

            if (helperPage.password != helperPage.passwordRep)
            {
                ModelState.AddModelError("passwordRep", App_GlobalResources.lang.formPassworRepSame);
            }

            var pageItem = ps.getPageById(pageId);

            if (pageItem == null)
            {
                return null;
            }

            ps.pageTitleBind(pageItem, helperPage, langId);
            helperPage.setTitle(pageItem.name);
            helperPage.breadCrumbItem = getBreadCrumbStaticPage(pageItem.name);
            helperPage.detail = pageItem.detail;

            if (ModelState.IsValid)
            {
                // password - code reControl
                var forgetItem = db.tbl_forgetPassword.Where(a => a.code == helperPage.resetCode).FirstOrDefault();

                if (forgetItem == null || forgetItem.userId != helperPage.userId)
                {
                    helperPage.isErrorExist = true;
                    helperPage.isMessageExist = true;
                    helperPage.message = getErrorMessage(App_GlobalResources.lang.unexpectedErrorMsg);
                    return View(helperPage);
                }

                // Reset Password
                try
                {
                    us.updateUserPassword(helperPage.userId, MD5(helperPage.password));
                    helperPage.isMessageExist = true;
                    helperPage.message = getSuccesMessage(App_GlobalResources.lang.resetPasswordSuccess);

                    string loginUrl = "";

                    var loginPage = ps.getPageByType(pageType.registerLogin, langId);

                    if (loginPage != null)
                    {
                        loginUrl = getSiteName(Request) + langCode + "/" + loginPage.url + ".html";
                    }

                    helperPage.message = helperPage.message.Replace("[loginPage]", loginUrl);

                }
                catch (Exception ex)
                {
                    errorSend(ex, "updatePassword", true);

                    helperPage.isErrorExist = false;
                    helperPage.isMessageExist = true;
                    helperPage.message = getErrorMessage(App_GlobalResources.lang.unexpectedErrorMsg);
                }

                try
                {
                    us.deleteForgetPasswordByUserId(helperPage.userId);
                }
                catch (Exception ex)
                {
                    errorSend(ex, "ForgetPasswordDelete");
                }
            }

            return View(helperPage);
        }