Example #1
0
        public ActionResult ForgotPassword(string Username)
        {
            string LoginType;

            try
            {
                string userkey = ConfigurationManager.AppSettings["userkey"];
                string uid     = ConfigurationManager.AppSettings["uid"];

                string ipaddress   = Request.UserHostAddress;
                string Agent       = Request.UserAgent;
                string BrowserUsed = Request.Browser.Browser;

                Employer.Employer employer = new Employer.Employer();

                if ((Username.Trim().Length >= 5) && (Username.Trim().Contains("@") == true) && (Username.Trim().Contains(".") == true))
                {
                    LoginType = "2";
                    var       LoginVal = Username;
                    DataTable dt       = employer.ResetPassword(Username, LoginType, BrowserUsed, uid, userkey, uid);
                    dt.TableName = "ReturnedVal";

                    var response = dt.Columns.Count.ToString();

                    if (response == "2")
                    {
                        var erroStatus = (from DataRow dr in dt.Rows
                                          select new ForgotPassword()
                        {
                            Message = dr["Message"].ToString(),
                            LoginStat = dr["LoginStat"].ToString(),
                        }).ToList();
                        TempData["error"] = erroStatus[0].Message;
                        return(View());
                    }

                    var forgotStatus = (from DataRow dr in dt.Rows
                                        select new ForgotPassword()
                    {
                        Message = dr["Message"].ToString(),
                        LoginStat = dr["LoginStat"].ToString(),
                        RSAPIN = dr["RSAPIN"].ToString()
                    }).ToList();

                    TempData["sMsg"] = forgotStatus[0].Message;
                    return(RedirectToAction("Index"));
                }
                else if ((Username.Trim().Length >= 10) && ((Username.Trim().All(char.IsDigit)) == true))
                {
                    LoginType = "1";
                    var       LoginVal = Username;
                    DataTable dt       = employer.ResetPassword(Username, LoginType, BrowserUsed, uid, userkey, uid);
                    dt.TableName = "ReturnedVal";

                    var response = dt.Columns.Count.ToString();

                    if (response == "2")
                    {
                        var erroStatus = (from DataRow dr in dt.Rows
                                          select new ForgotPassword()
                        {
                            Message = dr["Message"].ToString(),
                            LoginStat = dr["LoginStat"].ToString(),
                        }).ToList();
                        TempData["error"] = erroStatus[0].Message;
                        return(View());
                    }

                    var forgotStatus = (from DataRow dr in dt.Rows
                                        select new ForgotPassword()
                    {
                        Message = dr["Message"].ToString(),
                        LoginStat = dr["LoginStat"].ToString(),
                        RSAPIN = dr["RSAPIN"].ToString()
                    }).ToList();

                    TempData["sMsg"] = forgotStatus[0].Message;
                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData["error"] = "Email/Password not found";
                    return(View());
                }
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog(Username, "", "", "Login/ForgotPassword", "Login", "ForgotPassword", "ResetPassword Error", ex.Message.ToString(), 0);
                return(View());
            }
        }