public ActionResult Index(passwordModels pModel)
        {
            var            newPass = new passwordModels();
            passwordModels objResult;


            try
            {
                //TODO: validate user password, save to session, etc

                string vPassLama = pModel.password.Trim().ToUpper();
                string vPassBaru = pModel.password2.Trim().ToUpper();
                string vKonfPass = pModel.keterangan.Trim().ToUpper();

                newPass.no_anggota = ConfigModels.GetNoAnggota();
                newPass.password   = vPassBaru;
                newPass.keterangan = vKonfPass;

                objResult = _userService.GetPassword(newPass.no_anggota);

                Log.Debug(DateTime.Now + "  ===>>>> USER CONTROLLER No Anggota : " + newPass.no_anggota +
                          ", Pass Lama dari DataBase : " + objResult.password + ", Pass Lama : " + vPassLama + ", Pass Baru : " + vPassBaru + ", Konfirmasi Pass : "******"2", "**Password Lama Yang Dimasukkan Salah...");
                }
                else
                {
                    if (vPassBaru != vKonfPass)
                    {
                        ModelState.AddModelError("3", "**Password Baru Tidak Sama...");
                    }
                    else
                    {
                        objResult = _userService.UpdatePassword(newPass);
                    }
                }

                if (ModelState.IsValid)
                {
                    Log.Info(DateTime.Now + " ===>>>> Change Password Success, UserCode: " + newPass.no_anggota);
                    ModelState.AddModelError("1", "CHANGE PASSWORD SUCCESS...");

                    // Redirect to requested URL, or homepage if no previous page requested
                    //string returnUrl = Request.QueryString["ReturnUrl"];
                    //if (!String.IsNullOrEmpty(returnUrl))
                    //    return Redirect(returnUrl);

                    //return RedirectToAction("Index", "Login");
                }
            }
            catch (Exception ex)
            {
                Log.Error(DateTime.Now + " =====>>>> Change Password Failed, No Anggota:" + pModel.no_anggota, ex);
                ModelState.AddModelError("1", "Change Password Failed, Please try Again or Contact Your Administrator.");
            }

            return(View(pModel));
        }
        public ActionResult Index(passwordModels model)
        {
            //string message = "";

            //bool isValid = false;
            //object objHasil = null;

            var objResp = new passwordModels();

            try
            {
                //TODO: validate user password, save to session, etc
                string vPassword  = model.password.Trim().ToUpper();
                string no_anggota = model.no_anggota.Trim().ToUpper();

                //Log.Debug(DateTime.Now + "LOGIN CONTROLLER No Anggota : " + no_anggota + ", Password : "******"LOGIN CONTROLLER ==>> ID : " + objResp.id);

                if (objResp.id > 0)
                {
                    var dataLogin = objResp.no_anggota + "#" + objResp.nama_anggota + "#" + objResp.sektor + "#" + objResp.as_admin;

                    Log.Debug(DateTime.Now + " LOGIN No Anggota : " + objResp.id + "/" + no_anggota + ", nama_anggota : " + objResp.nama_anggota + ", Pass User : "******", Pass Data : " + objResp.password + ", As Admin : " + objResp.as_admin);

                    if (vPassword != objResp.password.Trim().ToUpper())
                    {
                        ModelState.AddModelError("", "Password Yang dimasukkan Salah...");
                    }
                }
                else
                {
                    Log.Error("Login Failed, username:"******" Password : "******"", "Login Failed, Invalid Nomer Anggota...");
                }

                if (ModelState.IsValid)
                {
                    int    SessionTime    = 120;
                    string strSessionTime = System.Configuration.ConfigurationManager.AppSettings["SessionTime"];
                    if (!String.IsNullOrEmpty(strSessionTime))
                    {
                        if (!int.TryParse(strSessionTime, out SessionTime))
                        {
                            SessionTime = 120;
                        }
                    }

                    FormsAuthenticationTicket tkt;
                    string     cookiestr;
                    HttpCookie ck;
                    tkt = new FormsAuthenticationTicket(1,
                                                        objResp.no_anggota,
                                                        DateTime.Now,
                                                        DateTime.Now.AddMinutes(SessionTime),
                                                        false,
                                                        objResp.no_anggota + "#" + objResp.nama_anggota + "#" + objResp.sektor + "#" + objResp.as_admin);

                    cookiestr = FormsAuthentication.Encrypt(tkt);

                    ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);

                    //if (model.RememberMe)
                    //    ck.Expires = tkt.Expiration;

                    ck.Path = FormsAuthentication.FormsCookiePath;
                    Response.Cookies.Add(ck);

                    // Log
                    Log.Info("Login Success, UserCode: " + model.no_anggota);

                    // Redirect to requested URL, or homepage if no previous page requested
                    string returnUrl = Request.QueryString["ReturnUrl"];
                    if (!String.IsNullOrEmpty(returnUrl))
                    {
                        return(Redirect(returnUrl));
                    }

                    return(RedirectToAction("Index", "Pelanggan"));
                }
            }
            catch (Exception ex)
            {
                Log.Error("Login Failed, username:"******"", "Login Failed, Please try Again or Contact Your Administrator.");
            }


            // Re-Initiate
            //model = InitiateLoginForm(model);

            return(View(model));
        }