public ResponseObjectPackage<Dictionary> GetDictionaryViewModel(int dictionaryID)
 {
     DictionaryModel dict = this.GetDictionaryByID(dictionaryID).GetDataOrExceptionIfError();
     List<DictionaryField> fields = new DictionaryFieldsLogic().GetDictionaryFieldsViewModel(dictionaryID).GetDataOrExceptionIfError();
     Dictionary dictionary = new Dictionary(dict, fields);
     return new ResponseObjectPackage<Dictionary>() { resultData = dictionary };
 }
 public JsonResult GetDictionaryFieldsViewModel(int dictionaryID)
 {
     try
     {
         ResponseObjectPackage<List<DictionaryField>> result = new DictionaryFieldsLogic().GetDictionaryFieldsViewModel(dictionaryID);
         return Json(result);
     }
     catch (Exception ex)
     {
         return this.HandleException(ex);
     }
 }
        public ResponseObjectPackage<List<Dictionary<string, object>>> GetDictionaryData(int dictionaryID)
        {
            DictionaryModel dictionary = new DictionariesLogic().GetDictionaryByID(dictionaryID).GetDataOrExceptionIfError();
            List<DictionaryFieldModel> fields = new DictionaryFieldsLogic().GetDictionaryFieldsByDictionaryID(dictionaryID).GetDataOrExceptionIfError();
            string sql = string.Format(
                "select {0} " +
                "from {1};",
                    string.Join(", ", fields.Select(e => e.columnName)),
                    dictionary.tableName
            );

            RequestPackage request = new RequestPackage() { requestString = sql };

            ResponseObjectPackage<List<Dictionary<string, object>>> response = new DBUtils().RunSqlAction(new DynamicCRUD().GetDictionaryData, request);
            return response;
        }