public bool Save() { bool result = false; Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { PartialHouseDAO PartialHouseDAO = new PartialHouseDAO(); if (PartialHouseDAO.IsHouseExist(this)) { result = PartialHouseDAO.Update(this, db, transaction); } else { result = PartialHouseDAO.Insert(this, db, transaction); } if (result) { transaction.Commit(); } else { transaction.Rollback(); } } catch (System.Exception ex) { transaction.Rollback(); result = false; throw ex; } finally { connection.Close(); } return(result); }
public bool Save() { bool result = false; Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { PartialHouseDAO PartialHouseDAO = new PartialHouseDAO(); if (PartialHouseDAO.IsHouseExist(this)) { result = PartialHouseDAO.Update(this, db, transaction); } else { result = PartialHouseDAO.Insert(this, db, transaction); } if (result) { transaction.Commit(); } else { transaction.Rollback(); } } catch (System.Exception ex) { transaction.Rollback(); result = false; throw ex; } finally { connection.Close(); } return result; }