Example #1
0
        /// <summary>
        /// Delete the record
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool Delete <T>(string tableName, string pk, string rk, DataSourceEnum dataSourceEnum = DataSourceEnum.Unknown)
        {
            if (string.IsNullOrEmpty(tableName))
            {
                return(false);
            }

            if (string.IsNullOrEmpty(pk))
            {
                return(false);
            }

            if (string.IsNullOrEmpty(rk))
            {
                return(false);
            }

            // If under Test, return True;
            if (DataSourceBackend.GetTestingMode())
            {
                return(true);
            }

            return(DeleteDirect <T>(tableName, pk, rk, dataSourceEnum));
        }
Example #2
0
        /// <summary>
        /// Insert or Replace the Record
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public T Update <T>(string tableName, string pk, string rk, T data, DataSourceEnum dataSourceEnum = DataSourceEnum.Unknown)
        {
            var myReturn = default(T);

            if (string.IsNullOrEmpty(tableName))
            {
                return(myReturn);
            }

            if (string.IsNullOrEmpty(pk))
            {
                return(myReturn);
            }

            if (string.IsNullOrEmpty(rk))
            {
                return(myReturn);
            }

            if (data == null)
            {
                return(myReturn);
            }

            // If under Test, return True;
            if (DataSourceBackend.GetTestingMode())
            {
                return(myReturn);
            }

            return(UpdateDirect <T>(tableName, pk, rk, data, dataSourceEnum));
        }
Example #3
0
        //public DataSourceEnum DataSourceServerMode = DataSourceEnum.Local;

        public bool SetDataSourceServerMode(DataSourceEnum dataSourceServerMode)
        {
            var connectionString        = string.Empty;
            var StorageConnectionString = GetDataSourceConnectionString(dataSourceServerMode);

            // If under Test, return True;
            if (DataSourceBackend.GetTestingMode())
            {
                return(true);
            }

            return(SetDataSourceServerModeDirect(StorageConnectionString));
        }
Example #4
0
        /// <summary>
        /// Load All Rows that match the PK
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="pk"></param>
        /// <returns></returns>
        public List <T> LoadAll <T>(string tableName, string pk, bool convert = true, DataSourceEnum dataSourceEnum = DataSourceEnum.Unknown)
        {
            var myReturnList = new List <T>();

            if (string.IsNullOrEmpty(tableName))
            {
                return(myReturnList);
            }

            if (string.IsNullOrEmpty(pk))
            {
                return(myReturnList);
            }

            // If under Test, return True;
            if (DataSourceBackend.GetTestingMode())
            {
                return(myReturnList);
            }

            return(LoadAllDirect <T>(tableName, pk, dataSourceEnum, convert));
        }
Example #5
0
        /// <summary>
        /// checks if the provided id should be blocked from access based on the input role
        /// if the id is in the role, block access and return true
        /// if the id is not in the role, don't block access and return true
        /// </summary>
        /// <param name="CurrentId"></param>
        /// <param name="userRole"></param>
        /// <returns></returns>
        public bool BlockExecptForRole(string CurrentId, UserRoleEnum userRole)
        {
            if (DataSourceBackend.GetTestingMode())
            {
                // Allow anyone in for testing...
                return(false);
            }

            // Check that the passed in ID, is in the roll specified...
            var data = DataSource.FindUserByID(CurrentId);

            var result = DataSource.UserHasClaimOfType(CurrentId, userRole);

            // If the user has the claim, then they blocked, else they are OK.
            if (result)
            {
                return(false);
            }

            // User does not have the claim, so return true...
            return(true);
        }