public void save(Donatie entity) { log.InfoFormat("Entering save with entity {0}", entity); var con = DBUtils.getConnection(); using (var comm = con.CreateCommand()) { comm.CommandText = "insert into donatii values (@id, @idD, @idC, @suma)"; var paramId = comm.CreateParameter(); paramId.ParameterName = "@id"; paramId.Value = entity.Id; Console.WriteLine("44444444444444444444444444444" + entity.Id); comm.Parameters.Add(paramId); var paramIdD = comm.CreateParameter(); paramIdD.ParameterName = "@idD"; paramIdD.Value = entity.IdD; comm.Parameters.Add(paramIdD); var paramIdC = comm.CreateParameter(); paramIdC.ParameterName = "@idC"; paramIdC.Value = entity.IdC; comm.Parameters.Add(paramIdC); var paramSuma = comm.CreateParameter(); paramSuma.ParameterName = "@suma"; paramSuma.Value = entity.Suma; comm.Parameters.Add(paramSuma); var result = comm.ExecuteNonQuery(); if (result == 0) { throw new RepositoryException("No task added !"); } } log.Info("Exiting save - Donatie"); }
public void save(Voluntar entity) { log.InfoFormat("Entering save with entity {0}", entity); var con = DBUtils.getConnection(); using (var comm = con.CreateCommand()) { comm.CommandText = "insert into voluntari values (@id, @nume, @email, @parola)"; var paramId = comm.CreateParameter(); paramId.ParameterName = "@id"; paramId.Value = entity.Id; comm.Parameters.Add(paramId); var paramNume = comm.CreateParameter(); paramNume.ParameterName = "@nume"; paramNume.Value = entity.Nume; comm.Parameters.Add(paramNume); var paramEmail = comm.CreateParameter(); paramEmail.ParameterName = "@email"; paramEmail.Value = entity.Email; comm.Parameters.Add(paramEmail); var paramParola = comm.CreateParameter(); paramParola.ParameterName = "@parola"; paramParola.Value = entity.Parola; comm.Parameters.Add(paramParola); var result = comm.ExecuteNonQuery(); if (result == 0) { throw new RepositoryException("No voluntar added !"); } } log.Info("Exiting save - Voluntar"); }
public void save(Donator entity) { log.InfoFormat("Entering save with entity {0}", entity); var con = DBUtils.getConnection(); using (var comm = con.CreateCommand()) { comm.CommandText = "insert into donatori values (@idD, @nume, @adresa, @nrTelefon)"; var paramId = comm.CreateParameter(); paramId.ParameterName = "@idD"; paramId.Value = entity.Id; comm.Parameters.Add(paramId); var paramNume = comm.CreateParameter(); paramNume.ParameterName = "@nume"; paramNume.Value = entity.Nume; comm.Parameters.Add(paramNume); var paramAdresa = comm.CreateParameter(); paramAdresa.ParameterName = "@adresa"; paramAdresa.Value = entity.Adresa; comm.Parameters.Add(paramAdresa); var paramNrTelefon = comm.CreateParameter(); paramNrTelefon.ParameterName = "@nrTelefon"; paramNrTelefon.Value = entity.NrTelefon; comm.Parameters.Add(paramNrTelefon); var result = comm.ExecuteNonQuery(); if (result == 0) { throw new RepositoryException("No donator added !"); } } log.Info("Exiting save - Donator"); }
public void update(Donator old, Donator entity) { log.InfoFormat("Entering save with entities {0},{1}", old, entity); var con = DBUtils.getConnection(); using (var comm = con.CreateCommand()) { comm.CommandText = "update donatori set nume=@nume, adresa=@adresa, nrTelefon=@nrTelefon where id=@id"; var paramId = comm.CreateParameter(); paramId.ParameterName = "@id"; paramId.Value = entity.Id; comm.Parameters.Add(paramId); var paramNume = comm.CreateParameter(); paramNume.ParameterName = "@nume"; paramNume.Value = entity.Nume; comm.Parameters.Add(paramNume); var paramAdresa = comm.CreateParameter(); paramAdresa.ParameterName = "@adresa"; paramAdresa.Value = entity.Adresa; comm.Parameters.Add(paramAdresa); var paramNrTelefon = comm.CreateParameter(); paramNrTelefon.ParameterName = "@nrTelefon"; paramNrTelefon.Value = entity.NrTelefon; comm.Parameters.Add(paramNrTelefon); var result = comm.ExecuteNonQuery(); if (result == 0) { throw new RepositoryException("No donator updated !"); } } log.Info("Exiting update - Donator"); }