public void save(Artist entity) { var con = DBUtils.getConnection(); using (var comm = con.CreateCommand()) { comm.CommandText = "insert into Artist(nume) values (@nume)"; var paramDesc = comm.CreateParameter(); paramDesc.ParameterName = "@nume"; paramDesc.Value = entity.Nume; comm.Parameters.Add(paramDesc); var result = comm.ExecuteNonQuery(); if (result == 0) { throw new RepositoryException("No artist added !"); } } }
public void update(int id, Personal entity) { var con = DBUtils.getConnection(); using (var comm = con.CreateCommand()) { comm.CommandText = "UPDATE Personal SET Nume = @nume,Descriere=@desc WHERE Id = @id; "; var paramId = comm.CreateParameter(); paramId.ParameterName = "@id"; paramId.Value = id; comm.Parameters.Add(paramId); var paramNume = comm.CreateParameter(); paramNume.ParameterName = "@nume"; paramNume.Value = entity.Nume; comm.Parameters.Add(paramNume); var paramUser = comm.CreateParameter(); paramUser.ParameterName = "@user"; paramUser.Value = entity.Username; comm.Parameters.Add(paramUser); var paramPass = comm.CreateParameter(); paramPass.ParameterName = "@parola"; paramPass.Value = entity.Parola; comm.Parameters.Add(paramPass); var result = comm.ExecuteNonQuery(); if (result == 0) { throw new RepositoryException("No Personal updated !"); } } }
public void save(Spectacol entity) { var con = DBUtils.getConnection(); using (var comm = con.CreateCommand()) { comm.CommandText = "insert into Spectacol(locatie,disponibile,vandute,idartist) values (@loc,@disp,@vand,@idart)"; var paramLoc = comm.CreateParameter(); paramLoc.ParameterName = "@loc"; paramLoc.Value = entity.Locatie; comm.Parameters.Add(paramLoc); var paramDisp = comm.CreateParameter(); paramDisp.ParameterName = "@disp"; paramDisp.Value = entity.Disponibile; comm.Parameters.Add(paramDisp); var paramVand = comm.CreateParameter(); paramVand.ParameterName = "@vand"; paramVand.Value = entity.Vandute; comm.Parameters.Add(paramVand); var paramIdArt = comm.CreateParameter(); paramIdArt.ParameterName = "@idart"; paramIdArt.Value = entity.Artist; comm.Parameters.Add(paramIdArt); var result = comm.ExecuteNonQuery(); if (result == 0) { throw new RepositoryException("No spectacol added !"); } } }
public void update(int id, Cumparator entity) { var con = DBUtils.getConnection(); using (var comm = con.CreateCommand()) { comm.CommandText = "UPDATE Cumparator SET Nume = @nume,bilete=@Bilete,idspectacol=@idspectacol WHERE Id = @id; "; var paramId = comm.CreateParameter(); paramId.ParameterName = "@id"; paramId.Value = id; comm.Parameters.Add(paramId); var paramNume = comm.CreateParameter(); paramNume.ParameterName = "@nume"; paramNume.Value = entity.Nume; comm.Parameters.Add(paramNume); var paramBilet = comm.CreateParameter(); paramBilet.ParameterName = "@bilete"; paramBilet.Value = entity.Bilete; comm.Parameters.Add(paramBilet); var paramSpec = comm.CreateParameter(); paramSpec.ParameterName = "@idspectacol"; paramSpec.Value = entity.IdSpectacol; comm.Parameters.Add(paramSpec); var result = comm.ExecuteNonQuery(); if (result == 0) { throw new RepositoryException("No cumparator updated !"); } } }
public IEnumerable <Artist> findAll() { IDbConnection con = DBUtils.getConnection(); IList <Artist> artistsR = new List <Artist>(); using (var comm = con.CreateCommand()) { comm.CommandText = "select Id,Nume from Artist"; using (var dataR = comm.ExecuteReader()) { while (dataR.Read()) { int idO = dataR.GetInt32(0); String nume = dataR.GetString(1); Artist artist = new Artist(idO, nume); artistsR.Add(artist); } } } return(artistsR); }