Beispiel #1
0
        /// <summary>
        /// Get with transaction
        /// </summary>
        public PM_ALT_EVENT_TYPE_GRP Get(object entityId, DbTransaction transaction)
        {
            ArgumentValidator.CheckForNullArgument(entityId, "entityId");
            ArgumentValidator.CheckForNullArgument(transaction, "transaction");

            PM_ALT_EVENT_TYPE_GRP PM_ALT_EVENT_TYPE_GRPEntity = null;

            try
            {
                Database  db        = GetDatabaseInstance();
                DbCommand dbCommand = db.GetSqlStringCommand(PM_ALT_EVENT_TYPE_GRPDAO.SqlGet);

                db.AddInParameter(dbCommand, "@NotiEventGroupID", DbType.Guid, entityId);
                using (IDataReader dataReader = db.ExecuteReader(dbCommand, transaction))
                {
                    if (dataReader.Read())
                    {
                        PM_ALT_EVENT_TYPE_GRPEntity = ReadEntity(dataReader);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy);
            }

            return(PM_ALT_EVENT_TYPE_GRPEntity);
        }
Beispiel #2
0
        private static PM_ALT_EVENT_TYPE_GRP ReadEntity(IDataReader dataReader)
        {
            PM_ALT_EVENT_TYPE_GRP PM_ALT_EVENT_TYPE_GRPEntity = new PM_ALT_EVENT_TYPE_GRP();
            object value;


            value = dataReader["NotiEventGroupID"];
            if (value != DBNull.Value)
            {
                PM_ALT_EVENT_TYPE_GRPEntity.NotiEventGroupID = (Guid?)value;
            }

            value = dataReader["EventTypeID"];
            if (value != DBNull.Value)
            {
                PM_ALT_EVENT_TYPE_GRPEntity.EventTypeID = (Guid?)value;
            }

            value = dataReader["NotiGroupID"];
            if (value != DBNull.Value)
            {
                PM_ALT_EVENT_TYPE_GRPEntity.NotiGroupID = (Guid?)value;
            }

            return(PM_ALT_EVENT_TYPE_GRPEntity);
        }
Beispiel #3
0
        private void UpdateAll(PM_ALT_EVENT_TYPE_GRP entity, DbTransaction transaction)
        {
            ArgumentValidator.CheckForNullArgument(entity, "entity");
            ArgumentValidator.CheckForNullArgument(transaction, "transaction");

            PersistentPM_ALT_EVENT_TYPE_GRP PM_ALT_EVENT_TYPE_GRPEntity = entity as PersistentPM_ALT_EVENT_TYPE_GRP;

            try
            {
                Database  db        = GetDatabaseInstance();
                DbCommand dbCommand = db.GetSqlStringCommand(PM_ALT_EVENT_TYPE_GRPDAO.SqlUpdate);

                db.AddInParameter(dbCommand, "@NotiEventGroupID", DbType.Guid, PM_ALT_EVENT_TYPE_GRPEntity.NotiEventGroupID);
                db.AddInParameter(dbCommand, "@EventTypeID", DbType.Guid, PM_ALT_EVENT_TYPE_GRPEntity.EventTypeID);
                db.AddInParameter(dbCommand, "@NotiGroupID", DbType.Guid, PM_ALT_EVENT_TYPE_GRPEntity.NotiGroupID);
                int result = db.ExecuteNonQuery(dbCommand, transaction);

                if (result == 0)
                {
                    throw new EntityNotFoundException();
                }
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy);
            }
        }
Beispiel #4
0
 public void Update(PM_ALT_EVENT_TYPE_GRP entity, bool updateAll, DbTransaction transaction)
 {
     if (!updateAll)
     {
         UpdateSome(entity, transaction);
     }
     else
     {
         UpdateAll(entity, transaction);
     }
 }
Beispiel #5
0
 public void Update(PM_ALT_EVENT_TYPE_GRP entity, bool updateAll)
 {
     if (!updateAll)
     {
         UpdateSome(entity);
     }
     else
     {
         UpdateAll(entity);
     }
 }
Beispiel #6
0
        public void UpdateSome(PM_ALT_EVENT_TYPE_GRP entity)
        {
            try
            {
                ArgumentValidator.CheckForNullArgument(entity, "PM_ALT_EVENT_TYPE_GRP Entity");

                _PM_ALT_EVENT_TYPE_GRPDAO.Update(entity, false);
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy);
            }
        }
Beispiel #7
0
        public void Delete(PM_ALT_EVENT_TYPE_GRP entity)
        {
            try
            {
                ArgumentValidator.CheckForNullArgument(entity, "PM_ALT_EVENT_TYPE_GRP Entity");

                _PM_ALT_EVENT_TYPE_GRPDAO.Delete(entity.NotiEventGroupID);
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy);
            }
        }
Beispiel #8
0
        public PM_ALT_EVENT_TYPE_GRP GetEntity(Guid entityGuid)
        {
            PM_ALT_EVENT_TYPE_GRP entity = null;

            try
            {
                ArgumentValidator.CheckForNullArgument(entityGuid, "PM_ALT_EVENT_TYPE_GRP Guid");

                entity = _PM_ALT_EVENT_TYPE_GRPDAO.Get(entityGuid);
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy);
            }

            return(entity);
        }
Beispiel #9
0
        public PM_ALT_EVENT_TYPE_GRP Insert(PM_ALT_EVENT_TYPE_GRP entity)
        {
            PM_ALT_EVENT_TYPE_GRP newEntity = null;

            try
            {
                ArgumentValidator.CheckForNullArgument(entity, "PM_ALT_EVENT_TYPE_GRP Entity");

                newEntity = _PM_ALT_EVENT_TYPE_GRPDAO.Insert(entity);
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy);
            }

            return(newEntity);
        }
Beispiel #10
0
        /// <summary>
        /// Insert
        /// </summary>
        public PM_ALT_EVENT_TYPE_GRP Insert(PM_ALT_EVENT_TYPE_GRP entity)
        {
            ArgumentValidator.CheckForNullArgument(entity, "entity");
            PersistentPM_ALT_EVENT_TYPE_GRP PM_ALT_EVENT_TYPE_GRPEntity = entity as PersistentPM_ALT_EVENT_TYPE_GRP;

            try
            {
                Database  db        = GetDatabaseInstance();
                DbCommand dbCommand = db.GetSqlStringCommand(PM_ALT_EVENT_TYPE_GRPDAO.SqlInsert);

                db.AddInParameter(dbCommand, "@NotiEventGroupID", DbType.Guid, PM_ALT_EVENT_TYPE_GRPEntity.NotiEventGroupID);
                db.AddInParameter(dbCommand, "@EventTypeID", DbType.Guid, PM_ALT_EVENT_TYPE_GRPEntity.EventTypeID);
                db.AddInParameter(dbCommand, "@NotiGroupID", DbType.Guid, PM_ALT_EVENT_TYPE_GRPEntity.NotiGroupID);

                int result = db.ExecuteNonQuery(dbCommand);
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy);
            }

            return(PM_ALT_EVENT_TYPE_GRPEntity as PM_ALT_EVENT_TYPE_GRP);
        }
Beispiel #11
0
        private void UpdateSome(PM_ALT_EVENT_TYPE_GRP entity, DbTransaction transaction)
        {
            ArgumentValidator.CheckForNullArgument(entity, "entity");
            ArgumentValidator.CheckForNullArgument(transaction, "transaction");

            PersistentPM_ALT_EVENT_TYPE_GRP PM_ALT_EVENT_TYPE_GRPEntity = entity as PersistentPM_ALT_EVENT_TYPE_GRP;

            StringBuilder sqlUpdateSome = new StringBuilder();

            sqlUpdateSome.Append("UPDATE dbo.PM_ALT_EVENT_TYPE_GRP SET ");

            PropertyInfo[] propertyInfos        = PM_ALT_EVENT_TYPE_GRPEntity.GetType().GetProperties();
            Hashtable      propertyValues       = new System.Collections.Hashtable();
            int            columnCountForUpdate = 0;

            foreach (PropertyInfo propertyInfo in propertyInfos)
            {
                if (EntityMapping.ContainsProperty(propertyInfo.Name))
                {
                    object     propertyValue = propertyInfo.GetValue(PM_ALT_EVENT_TYPE_GRPEntity, null);
                    ORProperty property      = EntityMapping[propertyInfo.Name];
                    if (!property.IsPrimaryKey)
                    {
                        if (!PM_ALT_EVENT_TYPE_GRPEntity.IsDefaultValue(propertyInfo.Name))
                        {
                            propertyValues[propertyInfo.Name] = propertyValue;

                            sqlUpdateSome.Append(" " + property.ColumnName + " = @" + property.ColumnName + ",");
                            columnCountForUpdate++;
                        }
                    }
                    else
                    {
                        propertyValues[propertyInfo.Name] = propertyValue;
                    }
                }
            }
            if (columnCountForUpdate == 0)
            {
                return;
            }

            sqlUpdateSome.Remove(sqlUpdateSome.Length - 1, 1);
            sqlUpdateSome.Append(" WHERE 1 = 1 ");
            sqlUpdateSome.Append(" AND NotiEventGroupID = @NotiEventGroupID ");

            try
            {
                Database  db        = GetDatabaseInstance();
                DbCommand dbCommand = db.GetSqlStringCommand(sqlUpdateSome.ToString());

                foreach (DictionaryEntry de in propertyValues)
                {
                    ORProperty property = EntityMapping[de.Key.ToString()];
                    db.AddInParameter(dbCommand, "@" + property.ColumnName, property.DatabaseType, de.Value);
                }

                int result = db.ExecuteNonQuery(dbCommand, transaction);

                if (result == 0)
                {
                    throw new EntityNotFoundException();
                }
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy);
            }
        }
Beispiel #12
0
        /// <summary>
        /// Update with transaction
        /// </summary>

        public void Update(PM_ALT_EVENT_TYPE_GRP entity, DbTransaction transaction)
        {
            Update(entity, true, transaction);
        }
Beispiel #13
0
        /// <summary>
        /// Update
        /// </summary>

        public void Update(PM_ALT_EVENT_TYPE_GRP entity)
        {
            Update(entity, true);
        }