public GlobalVariable GetGlobalVariable(GlobalVariableName globalVariableName) { List <GlobalVariable> globalVariableQuery = (from g in DB.GetTable <GlobalVariable>() where g.VariableName == globalVariableName.ToString() select g).ToList(); if (globalVariableQuery.Count > 1) { throw new ServiceException( string.Format( "More than one Global Variable with the name {0} found. Contact administrator.", globalVariableName.ToString()), ServiceResultCode.FatalError); } GlobalVariable result = globalVariableQuery.Count < 1 ? null : globalVariableQuery[0]; if (result == null) { throw new ServiceException( string.Format( "Could not find Global Variable {0}. Contact administrator.", globalVariableName.ToString()), ServiceResultCode.FatalError); } return(result); }
public string this[GlobalVariableName variableName] { get { ValidateVariableCache(variableName); return(_globalVariables[variableName.ToString()].VariableValue); } set { ValidateVariableCache(variableName); _globalVariables[variableName.ToString()].VariableValue = value; } }
private void ValidateVariableCache(GlobalVariableName variableName) { if (_globalVariables.Count < 1) { throw new UserThrownException( "Variables have not been downloaded from the server yet, global server variable chache is empty.", true, true, false); } if (!_globalVariables.ContainsKey(variableName.ToString())) { throw new UserThrownException( string.Format("No variablle exists with the name {0} in the global server variable cache.", variableName.ToString()), true, true, false); } }
public ServiceFunctionResult <GlobalVariable> GetGlobalVariable(GlobalVariableName globalVariableName, User user) { try { ValidateUser(user); List <GlobalVariable> query = (from g in DB.GetTable <GlobalVariable>() where g.VariableName == globalVariableName.ToString() select g).ToList(); GlobalVariable result = query.Count < 1 ? null : query[0]; return(new ServiceFunctionResult <GlobalVariable>() { Contents = result }); } catch (Exception ex) { return(new ServiceFunctionResult <GlobalVariable>(HandleException(ex, user))); } }
public ServiceFunctionResult <GlobalVariable> GetGlobalVariable(GlobalVariableName globalVariableName, User user) { return((new GlobalVariableContext()).GetGlobalVariable(globalVariableName, user)); }