public static InputChoice Load(Int32 inputChoiceId, bool useCache) { if (inputChoiceId == 0) { return(null); } InputChoice inputChoice = null; string key = "InputChoice_" + inputChoiceId.ToString(); if (useCache) { inputChoice = ContextCache.GetObject(key) as InputChoice; if (inputChoice != null) { return(inputChoice); } } inputChoice = new InputChoice(); if (inputChoice.Load(inputChoiceId)) { if (useCache) { ContextCache.SetObject(key, inputChoice); } return(inputChoice); } return(null); }
public static bool Delete(Int32 inputChoiceId) { InputChoice inputChoice = new InputChoice(); if (inputChoice.Load(inputChoiceId)) { return(inputChoice.Delete()); } return(false); }
public static InputChoiceCollection LoadForInputField(Int32 inputFieldId, int maximumRows, int startRowIndex, string sortExpression) { //DEFAULT SORT EXPRESSION if (string.IsNullOrEmpty(sortExpression)) { sortExpression = "OrderBy"; } //CREATE THE DYNAMIC SQL TO LOAD OBJECT StringBuilder selectQuery = new StringBuilder(); selectQuery.Append("SELECT"); if (maximumRows > 0) { selectQuery.Append(" TOP " + (startRowIndex + maximumRows).ToString()); } selectQuery.Append(" " + InputChoice.GetColumnNames(string.Empty)); selectQuery.Append(" FROM ac_InputChoices"); selectQuery.Append(" WHERE InputFieldId = @inputFieldId"); selectQuery.Append(" ORDER BY " + sortExpression); Database database = Token.Instance.Database; DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString()); database.AddInParameter(selectCommand, "@inputFieldId", System.Data.DbType.Int32, inputFieldId); //EXECUTE THE COMMAND InputChoiceCollection results = new InputChoiceCollection(); int thisIndex = 0; int rowCount = 0; using (IDataReader dr = database.ExecuteReader(selectCommand)) { while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows))) { if (thisIndex >= startRowIndex) { InputChoice inputChoice = new InputChoice(); InputChoice.LoadDataReader(inputChoice, dr); results.Add(inputChoice); rowCount++; } thisIndex++; } dr.Close(); } return(results); }
public static SaveResult Insert(InputChoice inputChoice) { return(inputChoice.Save()); }
public static SaveResult Update(InputChoice inputChoice) { return(inputChoice.Save()); }
public static bool Delete(InputChoice inputChoice) { return(inputChoice.Delete()); }