public ActionResult DataSource(DataManager dataManager) { IEnumerable data = new List <MediaTypeViewModel>(); int countAll = 0; ZOperationResult operationResult = new ZOperationResult(); if (IsSearch()) { try { SyncfusionGrid syncfusionGrid = new SyncfusionGrid(typeof(MediaType), UnitOfWork.DBMS); ArrayList args = new ArrayList(); string where = syncfusionGrid.ToLinqWhere(dataManager.Search, dataManager.Where, args); string orderBy = syncfusionGrid.ToLinqOrderBy(dataManager.Sorted); int take = (dataManager.Skip == 0 && dataManager.Take == 0) ? AppDefaults.SyncfusionRecordsBySearch : dataManager.Take; // Excel Filtering data = ZViewHelper <MediaTypeViewModel, MediaTypeDTO, MediaType> .ToViewList(Repository.Select(where, args.ToArray(), orderBy, dataManager.Skip, take)); if (dataManager.RequiresCounts) { countAll = Repository.Count(where, args.ToArray()); } } catch (Exception exception) { operationResult.ParseException(exception); } if (!operationResult.Ok) { throw new InvalidOperationException(operationResult.Text); } } return(Json(JsonConvert.SerializeObject(new { result = data, count = countAll }), JsonRequestBehavior.AllowGet)); }
public ActionResult DataSource(DataManager dataManager) { SyncfusionDataResult dataResult = new SyncfusionDataResult(); dataResult.result = new List <UserClaimViewModel>(); ZOperationResult operationResult = new ZOperationResult(); if (IsSearch(operationResult)) { try { SyncfusionGrid syncfusionGrid = new SyncfusionGrid(typeof(UserClaim), Application.UnitOfWork.DBMS); ArrayList args = new ArrayList(); string where = syncfusionGrid.ToLinqWhere(dataManager.Search, dataManager.Where, args); string orderBy = syncfusionGrid.ToLinqOrderBy(dataManager.Sorted); int take = (dataManager.Skip == 0 && dataManager.Take == 0) ? AppDefaults.SyncfusionRecordsBySearch : dataManager.Take; // Excel Filtering dataResult.result = ZViewHelper <UserClaimViewModel, UserClaim> .ToViewList(Application.Search(operationResult, where, args.ToArray(), orderBy, dataManager.Skip, take)); if (dataManager.RequiresCounts) { dataResult.count = Application.Count(operationResult, where, args.ToArray()); } } catch (Exception exception) { operationResult.ParseException(exception); } if (!operationResult.Ok) { throw operationResult.Exception; } } return(Json(JsonConvert.SerializeObject(dataResult), JsonRequestBehavior.AllowGet)); }