Ejemplo n.º 1
0
        /// <summary>
        /// The GetModuleDefinitions method returns a list of all module type definitions.
        /// </summary>
        /// <param name="portalId">
        /// The portal ID.
        /// </param>
        /// <returns>
        /// A list of general module definitions.
        /// </returns>
        /// <remarks>
        /// Other relevant sources: GetModuleDefinitions Stored Procedure
        /// </remarks>
        public List<GeneralModuleDefinition> GetCurrentModuleDefinitionsList(int portalId)
        {
            var result = new List<GeneralModuleDefinition>();

            // Create Instance of Connection and Command Object
            using (var connection = Config.SqlConnectionString)
            using (
                var command = new SqlCommand("rb_GetCurrentModuleDefinitions", connection) {
                    // Mark the Command as a SPROC
                    CommandType = CommandType.StoredProcedure
                }) {
                var parameterPortalId = new SqlParameter(StringsPortalId, SqlDbType.Int, 4) { Value = portalId };
                command.Parameters.Add(parameterPortalId);

                // Open the database connection and execute the command
                connection.Open();

                using (var dr = command.ExecuteReader(CommandBehavior.CloseConnection)) {
                    while (dr.Read()) {
                        var genModDef = new GeneralModuleDefinition {
                            FriendlyName = dr.GetString(0),
                            DesktopSource = dr.GetString(1),
                            MobileSource = dr.GetString(2),
                            Admin = dr.GetBoolean(3),
                            GeneralModDefID = dr.GetGuid(4)
                        };

                        result.Add(genModDef);
                    }
                }
            }

            return result;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The GetSingleModuleDefinition method returns a SqlDataReader
        ///   containing details about a specific module definition
        ///   from the ModuleDefinitions table.
        /// </summary>
        /// <param name="generalModDefId">
        /// The general mod def ID.
        /// </param>
        /// <returns>
        /// A single module definition.
        /// </returns>
        /// <remarks>
        /// Other relevant sources: GetSingleModuleDefinition Stored Procedure
        /// </remarks>
        public GeneralModuleDefinition GetSingleModuleDefinition(Guid generalModDefId)
        {
            // Create Instance of Connection and Command Object
            using (var sqlCommand = new SqlCommand("rb_GetSingleModuleDefinition") {
                // Mark the Command as a SPROC
                CommandType = CommandType.StoredProcedure
            }) {
                var parameterGeneralModDefId = new SqlParameter(StringsGeneralModDefId, SqlDbType.UniqueIdentifier) {
                    Value = generalModDefId
                };
                sqlCommand.Parameters.Add(parameterGeneralModDefId);

                // Execute the command and get the data reader
                var dr = DBHelper.GetDataReader(sqlCommand);
                var moduleDefinition = new GeneralModuleDefinition();
                while (dr.Read()) {
                    moduleDefinition.FriendlyName = dr["FriendlyName"].ToString();
                    moduleDefinition.DesktopSource = dr["DesktopSrc"].ToString();
                    moduleDefinition.MobileSource = dr["MobileSrc"].ToString();
                    moduleDefinition.GeneralModDefID = new Guid(Convert.ToString(dr["GeneralModDefID"]));
                }

                dr.Close();

                return moduleDefinition;
            }
        }