Example #1
0
        ///<summary>Will return the UserOdPref corresponding to the usernum/fkey/fkeytype/ClinicNum composite key given.</summary>
        public static UserOdPref GetByCompositeKey(long userNum, long fkey, UserOdFkeyType fkeyType, long clinicNum = 0)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <UserOdPref>(MethodBase.GetCurrentMethod(), userNum, fkey, fkeyType, clinicNum));
            }
            string command = "SELECT * FROM userodpref WHERE UserNum=" + POut.Long(userNum)
                             + " AND Fkey=" + POut.Long(fkey) + " AND FkeyType=" + POut.Int((int)fkeyType)
                             + " AND ClinicNum=" + POut.Long(clinicNum);

            return(ODMethodsT.Coalesce(
                       //Get the db value if it exists.
                       Crud.UserOdPrefCrud.SelectOne(command),
                       //Create a new instance if db value does not exist.
                       new UserOdPref()
            {
                IsNew = true,
                UserOdPrefNum = 0,
                Fkey = fkey,
                FkeyType = fkeyType,
                UserNum = userNum,
                ValueString = "",
                ClinicNum = clinicNum,
            }));
        }
Example #2
0
        public static List <UserOdPref> GetAllByFkeyAndFkeyType(long fkey, UserOdFkeyType fkeyType)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <UserOdPref> >(MethodBase.GetCurrentMethod(), fkey, fkeyType));
            }
            string command = "SELECT * FROM userodpref WHERE Fkey=" + POut.Long(fkey) + " AND FkeyType=" + POut.Int((int)fkeyType);

            return(Crud.UserOdPrefCrud.SelectMany(command));
        }
Example #3
0
        ///<summary>This will ensure that when inserting this preference that there are no other preferences that are of the same fkey/fkeytype/user combination.
        ///This will likely only be used in specific scenarios where there is only 1 userodpref for the fkey/fkeytype passed in.
        ///To use this method with multiple userodprefs, you must make ValueString contain a JSON object or equivalent complex document.</summary>
        public static void DeleteMany(long userNum, long fkey, UserOdFkeyType fkeyType)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), userNum, fkey, fkeyType);
                return;
            }
            //Delete any userodpref rows that match its usernum/fkey/fkeytype.
            string command = "DELETE FROM userodpref WHERE UserNum=" + POut.Long(userNum)
                             + " AND FkeyType=" + POut.Int((int)fkeyType)
                             + " AND Fkey=" + POut.Long(fkey);

            Db.NonQ(command);
        }
Example #4
0
        ///<summary>Deletes UserOdPref with provided parameters.
        ///If "userNum" is 0 then will delete all UserOdPref's with corresponding fkeyType and valueString.</summary>
        public static void DeleteForValueString(long userNum, UserOdFkeyType fkeyType, string valueString)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), userNum, fkeyType, valueString);
                return;
            }
            string command = "DELETE FROM userodpref "
                             + "WHERE ValueString='" + POut.String(valueString) + "' AND FkeyType=" + POut.Int((int)fkeyType);

            if (userNum != 0)
            {
                command += " AND UserNum=" + POut.Long(userNum);
            }
            Db.NonQ(command);
        }
 ///<summary>Helper method to update or insert the passed in UserOdPref utilizing the specified valueString and keyType.
 ///If the user pref passed in it null then a new user pref will be inserted.  Otherwise the user pref is updated.</summary>
 private void UpsertUserOdPref(UserOdPref userOdPref, UserOdFkeyType keyType, string valueString)
 {
     if (userOdPref == null)
     {
         UserOdPref userOdPrefTemp = new UserOdPref();
         userOdPrefTemp.Fkey        = 0;
         userOdPrefTemp.FkeyType    = keyType;
         userOdPrefTemp.UserNum     = _userNumCur;
         userOdPrefTemp.ValueString = valueString;
         UserOdPrefs.Insert(userOdPrefTemp);
     }
     else
     {
         userOdPref.FkeyType    = keyType;
         userOdPref.ValueString = valueString;
         UserOdPrefs.Update(userOdPref);
     }
 }
Example #6
0
        ///<summary>Will return a list of UserOdPrefs corresponding to the usernum/fkey/fkeytype combination given.</summary>
        public static List <UserOdPref> GetByUserAndFkeyAndFkeyType(long userNum, long fkey, UserOdFkeyType fkeyType, List <long> listClinicNums = null)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <UserOdPref> >(MethodBase.GetCurrentMethod(), userNum, fkey, fkeyType, listClinicNums));
            }
            string command = "SELECT * FROM userodpref WHERE UserNum=" + POut.Long(userNum)
                             + " AND Fkey=" + POut.Long(fkey) + " AND FkeyType=" + POut.Int((int)fkeyType);

            if (listClinicNums != null && listClinicNums.Count > 0)
            {
                command += " AND ClinicNum IN(" + String.Join(", ", listClinicNums) + ") ";
            }
            return(Crud.UserOdPrefCrud.SelectMany(command));
        }