Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class LoginModel
- {
- public string Email { get; set; }
- public string Senha { get; set; }
- public bool ValidarLogin()
- {
- // Comando para fazer a consulta
- string consultaSql = $"Select VendedorId From Estudo.Vendedores Where Email='{Email}' and Senha='{Senha}'";
- DAL Acessar = new DAL();
- DataTable carregaTabela = new DataTable(consultaSql); // Comando para executar a consulta.
- if (carregaTabela.Rows.Count == 1)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- public class DAL
- {
- // Variaveis de conexão
- private static string NomeServidor = @"DESKTOP-DC0D3FTTHIAGO";
- private static string TipoAutenticacao = "SSPI";
- private static string NomeBanco = "SistemaDeVenda";
- private static string StringConexao = $"Data source={NomeServidor}; Integrated Security={TipoAutenticacao}; Initial Catalog={NomeBanco}" ;
- private static SqlConnection Conexao;
- //@"data source=DESKTOP-DC0D3FTTHIAGO; Integrated Security=SSPI;Initial Catalog=SistemaDeVenda"
- public DAL()
- {
- Conexao = new SqlConnection(StringConexao);
- Conexao.Open();
- }
- public DataTable RetDataTable(string sql)
- {
- DataTable data = new DataTable();
- SqlCommand Executar = new SqlCommand(sql, Conexao);
- SqlDataAdapter da = new SqlDataAdapter(Executar);
- da.Fill(data);
- return data;
- }
- public void ExecutarComandoSQL(string sql)
- {
- SqlCommand Executar = new SqlCommand(sql, Conexao );
- Executar.ExecuteNonQuery();
- }
- }
- [HttpPost]
- public IActionResult Login(LoginModel login)
- {
- bool loginOk = login.ValidarLogin();
- return View();
- }
Add Comment
Please, Sign In to add comment