コード例 #1
0
        /// <summary>
        /// This method deletes a 'Address' object.
        /// </summary>
        /// <param name='List<PolymorphicObject>'>The 'Address' to delete.
        /// <returns>A PolymorphicObject object with a Boolean value.
        internal PolymorphicObject DeleteAddress(List <PolymorphicObject> parameters, DataConnector dataConnector)
        {
            // Initial Value
            PolymorphicObject returnObject = new PolymorphicObject();

            // If the data connection is connected
            if ((dataConnector != null) && (dataConnector.Connected == true))
            {
                // Create Delete StoredProcedure
                DeleteAddressStoredProcedure deleteAddressProc = null;

                // verify the first parameters is a(n) 'Address'.
                if (parameters[0].ObjectValue as Address != null)
                {
                    // Create Address
                    Address address = (Address)parameters[0].ObjectValue;

                    // verify address exists
                    if (address != null)
                    {
                        // Now create deleteAddressProc from AddressWriter
                        // The DataWriter converts the 'Address'
                        // to the SqlParameter[] array needed to delete a 'Address'.
                        deleteAddressProc = AddressWriter.CreateDeleteAddressStoredProcedure(address);
                    }
                }

                // Verify deleteAddressProc exists
                if (deleteAddressProc != null)
                {
                    // Execute Delete Stored Procedure
                    bool deleted = this.DataManager.AddressManager.DeleteAddress(deleteAddressProc, dataConnector);

                    // Create returnObject.Boolean
                    returnObject.Boolean = new NullableBoolean();

                    // If delete was successful
                    if (deleted)
                    {
                        // Set returnObject.Boolean.Value to true
                        returnObject.Boolean.Value = NullableBooleanEnum.True;
                    }
                    else
                    {
                        // Set returnObject.Boolean.Value to false
                        returnObject.Boolean.Value = NullableBooleanEnum.False;
                    }
                }
            }
            else
            {
                // Raise Error Data Connection Not Available
                throw new Exception("The database connection is not available.");
            }

            // return value
            return(returnObject);
        }
コード例 #2
0
        /// <summary>
        /// This method finds a 'Address' object.
        /// </summary>
        /// <param name='List<PolymorphicObject>'>The 'Address' to delete.
        /// <returns>A PolymorphicObject object with a Boolean value.
        internal PolymorphicObject FindAddress(List <PolymorphicObject> parameters, DataConnector dataConnector)
        {
            // Initial Value
            PolymorphicObject returnObject = new PolymorphicObject();

            // locals
            Address address = null;

            // If the data connection is connected
            if ((dataConnector != null) && (dataConnector.Connected == true))
            {
                // Create Find StoredProcedure
                FindAddressStoredProcedure findAddressProc = null;

                // verify the first parameters is a 'Address'.
                if (parameters[0].ObjectValue as Address != null)
                {
                    // Get AddressParameter
                    Address paramAddress = (Address)parameters[0].ObjectValue;

                    // verify paramAddress exists
                    if (paramAddress != null)
                    {
                        // Now create findAddressProc from AddressWriter
                        // The DataWriter converts the 'Address'
                        // to the SqlParameter[] array needed to find a 'Address'.
                        findAddressProc = AddressWriter.CreateFindAddressStoredProcedure(paramAddress);
                    }

                    // Verify findAddressProc exists
                    if (findAddressProc != null)
                    {
                        // Execute Find Stored Procedure
                        address = this.DataManager.AddressManager.FindAddress(findAddressProc, dataConnector);

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

            // return value
            return(returnObject);
        }
コード例 #3
0
        /// <summary>
        /// This method fetches all 'Address' objects.
        /// </summary>
        /// <param name='List<PolymorphicObject>'>The 'Address' to delete.
        /// <returns>A PolymorphicObject object with all  'Addresses' objects.
        internal PolymorphicObject FetchAll(List <PolymorphicObject> parameters, DataConnector dataConnector)
        {
            // Initial Value
            PolymorphicObject returnObject = new PolymorphicObject();

            // locals
            List <Address> addressListCollection = null;

            // Create FetchAll StoredProcedure
            FetchAllAddressesStoredProcedure fetchAllProc = null;

            // If the data connection is connected
            if ((dataConnector != null) && (dataConnector.Connected == true))
            {
                // Get AddressParameter
                // Declare Parameter
                Address paramAddress = null;

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

                // Now create FetchAllAddressesProc from AddressWriter
                fetchAllProc = AddressWriter.CreateFetchAllAddressesStoredProcedure(paramAddress);
            }

            // Verify fetchAllProc exists
            if (fetchAllProc != null)
            {
                // Execute FetchAll Stored Procedure
                addressListCollection = this.DataManager.AddressManager.FetchAllAddresses(fetchAllProc, dataConnector);

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

            // return value
            return(returnObject);
        }
コード例 #4
0
        public async Task <ApiResult <ApiAddressResponse> > GenerateAddress(string userId, string currency)
        {
            try
            {
                var result = await AddressWriter.GenerateAddress(userId, currency);

                if (result.HasErrors)
                {
                    return(new ApiResult <ApiAddressResponse>(false, result.FirstError));
                }

                var apiResult = new ApiAddressResponse
                {
                    Currency = currency,
                    Address  = result.Data
                };
                return(new ApiResult <ApiAddressResponse>(true, apiResult));
            }
            catch (Exception ex)
            {
                return(new ApiResult <ApiAddressResponse>(ex));
            }
        }