private SqlCommand buildCmd(ShowDTO show) { SqlCommand cmd = new SqlCommand(); cmd.Parameters.AddWithValue("ID", show.getID()); cmd.Parameters.AddWithValue("NrTickets", show.getNumberOfTickets()); cmd.Parameters.AddWithValue("Genre", show.getGenre()); cmd.Parameters.AddWithValue("Date", show.getDate().ToString()); cmd.Parameters.AddWithValue("Distribution", show.getDistribution()); cmd.Parameters.AddWithValue("Title", show.getTitle()); return(cmd); }
public ShowModel map(ShowDTO showdto) { ShowModel model = new ShowModel(); model.setID(showdto.getID()); model.setGenre(showdto.getGenre()); model.setDistribution(showdto.getDistribution()); model.setDate(showdto.getDate()); model.setNumberOfTickets(showdto.getNumberOfTickets()); model.setTitle(showdto.getTitle()); return(model); }
public bool updateShow(ShowDTO show) { SqlCommand cmd = buildCmd(show); cmd = connectToDB(cmd); cmd.CommandText = "update Shows set Title = @Title, Genre = @Genre, Distr = @Distribution, Date = @Date, NumberOfTickets = @NrTickets where ID=@ID"; cmd.ExecuteNonQuery(); cmd.Connection.Close(); ShowDTO oldShow = showsList.Find(shw => shw.getID() == show.getID()); showsList.Remove(oldShow); showsList.Add(show); return(true); }