Exemplo n.º 1
0
        public ActionResult Logins(LoanViewModel lvm)
        {
            try
            {
                users.Email   = lvm.AccountsModel.Email;
                users.pasword = lvm.AccountsModel.pasword;
                var EncrypPassword = new CryptographyManager().ComputeHash(users.pasword, HashName.SHA256);
                users.pasword = EncrypPassword;

                var valid = DataReaders.loggedIn(users.Email, EncrypPassword);

                WebLog.Log("Email" + users.Email + EncrypPassword);
                WebLog.Log("Valid1" + valid);
                if (valid == true)
                {
                    WebLog.Log("Valid2" + valid);
                    if (users.Email != null)
                    {
                        WebLog.Log("users.Email 2" + users.Email);
                        Session["id"]   = users.Email;
                        Session["User"] = Session["id"];
                        var LoggedInuser = new LogginHelper();
                        user = LoggedInuser.LoggedInUser();
                        // return View("index");

                        // string LoginPage = ConfigurationManager.AppSettings["DefaultLogin"];
                        // return RedirectToAction("Index", "Dashboard");
                        // This is For Banks
                        var bankFk = DataReaders.getBankByUser(users.Email);

                        /* if(bankFk.BankFk != null || bankFk.BankFk != 0)
                         * {
                         *   return RedirectToAction("DashboardSummary", "Dashboard");
                         * }
                         * else if(bankFk .BankFk== null || bankFk.BankFk == 0)
                         * return RedirectToAction("Dashboard", "Dashboard");
                         */
                        if (bankFk.BankFk == null || bankFk.BankFk == 0)
                        {
                            TempData["Flg"] = "0";
                            return(RedirectToAction("Dashboard", "Dashboard"));
                        }
                        else if (bankFk.BankFk != null || bankFk.BankFk != 0)
                        {
                            return(RedirectToAction("DashboardSummary", "Dashboard"));
                        }
                        // return Redirect(LoginPage);
                    }
                    else
                    {
                        TempData["message"] = "Invalid User Try Again";
                    }
                    // ViewBag.Message ="Try Again!";
                    return(View("Signin"));
                }
                else
                {
                    WebLog.Log("Valid3" + valid);
                    TempData["message"] = "User Does Not Exist";
                    ViewBag.Message     = "User Does Not Exist";
                    return(View("Signin"));
                }
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(null);
            }
        }