public List <JoinedTransfer> GetTransfers() { List <JoinedTransfer> transferDetails = new List <JoinedTransfer>(); try { using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); SqlCommand cmd = new SqlCommand(sqlGetTransferDetailsJoined, conn); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { JoinedTransfer temp = JoinedTransferFromReader(reader); transferDetails.Add(temp); } } } catch (SqlException ex) { return(transferDetails); } return(transferDetails); }
public void GetTransferById(int inputTransferId) { List <JoinedTransfer> allTransfers = transferAPI.GetTransfers(); JoinedTransfer requested = new JoinedTransfer(); foreach (JoinedTransfer transfers in allTransfers) { if (transfers.TransferId == inputTransferId && (transfers.FromId == authService.userId || transfers.ToId == authService.userId)) { requested = transfers; } else { } } if (requested.TransferId == 0) { Console.WriteLine("Sorry, that's not a valid transfer ID."); } else { Console.WriteLine(requested); } }