public IResultModel OptionsEdit(string code) { var model = new ModuleOptionsUpdateModel { Code = code, Definitions = _moduleOptionsContainer.GetDefinitions(code), Instance = _moduleOptionsContainer.GetInstance(code) }; return(ResultModel.Success(model)); }
public async Task <IResultModel> GetValueByKey(string key, ConfigType type = ConfigType.System, string moduleCode = null) { string value = string.Empty; if (type == ConfigType.Module) { var options = _moduleOptionsEngine.GetInstance(moduleCode); if (options != null) { var properties = options.GetType().GetProperties(); foreach (var propertyInfo in properties) { if (propertyInfo.Name.EqualsIgnoreCase(key)) { var val = propertyInfo.GetValue(options); if (val != null) { if (propertyInfo.PropertyType.IsEnum || propertyInfo.PropertyType.IsBool()) { value = val.ToInt().ToString(); } else if (propertyInfo.PropertyType.IsDateTime()) { value = val.ToDateTime().Format(); } else { value = val.ToString(); } } break; } } } } else { var entity = await _repository.GetByKey(key); if (entity != null) { value = entity.Value; } } return(ResultModel.Success(value)); }