public TicketDTO map(TicketModel ticketmodel) { TicketDTO dto = new TicketDTO(); dto.setID(ticketmodel.getID()); dto.setShowID(ticketmodel.getShowID()); dto.setRow(ticketmodel.getRow()); dto.setColumn(ticketmodel.getColumn()); return(dto); }
private void getAllTickets() { ticketsList = new List <TicketDTO>(); SqlCommand cmd = connectToDB(); cmd.CommandText = "select * from Tickets"; SqlDataReader dataReader = cmd.ExecuteReader(); while (dataReader.Read()) { TicketDTO ticket = new TicketDTO(); ticket.setID((Int32)dataReader["ID"]); ticket.setShowID((Int32)dataReader["ShowID"]); ticket.setRow((Int32)dataReader["Row"]); ticket.setColumn((Int32)dataReader["Col"]); ticketsList.Add(ticket); } cmd.Connection.Close(); }
public List <TicketDTO> getTicketsByShowID(int ID) { List <TicketDTO> ticketByShow = new List <TicketDTO>(); SqlCommand cmd = connectToDB(); cmd.Parameters.AddWithValue("ShowID", ID); cmd.CommandText = "select * from Tickets where ShowID = @ShowID"; SqlDataReader dataReader = cmd.ExecuteReader(); while (dataReader.Read()) { TicketDTO ticket = new TicketDTO(); ticket.setID((Int32)dataReader["ID"]); ticket.setShowID((Int32)dataReader["ShowID"]); ticket.setRow((Int32)dataReader["Row"]); ticket.setColumn((Int32)dataReader["Col"]); ticketByShow.Add(ticket); } cmd.Connection.Close(); return(ticketByShow); }