public TrabajadorApi LoginApi(String UserName, String Password) { TrabajadorApi resu = new TrabajadorApi(); using (SqlConnection connection = new SqlConnection(cadena)) { try { connection.Open(); SqlCommand command = new SqlCommand("VR_Login_Participante", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@UserName", SqlDbType.VarChar).Value = UserName; command.Parameters.Add("@Password", SqlDbType.VarChar).Value = Password; SqlDataReader reader = command.ExecuteReader(CommandBehavior.SingleResult); if (reader.HasRows) { if (reader.Read()) { resu = new TrabajadorApi(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3)); } } reader.Close(); connection.Close(); } catch (Exception e) { resu.tr_Apellidos = e.Message; connection.Close(); } } return(resu); }
public HttpResponseMessage Login(String UserName, String Password) { B_Trabajador bTR = new B_Trabajador(); TrabajadorApi tr = bTR.LoginApi(UserName, Password); return(Request.CreateResponse(HttpStatusCode.OK, tr)); }
public TrabajadorApi LoginApi(String UserName, String Password) { P_Trabajador dao = new P_Trabajador(); TrabajadorApi ar = dao.LoginApi(UserName, Password); return(ar); }