public Seller findOne(int id) { //log.InfoFormat("Entering findOne with value {0}", id); SQLiteConnection con = DBUtils.getConnection(); using (var comm = new SQLiteCommand("SELECT * FROM Sellers WHERE id=@id", con)) { comm.Parameters.AddWithValue("@id", id); using (var dataR = comm.ExecuteReader()) { if (dataR.Read()) { int idV = dataR.GetInt32(0); String user = dataR.GetString(2); String pass = dataR.GetString(3); Seller seller = new Seller(idV, user, pass); //log.InfoFormat("Exiting findOne with value {0}", task); return(seller); } } } //log.InfoFormat("Exiting findOne with value {0}", null); return(null); }
public Ticket findOne(int id) { //log.InfoFormat("Entering findOne with value {0}", id); SQLiteConnection con = DBUtils.getConnection(); using (var comm = new SQLiteCommand("SELECT * FROM Tickets WHERE id=@id", con)) { comm.Parameters.AddWithValue("@id", id); using (var dataR = comm.ExecuteReader()) { if (dataR.Read()) { int idV = dataR.GetInt32(0); int gameId = dataR.GetInt32(1); String client = dataR.GetString(2); int nrOfSeats = dataR.GetInt32(3); Ticket ticket = new Ticket(idV, gameId, client, nrOfSeats); //log.InfoFormat("Exiting findOne with value {0}", task); return(ticket); } } } //log.InfoFormat("Exiting findOne with value {0}", null); return(null); }
public IEnumerable <Game> findAll() { SQLiteConnection con = DBUtils.getConnection(); IList <Game> games = new List <Game>(); using (var comm = new SQLiteCommand("SELECT * FROM Games", con)) { using (SQLiteDataReader dataR = comm.ExecuteReader()) { while (dataR.Read()) { int idV = dataR.GetInt32(0); String homeTeam = dataR.GetString(1); String awayTeam = dataR.GetString(2); TypeOfGame type = (TypeOfGame)Enum.Parse(typeof(TypeOfGame), dataR.GetString(3)); int nrOfSeats = dataR.GetInt32(4); int emptySeats = dataR.GetInt32(5); float price = dataR.GetFloat(6); Game game = new Game(idV, homeTeam, awayTeam, type, nrOfSeats, emptySeats, price); games.Add(game); } } } return(games); }