コード例 #1
0
ファイル: Spotlight.cs プロジェクト: tjsas1/RHP
        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);
        }
コード例 #2
0
ファイル: Spotlight.cs プロジェクト: nirshandileep/RHP
        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;
        }