public FindResponse FindAppSettings(FindRequest request) { var response = new FindResponse(); using (var db = DbContext) { var query = db.AppSettings.AsQueryable(); if (request.SettingType.HasValue) { query = query.Where(i => i.SettingType == request.SettingType); } if (request.ExcludeSettingTypes != null && request.ExcludeSettingTypes.Any()) { query = query.Where(i => request.ExcludeSettingTypes.All(k => k != i.SettingType)); } query = request.IsSortingValid ? request.ApplySortOption(query) : request.ApplyPageOption(query.OrderBy(q => q.Name)); var pagingResult = request.ApplyPageOption(query).ToList(); response.TotalRecords = query.Count(); response.Results = pagingResult.MapList<AppSetting>(); } return response; }
public List<AppSetting> GetAppSettings(AppSettingType settingType) { var key = FormatKey(CacheKey.GetAppSettings, settingType); var appRequest = new Data.DataContract.AppSettingDC.FindRequest { SettingType = settingType }; var cacheValue = GetOrSet(key, _serviceHelper.AppSetting, service => service.FindAppSettings(appRequest).Results); return cacheValue as List<AppSetting> ?? new List<AppSetting>(); }
public ActionResult Index(AppSettingIndexModel model) { if (!model.SettingType.HasValue && !Request.IsPostAction()) { model.SettingType = AppSettingType.Smtp; } model.InitSortInfo(); if (string.IsNullOrWhiteSpace(model.SortBy)) { model.SortBy = "Name"; } var filter = new FindRequest { SettingType = model.SettingType, ExcludeSettingTypes = new List<AppSettingType> { AppSettingType.State }, SortOption = new SortOption(new[] { new SortItem(model.SortBy, model.SortDirection.Value) }), PageOption = new PageOption { PageSize = model.Pagination.PageSize, PageNumber = model.Pagination.CurrentPageIndex } }; var response = ServiceHelper.AppSetting.ExecuteDispose(s => s.FindAppSettings(filter)); model.Results = response.Results.MapList<AppSettingModel>(); model.Pagination.TotalRecords = response.TotalRecords; return View(model); }
public FindResponse FindAppSettings(FindRequest request) { return Execute(_repository, r => r.FindAppSettings(request)); }