public bool Save() { bool result = false; Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { SpotlightDAO spotlightDAO = new SpotlightDAO(); if (spotlightDAO.IsSpotlightExist(this)) { result = spotlightDAO.Update(this, db, transaction); } else { result = spotlightDAO.Insert(this, db, transaction); } transaction.Commit(); } 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 { SpotlightDAO spotlightDAO = new SpotlightDAO(); if (spotlightDAO.IsSpotlightExist(this)) { result = spotlightDAO.Update(this, db, transaction); } else { result = spotlightDAO.Insert(this, db, transaction); } transaction.Commit(); } catch (System.Exception ex) { transaction.Rollback(); result = false; throw ex; } finally { connection.Close(); } return result; }