I need to get the ID of a user already logged in to the application to create another product. How do I do this?
So,soon,andwiththeemailandpasswordlogged,IwanttofindtheIDloggedinwhenIregisterthecar,itpullsthatIDandregister.IhavealreadytriedusingThread.CurrentPrincipal.Identity.IsAuthenticated,Environment.UserNameandtheWindowsIdentity.GetCurrent()buttheseonlytakethenameofthepersonloggedinwindows,nottheapplication.
Login
Empresaempresa=newEmpresa();empresa.Email=txtEmail.Text;empresa.Senha=txtSenha.Text;if(EmpresaDAO.BuscarEmpresaPorEmailESenha(empresa)!=null){empresa=EmpresaDAO.BuscarEmpresaPorEmailESenha(empresa);this.Close();MenuEmpresamenuEmpresa=newMenuEmpresa();menuEmpresa.ShowDialog();}
CarRegistration
try{if(WindowsIdentity.GetCurrent().IsAuthenticated){empresa.Email=WindowsIdentity.GetCurrent().Name;}carro.Empresa=EmpresaDAO.BuscarEmpresaPorEmail(empresa);carro.Nome=txtNome.Text;carro.Cambio=txtCambio.Text;carro.Cor=txtCor.Text;carro.Marca=txtMarca.Text;carro.Quilometragem=txtQuilometragem.Text;carro.Placa=txtPlaca.Text;carro.Portas=int.Parse(txtPorta.Text);carro.Ano=int.Parse(txtPorta.Text);carro.Preco=txtPreco.Text;CarroDAO.Incluir(carro);MessageBox.Show("O cadastro do carro: " + carro.Nome + " foi concluido com sucesso", "Cadastrado");
}
I tried to do as much as possible to asp.NET, because I did not understand how I will do this in C #.
ASP.NET
Usuario usu = new Usuario();
ItemVenda itemv = new ItemVenda();
if (Request.IsAuthenticated)
{
usu.Login = HttpContext.User.Identity.Name;
}
venda.Usuario = UsuarioDAO.BuscarUsuarioPorLogin(usu);