private void LoadProfile() { string token = Session.Token; string email = Session.email; string password = Session.password; var getToken = VirtualFairIntegration.ApiLogin(email, password); if (getToken.statusCode == 200) { txtNombreCompleto.Text = getToken.userConnect.fullName; txtEmail.Text = getToken.userConnect.email; txtPais.Text = getToken.userConnect.country; txtCiudad.Text = getToken.userConnect.city; txtDireccion.Text = getToken.userConnect.address; } else { } }
private void btnIngresar_Click(object sender, EventArgs e) { var email = txtEmail.Text.Trim(); var password = txtPassword.Text; if (ComprobarFormatoEmail(email)) { if (email != "" && password != "") { Session.email = email; Session.password = password; var getToken = VirtualFairIntegration.ApiLogin(email, password); int statusCode = getToken.statusCode; if (statusCode == 403) { string text = getToken.message; string title = "Información"; MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (statusCode == 200) { Session.Token = getToken.sessionToken.token; Session.IdProfile = getToken.sessionToken.idUser; Session.NameUser = getToken.userConnect.fullName; Session.NameProfile = getToken.userConnect.profile.name; Session.id = getToken.userConnect.id; int idProfile = getToken.userConnect.idProfile; if (idProfile > 0) { if (idProfile == 1) { var homeAdmin = new HomeAdmin(); homeAdmin.Show(); this.Hide(); } else if (idProfile == 2) { var homeConsultor = new HomeConsultant(); homeConsultor.Show(); this.Hide(); } else if (idProfile == 3) { var homeProductor = new HomeProducer(); homeProductor.Show(); this.Hide(); } else if (idProfile == 4) { var homeTransportista = new HomeCarrier(); homeTransportista.Show(); this.Hide(); } else if (idProfile == 5) { //CLIENTE INTERNO //internal customer var homeClient = new HomeInternalCustomer(); homeClient.Show(); this.Hide(); } else if (idProfile == 6) { //CLIENTE EXTERNO //internal customer var homeClientExternal = new HomeExternalCustomer(); homeClientExternal.Show(); this.Hide(); } } else { string text = "Usuario no existe"; string title = "Información"; MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else if (email != "" && password == "") { string text = "Debe ingresar password"; string title = "Información"; MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (email == "" && password != "") { string text = "Debe ingresar email"; string title = "Información"; MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { string text = "Email tiene formato incorrecto"; string title = "Información"; MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Information); } }