Exemplo n.º 1
0
        /// <summary>
        /// This method creates an instance of a
        /// 'FetchAllMethodsStoredProcedure' object and
        /// creates the sql parameter[] array needed
        /// to execute the procedure 'Method_FetchAll'.
        /// </summary>
        /// <returns>An instance of a(n) 'FetchAllMethodsStoredProcedure' object.</returns>
        public static new FetchAllMethodsStoredProcedure CreateFetchAllMethodsStoredProcedure(Method method)
        {
            // Initial value
            FetchAllMethodsStoredProcedure fetchAllMethodsStoredProcedure = new FetchAllMethodsStoredProcedure();

            // If the method object exists
            if (method != null)
            {
                if ((method.FetchAllForTable) && (method.HasTableId))
                {
                    // change the procedureName
                    fetchAllMethodsStoredProcedure.ProcedureName = "Method_FetchAllForTable";

                    // create the @TableId parameter
                    fetchAllMethodsStoredProcedure.Parameters = SqlParameterHelper.CreateSqlParameters("@TableId", method.TableId);
                }
                // if method.LoadByProjectId is true
                else if (method.LoadByProjectId)
                {
                    // Change the procedure name
                    fetchAllMethodsStoredProcedure.ProcedureName = "Method_FetchAllByProjectId";

                    // Create the @ProjectId parameter
                    fetchAllMethodsStoredProcedure.Parameters = SqlParameterHelper.CreateSqlParameters("@ProjectId", method.ProjectId);
                }
            }

            // return value
            return(fetchAllMethodsStoredProcedure);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method fetches a  'List<Method>' object.
        /// This method uses the 'Methods_FetchAll' procedure.
        /// </summary>
        /// <returns>A 'List<Method>'</returns>
        /// </summary>
        public List <Method> FetchAllMethods(FetchAllMethodsStoredProcedure fetchAllMethodsProc, DataConnector databaseConnector)
        {
            // Initial Value
            List <Method> methodCollection = null;

            // Verify database connection is connected
            if ((databaseConnector != null) && (databaseConnector.Connected))
            {
                // First Get Dataset
                DataSet allMethodsDataSet = this.DataHelper.LoadDataSet(fetchAllMethodsProc, databaseConnector);

                // Verify DataSet Exists
                if (allMethodsDataSet != null)
                {
                    // Get DataTable From DataSet
                    DataTable table = this.DataHelper.ReturnFirstTable(allMethodsDataSet);

                    // if table exists
                    if (table != null)
                    {
                        // Load Collection
                        methodCollection = MethodReader.LoadCollection(table);
                    }
                }
            }

            // return value
            return(methodCollection);
        }
Exemplo n.º 3
0
        /// <summary>
        /// This method creates an instance of a
        /// 'FetchAllMethodsStoredProcedure' object and
        /// creates the sql parameter[] array needed
        /// to execute the procedure 'Method_FetchAll'.
        /// </summary>
        /// <returns>An instance of a(n) 'FetchAllMethodsStoredProcedure' object.</returns>
        public static FetchAllMethodsStoredProcedure CreateFetchAllMethodsStoredProcedure(Method method)
        {
            // Initial value
            FetchAllMethodsStoredProcedure fetchAllMethodsStoredProcedure = new FetchAllMethodsStoredProcedure();

            // return value
            return(fetchAllMethodsStoredProcedure);
        }
Exemplo n.º 4
0
        /// <summary>
        /// This method fetches all 'Method' objects.
        /// </summary>
        /// <param name='List<PolymorphicObject>'>The 'Method' to delete.
        /// <returns>A PolymorphicObject object with all  'Methods' objects.
        internal PolymorphicObject FetchAll(List <PolymorphicObject> parameters, DataConnector dataConnector)
        {
            // Initial Value
            PolymorphicObject returnObject = new PolymorphicObject();

            // locals
            List <Method> methodListCollection = null;

            // Create FetchAll StoredProcedure
            FetchAllMethodsStoredProcedure fetchAllProc = null;

            // If the data connection is connected
            if ((dataConnector != null) && (dataConnector.Connected == true))
            {
                // Get MethodParameter
                // Declare Parameter
                Method paramMethod = null;

                // verify the first parameters is a(n) 'Method'.
                if (parameters[0].ObjectValue as Method != null)
                {
                    // Get MethodParameter
                    paramMethod = (Method)parameters[0].ObjectValue;
                }

                // Now create FetchAllMethodsProc from MethodWriter
                fetchAllProc = MethodWriter.CreateFetchAllMethodsStoredProcedure(paramMethod);
            }

            // Verify fetchAllProc exists
            if (fetchAllProc != null)
            {
                // Execute FetchAll Stored Procedure
                methodListCollection = this.DataManager.MethodManager.FetchAllMethods(fetchAllProc, dataConnector);

                // if dataObjectCollection exists
                if (methodListCollection != null)
                {
                    // set returnObject.ObjectValue
                    returnObject.ObjectValue = methodListCollection;
                }
            }
            else
            {
                // Raise Error Data Connection Not Available
                throw new Exception("The database connection is not available.");
            }

            // return value
            return(returnObject);
        }