Exemple #1
0
        public ActionResult SignUp(User user)
        {
            if (this.Session["CaptchaImageText"].ToString() == user.SecurityCode)
            {
                string newSalt = PasswordEncryption.RandomString();
                user.Password    = PasswordEncryption.encryptPassword(user.Password, newSalt);
                user.Email       = user.NewEmail;
                user.RoleId      = 1;
                user.Status      = true;
                user.step_status = 0;

                UserAccess ua = new UserAccess();
                if (ua.InsertUser(user) >= 1)
                {
                    //ViewBag.SuccessMsg = "Your profile Successfully created.";
                    TempData["status"] = "success";
                    //If succeed update step table to step2
                    StepAccess sa = new StepAccess();
                    //if (sa.updateStepNumberByUserId(ua.getUserId(user.Email), 1))
                    return(RedirectToAction("UserLogin", "Login"));
                }
                TempData["status"] = "fail";
                //ViewBag.ErrorMsg = "Failed to Sign up try again!";
            }
            else
            {
                TempData["status"] = "captchaFail";
                //ViewBag.ErrorMsg = "Entered Security Code is Not Correct!";
                TempData["ErrorModel"] = user;
            }


            //return View();
            return(RedirectToAction("SignUp"));
        }
Exemple #2
0
        public ActionResult Step2(CompanyBranchModel userCompany2)
        {
            int userId = (int)Session["userId"];
            //int userId = 68;

            BranchAccess ba = new BranchAccess();

            userCompany2.MainBranch.StateId    = userCompany2.StateId;
            userCompany2.MainBranch.BranchCode = ba.createBranchCode(userCompany.Company.CompanyCode);
            userCompany.MainBranch             = userCompany2.MainBranch;
            int reslt = ba.insertFirstBranchDetails(userCompany, userId);

            if (reslt > 0)
            {
                StepAccess sa = new StepAccess();
                if (sa.updateStepNumberByUserId(userId, 3))
                {
                    bool reslt2 = ba.updateUserBranchId(userCompany2, userId);
                    if (reslt2)
                    {
                        return(RedirectToAction("Step3"));
                    }
                }
            }
            else
            {
                ViewBag.ErrorMsg = "Failed to create first branch";
            }
            return(View());
        }
Exemple #3
0
        // GET: SetupProcessTest
        public ActionResult Step1(int?edit)
        {
            Session["userId"] = 229;

            if (Session["userId"] == null || Session["userId"].ToString() == "")
            {
                return(RedirectToAction("UserLogin", "Login"));
            }

            int           userId = Convert.ToInt32(Session["userId"]);
            CompanyAccess ca     = new CompanyAccess();
            StepAccess    sa     = new StepAccess();
            // Get company types to list
            List <CompanyType> ctList = ca.GetAllCompanyType();

            ViewBag.TypeId = new SelectList(ctList, "TypeId", "TypeName");

            //Get states to list
            List <State> stateList = ca.GetAllStates();

            ViewBag.StateId = new SelectList(stateList, "StateId", "StateName");

            if (Convert.ToInt32(Session["companyStep"]) == 1 && edit != 1)
            {
                return(View());
            }

            if (edit == 1)
            {
                if (!string.IsNullOrEmpty(Session["userId"].ToString()))
                {
                    userId = Convert.ToInt32(Session["userId"]);
                    //----------
                    Company preCompany = ca.GetCompanyDetailsCompanyId(userData.Company_Id);


                    _comCode     = preCompany.CompanyCode;
                    ViewBag.Edit = "Yes";

                    return(View(preCompany));
                }
            }

            return(RedirectToAction("UserLogin", "Login"));
        }
Exemple #4
0
        public ActionResult Step2()
        {
            Session["userId"] = 229;
            //Session["userId"] = 4;
            //int userId = 68;
            if ((Session["userId"] != null) && (Session["userId"].ToString() != ""))
            //if(userId>0)
            {
                int        userId = (int)Session["userId"];
                StepAccess cs     = new StepAccess();
                int        reslt  = Convert.ToInt32(Session["companyStep"]);
                if (reslt == 2)
                {
                    if ((TempData["Company"] != null) && (TempData["Company"].ToString() != ""))
                    {
                        userCompany = new CompanyBranchModel();
                        userCompany = (CompanyBranchModel)TempData["Company"];

                        CompanyType = (userCompany.Company.TypeId == 1) ? "Lender" : "Dealer";

                        userCompany.MainBranch = new Branch();
                        if (userCompany.Company.Extension == null)
                        {
                            userCompany.Company.Extension = "";
                        }
                    }

                    //Get states to list
                    CompanyAccess ca        = new CompanyAccess();
                    List <State>  stateList = ca.GetAllStates();
                    ViewBag.StateId = new SelectList(stateList, "StateId", "StateName");

                    return(View(userCompany));
                }
                else
                {
                    return(RedirectToAction("UserLogin", "Login"));
                }
            }
            else
            {
                return(RedirectToAction("UserLogin", "Login"));
            }
        }
Exemple #5
0
        public ActionResult Step1(Company company, int?edit)
        {
            if (Session["userId"] == null || Session["userId"].ToString() == "")
            {
                return(RedirectToAction("UserLogin", "Login"));
            }


            string type;

            if (edit != 1)
            {
                GeneratesCode gc = new GeneratesCode();
                _comCode = company.CompanyCode = gc.GenerateCompanyCode(company.CompanyName);
                type     = "INSERT";
            }
            else
            {
                company.CompanyCode = _comCode;
                type = "UPDATE";
            }

            //
            company.Zip = company.ZipPre;
            if (company.Extension != null)
            {
                company.Zip += "-" + company.Extension;
            }

            company.CreatedBy     = company.FirstSuperAdminId = Convert.ToInt32(Session["userId"]);
            company.CompanyStatus = true;
            CompanyAccess ca = new CompanyAccess();

            //check this record is new one or exitsting one
            //string type = (edit == 1) ? "UPDATE" : "INSERT";

            int companyId = ca.InsertCompany(company, type);

            if (companyId > 0)
            {
                ViewBag.SuccessMsg = "Company Successfully setup.";

                CompanyType = (company.TypeId == 1) ? "Lender" : "Dealer";

                //If succeed update step table to step2
                StepAccess sa = new StepAccess();
                sa.updateStepNumberByUserId(company.FirstSuperAdminId, 2);

                //Send company detail to step 2
                CompanyBranchModel comBranch = new CompanyBranchModel();
                comBranch.Company = company;

                TempData["Company"] = comBranch;

                return(RedirectToAction("Step2"));
            }
            ViewBag.ErrorMsg = "Failed to Setup company.";

            // Get company types to list
            List <CompanyType> ctList = ca.GetAllCompanyType();

            ViewBag.TypeId = new SelectList(ctList, "TypeId", "TypeName");

            //Get states to list
            List <State> stateList = ca.GetAllStates();

            ViewBag.StateId = new SelectList(stateList, "StateId", "StateName");

            return(View());
        }
Exemple #6
0
        public ActionResult UserLogin(UserLogin user)
        {
            try
            {
                //string ip = Request.UserHostAddress;
                DataSet dsUser   = new DataSet();
                var     login    = new LoginAccess();
                var     step     = new StepAccess();
                User    userData = new User();
                userData.UserName = user.userName;

                //pass user name to database and get user details
                dsUser = login.CheckUserLogin(userData);
                if (dsUser.Tables[0].Rows.Count > 0)
                {
                    userData.UserId   = int.Parse(dsUser.Tables[0].Rows[0]["user_id"].ToString());
                    userData.UserName = dsUser.Tables[0].Rows[0]["user_name"].ToString();
                    userData.Password = dsUser.Tables[0].Rows[0]["password"].ToString();

                    userData.RoleId = int.Parse(dsUser.Tables[0].Rows[0]["role_id"].ToString());
                    if (userData.RoleId == 4)
                    {
                        DataSet dsDelearCompany = new DataSet();
                        dsDelearCompany = login.GetDealerUserCompanyBranch(userData.UserId);
                        if (dsDelearCompany.Tables[0].Rows[0]["company_id"].ToString() != "")
                        {
                            userData.Company_Id  = int.Parse(dsDelearCompany.Tables[0].Rows[0]["company_id"].ToString());
                            userData.CompanyName = dsDelearCompany.Tables[0].Rows[0]["company_name"].ToString();
                        }
                        if (dsDelearCompany.Tables[0].Rows[0]["branch_id"].ToString() != "")
                        {
                            userData.BranchId   = int.Parse(dsDelearCompany.Tables[0].Rows[0]["branch_id"].ToString());
                            userData.BranchName = dsDelearCompany.Tables[0].Rows[0]["branch_name"].ToString();
                        }
                    }
                    else
                    {
                        userData.BranchId   = int.Parse(dsUser.Tables[0].Rows[0]["branch_id"].ToString());
                        userData.BranchName = dsUser.Tables[0].Rows[0]["branch_name"].ToString();
                        if (dsUser.Tables[0].Rows[0]["company_id"].ToString() != "")
                        {
                            userData.Company_Id  = int.Parse(dsUser.Tables[0].Rows[0]["company_id"].ToString());
                            userData.CompanyType = int.Parse(dsUser.Tables[0].Rows[0]["company_type"].ToString());
                            userData.CompanyCode = dsUser.Tables[0].Rows[0]["company_code"].ToString();
                        }
                        else
                        {
                            userData.Company_Id = 0;
                        }
                        userData.CompanyName = dsUser.Tables[0].Rows[0]["company_name"].ToString();
                    }

                    userData.step_status = int.Parse(dsUser.Tables[0].Rows[0]["step_status"].ToString());

                    //To compair Database password and user enter password
                    string   passwordFromDB = userData.Password;
                    char[]   delimiter      = { ':' };
                    string[] split          = passwordFromDB.Split(delimiter);
                    var      checkCharHave  = passwordFromDB.ToLowerInvariant().Contains(':');
                    if (passwordFromDB == null || (checkCharHave == false))
                    {
                        Log log = new Log(userData.UserId, userData.Company_Id, userData.BranchId, 0, "User Login", "User : "******" was unable to login, Entered password did not match", DateTime.Now);

                        int islog = (new LogAccess()).InsertLog(log);
                        return(RedirectToAction("UserLogin", "Login", new { lbl = "Incorrect Username & Password combination. Please confirm entry and resubmit." }));
                    }

                    string passwordEncripted = PasswordEncryption.encryptPassword(user.password, split[1]);
                    if (string.Compare(passwordEncripted, passwordFromDB) == 0)
                    {
                        //user object pass to session
                        Session["AuthenticatedUser"] = userData;

                        // Does not complete atleast one cycle
                        if (userData.step_status == 0)
                        {
                            if (userData.RoleId == 3)
                            {
                                Log log = new Log(userData.UserId, userData.Company_Id, userData.BranchId, 0, "User Login", "User : "******" was unable to login", DateTime.Now);

                                int islog = (new LogAccess()).InsertLog(log);
                                return(RedirectToAction("UserLogin", "Login", new { lbl = "Company setup process is on going please contact admin." }));
                            }
                            else
                            {
                                Log log = new Log(userData.UserId, userData.Company_Id, userData.BranchId, 0, "User Login", "User : "******" has logged successfully", DateTime.Now);

                                int islog = (new LogAccess()).InsertLog(log);
                                if (userData.Company_Id == 0)
                                {
                                    Session["companyStep"] = 1;
                                    return(RedirectToAction("Index", "SetupProcess"));
                                }
                                else if (userData.Company_Id > 0)
                                {
                                    if (userData.RoleId == 1)
                                    {
                                        DataSet dsStepNo = new DataSet();
                                        dsStepNo = step.checkSuperAdminLoginWhileCompanySetup(userData);
                                        if (dsStepNo.Tables[0].Rows.Count > 0)
                                        {
                                            Session["companyStep"] = int.Parse(dsStepNo.Tables[0].Rows[0]["step_number"].ToString());
                                            return(RedirectToAction("Index", "SetupProcess"));
                                        }
                                        else
                                        {
                                            LoanSetupStep loanStep     = new LoanSetupStep();
                                            DataSet       dsLoanStepNo = new DataSet();
                                            dsLoanStepNo = step.checkUserLoginWhileLoanSetup(userData);
                                            if (dsLoanStepNo.Tables[0].Rows.Count > 0)
                                            {
                                                loanStep.CompanyId             = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["company_id"].ToString());
                                                loanStep.BranchId              = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["branch_id"].ToString());
                                                loanStep.stepId                = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["step_number"].ToString());
                                                loanStep.nonRegisteredBranchId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["non_registered_branch_id"].ToString());
                                                if (dsLoanStepNo.Tables[0].Rows[0]["loan_id"].ToString() != "")
                                                {
                                                    loanStep.loanId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["loan_id"].ToString());
                                                }
                                                else
                                                {
                                                    loanStep.loanId = 0;
                                                }
                                                Session["loanStep"] = loanStep;
                                                if (userData.RoleId == 1)
                                                {
                                                    return(RedirectToAction("Step" + (loanStep.stepId + 5), "SetupProcess"));
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        //if step table has record pass(company id and branch id)
                                        DataSet dsStepNo = new DataSet();
                                        dsStepNo = step.checkUserLoginWhileCompanySetup(userData);
                                        if (dsStepNo.Tables[0].Rows.Count > 0)
                                        {
                                            Session["companyStep"] = int.Parse(dsStepNo.Tables[0].Rows[0]["step_number"].ToString());
                                            return(RedirectToAction("Index", "SetupProcess"));
                                        }
                                        else
                                        {
                                            //No Step recor in relavent Company and branch
                                            LoanSetupStep loanStep     = new LoanSetupStep();
                                            DataSet       dsLoanStepNo = new DataSet();
                                            dsLoanStepNo = step.checkUserLoginWhileLoanSetup(userData);
                                            if (dsLoanStepNo.Tables[0].Rows.Count > 0)
                                            {
                                                loanStep.CompanyId             = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["company_id"].ToString());
                                                loanStep.BranchId              = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["branch_id"].ToString());
                                                loanStep.stepId                = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["step_number"].ToString());
                                                loanStep.nonRegisteredBranchId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["non_registered_branch_id"].ToString());
                                                if (dsLoanStepNo.Tables[0].Rows[0]["loan_id"].ToString() != "")
                                                {
                                                    loanStep.loanId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["loan_id"].ToString());
                                                }
                                                else
                                                {
                                                    loanStep.loanId = 0;
                                                }

                                                Session["loanStep"] = loanStep;
                                                return(RedirectToAction("Step" + (loanStep.stepId + 5), "SetupProcess"));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        // Complete cycle and no start new cycle
                        else if (userData.step_status == 1 || userData.step_status == 2)
                        {
                            //delete just added unit if exists
                            UnitAccess ua = new UnitAccess();
                            ua.DeleteJustAddedUnits(userData.UserId);

                            //insert log
                            Log log = new Log(userData.UserId, userData.Company_Id, userData.BranchId, 0, "User Login", "User : "******" has logged successfully", DateTime.Now);

                            int islog = (new LogAccess()).InsertLog(log);

                            return(RedirectToAction("UserDetails", "UserManagement"));
                        }
                        // atleast one cycle complete and Start new cycle
                        //else if (userData.step_status == 2)
                        //{

                        //    //delete just added unit if exists
                        //    UnitAccess ua = new UnitAccess();
                        //    ua.DeleteJustAddedUnits(userData.UserId);
                        //    //insert log
                        //    Log log = new Log(userData.UserId, userData.Company_Id, userData.BranchId, 0, "User Login", "User : "******" has logged successfully", DateTime.Now);

                        //    int islog = (new LogAccess()).InsertLog(log);
                        //    if (userData.RoleId == 1)
                        //    {
                        //        DataSet dsStepNo = new DataSet();
                        //        dsStepNo = step.checkSuperAdminLoginWhileCompanySetup(userData);
                        //        if (dsStepNo.Tables[0].Rows.Count > 0)
                        //        {
                        //            Session["companyStep"] = int.Parse(dsStepNo.Tables[0].Rows[0]["step_number"].ToString());
                        //            Session["isNotCompleteStep"] = 1;
                        //            //return RedirectToAction("Index", "SetupProcess");
                        //            return RedirectToAction("UserLogin", "Login");
                        //        }
                        //        else
                        //        {
                        //            LoanSetupStep loanStep = new LoanSetupStep();
                        //            DataSet dsLoanStepNo = new DataSet();
                        //            dsLoanStepNo = step.checkUserLoginWhileLoanSetup(userData);
                        //            if (dsLoanStepNo.Tables[0].Rows.Count > 0)
                        //            {
                        //                loanStep.CompanyId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["company_id"].ToString());
                        //                loanStep.BranchId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["branch_id"].ToString());
                        //                loanStep.stepId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["step_number"].ToString());
                        //                loanStep.nonRegisteredBranchId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["non_registered_branch_id"].ToString());
                        //                if (dsLoanStepNo.Tables[0].Rows[0]["loan_id"].ToString() != "")
                        //                {
                        //                    loanStep.loanId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["loan_id"].ToString());
                        //                }
                        //                else
                        //                {
                        //                    loanStep.loanId = 0;
                        //                }
                        //                Session["isNotCompleteStep"] = 1;
                        //                Session["loanStep"] = loanStep;
                        //                if (userData.RoleId == 1)
                        //                {
                        //                    //return RedirectToAction("Step" + (loanStep.stepId + 5), "SetupProcess");
                        //                    return RedirectToAction("UserLogin", "Login");
                        //                }
                        //            }
                        //        }
                        //    }
                        //    else
                        //    {
                        //        //if step table has record pass(company id and branch id)
                        //        DataSet dsStepNo = new DataSet();
                        //        dsStepNo = step.checkUserLoginWhileCompanySetup(userData);
                        //        if (dsStepNo.Tables[0].Rows.Count > 0)
                        //        {
                        //            Session["isNotCompleteStep"] = 1;
                        //            Session["companyStep"] = int.Parse(dsStepNo.Tables[0].Rows[0]["step_number"].ToString());
                        //            return RedirectToAction("UserLogin", "Login");
                        //        }
                        //        else
                        //        {
                        //            //No Step recor in relavent Company and branch
                        //            LoanSetupStep loanStep = new LoanSetupStep();
                        //            DataSet dsLoanStepNo = new DataSet();
                        //            dsLoanStepNo = step.checkUserLoginWhileLoanSetup(userData);
                        //            if (dsLoanStepNo.Tables[0].Rows.Count > 0)
                        //            {
                        //                loanStep.CompanyId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["company_id"].ToString());
                        //                loanStep.BranchId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["branch_id"].ToString());
                        //                loanStep.stepId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["step_number"].ToString());
                        //                loanStep.nonRegisteredBranchId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["non_registered_branch_id"].ToString());
                        //                if (dsLoanStepNo.Tables[0].Rows[0]["loan_id"].ToString() != "")
                        //                {
                        //                    loanStep.loanId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["loan_id"].ToString());
                        //                }
                        //                else
                        //                {
                        //                    loanStep.loanId = 0;
                        //                }

                        //                Session["isNotCompleteStep"] = 1;
                        //                Session["loanStep"] = loanStep;

                        //                //return RedirectToAction("Step" + (loanStep.stepId + 5), "SetupProcess");
                        //                return RedirectToAction("UserLogin", "Login");
                        //            }
                        //            //if SA stepstatus 2 and no records in loan setup and companysetup
                        //            else
                        //            {
                        //                return RedirectToAction("UserDetails", "Usermanagement");
                        //            }
                        //        }


                        //    }
                        //}
                        else
                        {
                            //insert log
                            Log log = new Log(userData.UserId, userData.Company_Id, userData.BranchId, 0, "User Login", "User : "******" was unable to login", DateTime.Now);

                            int islog = (new LogAccess()).InsertLog(log);
                            return(RedirectToAction("UserLogin", "Login", new { lbl = "Company setup process is on going please contact admin." }));
                        }



                        //    //check Company setup process
                        //    //Check SuperAdmin
                        //    //company ID null or 0 then redirect to step process 1
                        //    if (userData.Company_Id == 0)
                        //    {
                        //        Session["companyStep"] = 1;
                        //        return RedirectToAction("Index", "SetupProcess");
                        //    }
                        //    else if (userData.Company_Id > 0)
                        //    {
                        //        //check branch count more than one and
                        //        if (userData.RoleId == 1)
                        //        {
                        //            //check branch count in view and step table row count
                        //            //IF more than branch count and has step record ask question

                        //            DataSet dsStepNo = new DataSet();
                        //            dsStepNo = step.checkSuperAdminLoginWhileCompanySetup(userData);
                        //            if (dsStepNo.Tables[0].Rows.Count > 0)
                        //            {
                        //                int bcount = 0;
                        //                if (dsStepNo.Tables[0].Rows[0]["branchCount"].ToString() != "")
                        //                {
                        //                    bcount = int.Parse(dsStepNo.Tables[0].Rows[0]["branchCount"].ToString());
                        //                }
                        //                int scount = 0;
                        //                if (dsStepNo.Tables[0].Rows[0]["stepCount"].ToString() != "")
                        //                {
                        //                    scount = int.Parse(dsStepNo.Tables[0].Rows[0]["stepCount"].ToString());
                        //                }
                        //                if (bcount <= scount)
                        //                {
                        //                    Session["companyStep"] = int.Parse(dsStepNo.Tables[0].Rows[0]["step_number"].ToString());
                        //                    return RedirectToAction("Index", "SetupProcess");

                        //                }
                        //                else
                        //                {
                        //                    //message: Not complete Step, Do you want to complete it.
                        //                    Session["isNotCompleteStep"] = 1;
                        //                    Session["companyStep"] = int.Parse(dsStepNo.Tables[0].Rows[0]["step_number"].ToString());
                        //                    return RedirectToAction("UserLogin", "Login");
                        //                }
                        //            }
                        //            else
                        //            {
                        //                LoanSetupStep loanStep = new LoanSetupStep();
                        //                DataSet dsLoanStepNo = new DataSet();
                        //                dsLoanStepNo = step.checkUserLoginWhileLoanSetup(userData);
                        //                if (dsLoanStepNo.Tables[0].Rows.Count > 0)
                        //                {
                        //                    loanStep.CompanyId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["company_id"].ToString());
                        //                    loanStep.BranchId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["branch_id"].ToString());
                        //                    loanStep.stepId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["step_number"].ToString());
                        //                    loanStep.nonRegisteredBranchId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["non_registered_branch_id"].ToString());
                        //                    if (dsLoanStepNo.Tables[0].Rows[0]["loan_id"].ToString() != "")
                        //                    {
                        //                        loanStep.loanId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["loan_id"].ToString());
                        //                    }
                        //                    else
                        //                    {
                        //                        loanStep.loanId = 0;
                        //                    }
                        //                    Session["loanStep"] = loanStep;
                        //                    if (userData.RoleId == 1)
                        //                    {
                        //                        return RedirectToAction("Step" + (loanStep.stepId + 5), "SetupProcess");
                        //                    }
                        //                }
                        //                else
                        //                {
                        //                    //Redirect to Super Admin dashboard
                        //                    return RedirectToAction("UserDetails", "UserManagement");
                        //                }

                        //            }

                        //        }
                        //        else
                        //        {
                        //            //if step table has record pass(company id and branch id)
                        //            DataSet dsStepNo = new DataSet();
                        //            dsStepNo = step.checkUserLoginWhileCompanySetup(userData);
                        //            if (dsStepNo.Tables[0].Rows.Count > 0)
                        //            {
                        //                Session["companyStep"] = int.Parse(dsStepNo.Tables[0].Rows[0]["step_number"].ToString());
                        //                if (userData.RoleId == 2)
                        //                {
                        //                    return RedirectToAction("Index", "SetupProcess");
                        //                }
                        //                else
                        //                {
                        //                    return RedirectToAction("UserLogin", "Login", new { lbl = "Company setup process is on going please contact admin." });
                        //                }
                        //            }
                        //            else
                        //            {
                        //                //No Step recor in relavent Company and branch
                        //                LoanSetupStep loanStep = new LoanSetupStep();
                        //                DataSet dsLoanStepNo = new DataSet();
                        //                dsLoanStepNo = step.checkUserLoginWhileLoanSetup(userData);
                        //                if (dsLoanStepNo.Tables[0].Rows.Count > 0)
                        //                {
                        //                    loanStep.CompanyId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["company_id"].ToString());
                        //                    loanStep.BranchId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["branch_id"].ToString());
                        //                    loanStep.stepId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["step_number"].ToString());
                        //                    loanStep.nonRegisteredBranchId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["non_registered_branch_id"].ToString());
                        //                    if (dsLoanStepNo.Tables[0].Rows[0]["loan_id"].ToString() != "")
                        //                    {
                        //                        loanStep.loanId = int.Parse(dsLoanStepNo.Tables[0].Rows[0]["loan_id"].ToString());
                        //                    }
                        //                    else
                        //                    {
                        //                        loanStep.loanId = 0;
                        //                    }

                        //                    Session["loanStep"] = loanStep;
                        //                    if (userData.RoleId == 2)
                        //                    {
                        //                        //return RedirectToAction("Index", "SetupProcess");
                        //                        return RedirectToAction("Step" + (loanStep.stepId+5), "SetupProcess");
                        //                    }
                        //                }
                        //                else
                        //                {
                        //                    if (userData.RoleId == 2)
                        //                    {
                        //                        //Redirect to Branch Admin dashboard
                        //                        return RedirectToAction("UserDetails", "UserManagement");
                        //                    }
                        //                    else
                        //                    {
                        //                        //Redirect to User dashboard
                        //                        return RedirectToAction("UserDetails", "UserManagement");
                        //                    }
                        //                }


                        //            }

                        //        }
                        //    }

                        //}
                        //else
                        //{
                        //    //User Name Correct but user enter password does not match with database password value
                        //    return RedirectToAction("UserLogin", "Login", new { lbl = "Incorrect Username or Password, please confirm and submit." });
                        //}
                        //insert log entry
                    }
                    else
                    {
                        //User Name Correct but user enter password does not match with database password value
                        Log log = new Log(userData.UserId, userData.Company_Id, userData.BranchId, 0, "User Login", "User : "******" was unable to login, Entered password did not match ", DateTime.Now);

                        int islog = (new LogAccess()).InsertLog(log);
                        return(RedirectToAction("UserLogin", "Login", new { lbl = "Incorrect Username & Password combination. Please confirm entry and resubmit." }));
                    }
                }
                else
                {
                    //Incorrect UserName
                    Log log = new Log(userData.UserId, userData.Company_Id, userData.BranchId, 0, "User Login", "User : "******" was unable to login, Entered username did not exist ", DateTime.Now);

                    int islog = (new LogAccess()).InsertLog(log);
                    return(RedirectToAction("UserLogin", "Login", new { lbl = "Incorrect Username & Password combination. Please confirm entry and resubmit." }));
                }
            }
            catch
            {
                return(RedirectToAction("UserLogin", "Login", new { lbl = "An error has occurred.Please try again later" }));
            }
            return(RedirectToAction("UserLogin", "Login"));
        }