Пример #1
0
        public IActionResult Login(IFormCollection form)
        {
            var email   = form["email"];
            var senha   = form ["senha"];
            var cliente = clienteR.BuscarEmailESenha(email, senha);

            if (cliente != null)
            {
                if (cliente.Tipo.Equals("Admin"))
                {
                    HttpContext.Session.SetString(SESSION_ADM, email);
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    HttpContext.Session.SetString(SESSION_EMAIL, email);
                    HttpContext.Session.SetString(SESSION_CLIENTE, cliente.Nome);
                    return(RedirectToAction("Index", "Home"));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Пример #2
0
        public IActionResult Login(IFormCollection form)
        {
            var email   = form["email"];
            var senha   = form ["senha"];
            var cliente = ClienteRepositorio.BuscarEmailESenha(email, senha);

            if (cliente != null)
            {
                if (cliente.Tipo == "admin")
                {
                    return(RedirectToAction("Adm", "Admin"));
                }
                else
                {
                    HttpContext.Session.SetString(SESSION_EMAIL, email);
                    HttpContext.Session.SetString(SESSION_CLIENTE, cliente.Nome);
                    return(RedirectToAction("Index", "Home"));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }


            // if (cliente != null && cliente.Senha.Equals(senha) && cliente.Tipo.Equals("Comum"))
            // {
            //     HttpContext.Session.SetString(SESSION_EMAIL, usuario);
            //     HttpContext.Session.SetString(SESSION_CLIENTE, cliente.Nome);
            //     return RedirectToAction("Index", "Home");
            // }

            // if(cliente != null && cliente.Senha.Equals(senha) && cliente.Tipo.Equals("Admin"))
            // {
            // return RedirectToAction("Adm", "Admin");
            // }

            // else{
            //     return RedirectToAction("Index", "Home");
            // }

            // && cliente.Tipo.Equals("Comum")
            // if(form["email"].Equals("*****@*****.**") && form["senha"].Equals("admin")){
            //     return RedirectToAction("Adm", "Admin");
            // }
        }