public async Task <IActionResult> Get([FromQuery] PagingRequestModel model) { var accountMicroService = new AccountMicroService(_AppConfig.APIGatewayServer); var toDTO = new Func <MemberHierarchyParam, Task <MemberHierarchyParamDTO> >(async(entity) => { var dto = new MemberHierarchyParamDTO(); dto.Id = entity.Id; dto.Name = entity.Name; dto.Description = entity.Description; dto.Creator = entity.Creator; dto.Modifier = entity.Modifier; dto.CreatedTime = entity.CreatedTime; dto.ModifiedTime = entity.ModifiedTime; var refSetting = await _Context.MemberHierarchySettings.Where(x => x.MemberHierarchyParamId == entity.Id && x.OrganizationId == CurrentAccountOrganizationId).FirstOrDefaultAsync(); if (refSetting != null) { dto.Rate = refSetting.Rate; } await accountMicroService.GetNameByIds(entity.Creator, entity.Modifier, (creatorName, modifierName) => { dto.CreatorName = creatorName; dto.ModifierName = modifierName; }); return(await Task.FromResult(dto)); }); return(await _PagingRequest(model, toDTO)); }
/// <summary> /// SimplePagedQueryAsync /// </summary> /// <param name="model"></param> /// <param name="accid"></param> /// <param name="advanceQuery"></param> /// <returns></returns> public override async Task <PagedData <StaticMesh> > SimplePagedQueryAsync(PagingRequestModel model, string accid, Func <IQueryable <StaticMesh>, Task <IQueryable <StaticMesh> > > advanceQuery = null) { var result = await base.SimplePagedQueryAsync(model, accid, advanceQuery); if (result.Total > 0) { for (int idx = result.Data.Count - 1; idx >= 0; idx--) { var curData = result.Data[idx]; curData.Properties = null; curData.Dependencies = null; if (!string.IsNullOrWhiteSpace(curData.Icon)) { var fs = await _DbContext.Files.FirstOrDefaultAsync(x => x.Id == curData.Icon); if (fs != null) { curData.IconFileAssetUrl = fs.Url; } } if (!string.IsNullOrWhiteSpace(curData.FileAssetId)) { var fs = await _DbContext.Files.FirstOrDefaultAsync(x => x.Id == curData.FileAssetId); if (fs != null) { curData.FileAssetUrl = fs.Url; } } } } return(result); }
/// <summary> /// SimplePagedQueryAsync /// </summary> /// <param name="model"></param> /// <param name="accid"></param> /// <param name="advanceQuery"></param> /// <returns></returns> public override async Task <PagedData <Organization> > SimplePagedQueryAsync(PagingRequestModel model, string accid, Func <IQueryable <Organization>, Task <IQueryable <Organization> > > advanceQuery = null) { var result = await base.SimplePagedQueryAsync(model, accid, advanceQuery); if (result.Total > 0) { for (int idx = result.Data.Count - 1; idx >= 0; idx--) { var curData = result.Data[idx]; //if (!string.IsNullOrWhiteSpace(curData.Icon)) // curData.IconFileAsset = await _DbContext.Files.FindAsync(curData.Icon); if (!string.IsNullOrWhiteSpace(curData.Icon)) { var fs = await _DbContext.Files.FirstOrDefaultAsync(x => x.Id == curData.Icon); if (fs != null) { curData.IconFileAssetUrl = fs.Url; } } if (!string.IsNullOrWhiteSpace(curData.OrganizationTypeId)) { var organType = await _DbContext.OrganizationTypes.Where(x => x.ActiveFlag == AppConst.I_DataState_Active && x.Id == curData.OrganizationTypeId).FirstOrDefaultAsync(); if (organType != null) { curData.OrganizationTypeName = organType.Name; } } } } return(result); }
/// <summary> /// 根据查询参数获取分页信息 /// </summary> /// <param name="model"></param> /// <param name="qMapping"></param> /// <param name="advanceQuery"></param> /// <param name="literal"></param> /// <returns></returns> protected async Task <IActionResult> _GetPagingRequest(PagingRequestModel model, Action <List <string> > qMapping = null, Func <IQueryable <T>, Task <IQueryable <T> > > advanceQuery = null, Func <T, IList <T>, Task <T> > literal = null) { var accid = AuthMan.GetAccountId(this); var qs = new List <string>(); qMapping?.Invoke(qs); if (qs.Count > 0) { var builder = new StringBuilder(); foreach (var item in qs) { builder.AppendFormat(";{0}", item); } model.Q = builder.ToString(); } var result = await _Repository.SimplePagedQueryAsync(model, accid, advanceQuery); if (literal != null) { if (result.Data != null && result.Data.Count > 0) { for (int idx = result.Data.Count - 1; idx >= 0; idx--) { result.Data[idx] = await literal(result.Data[idx], result.Data); } } } return(Ok(RepositoryBase <T, DTO> .PageQueryDTOTransfer(result))); }
public async Task <Result <ListResult <RoutePoint> > > GetPoints(PagingRequestModel model, string routes) { try { var pager = new QueryPager(); ApplyPaging(model, pager); var results = await _pointRepository.Search(pager); var listResult = new ListResult <RoutePoint>() { Count = results.Count, HasNext = results.HasNext, Results = results.Results.Select(r => new RoutePoint() { Id = r.RouteInfo.ID, Point = GeoPointConverter.GetPoint(r.Point) }).ToList() }; return(new Result <ListResult <RoutePoint> >(listResult)); } catch (Exception ex) { ErrorResult error = GenerateError(ex); return(new Result <ListResult <RoutePoint> >(error)); } }
public async Task <IActionResult> Get([FromQuery] PagingRequestModel model, string departmentId, bool ignoreOwner = false, bool currentOrganAccount = true) { var organId = await _GetCurrentUserOrganId(); var advanceQuery = new Func <IQueryable <Account>, Task <IQueryable <Account> > >(async(query) => { if (!string.IsNullOrWhiteSpace(departmentId)) { query = query.Where(x => x.DepartmentId == departmentId); } if (ignoreOwner) { var organ = await _Repository._DbContext.Organizations.FindAsync(organId); if (organ != null) { query = query.Where(x => x.Id != organ.OwnerId); } } if (currentOrganAccount) { query = query.Where(x => x.OrganizationId == organId); } query = query.Where(x => x.ActiveFlag == AppConst.I_DataState_Active); return(query); }); return(await _GetPagingRequest(model, null, advanceQuery)); }
public async Task <IActionResult> Get([FromQuery] PagingRequestModel model) { var accountMicroService = new AccountMicroService(_AppConfig.APIGatewayServer); var nationalUrbanMicroService = new NationalUrbanMicroService(_AppConfig.APIGatewayServer); var toDTO = new Func <WorkFlow, Task <WorkFlowDTO> >(async(entity) => { var dto = new WorkFlowDTO(); dto.Id = entity.Id; dto.Name = entity.Name; dto.Description = entity.Description; dto.Creator = entity.Creator; dto.Modifier = entity.Modifier; dto.CreatedTime = entity.CreatedTime; dto.ModifiedTime = entity.ModifiedTime; await accountMicroService.GetNameByIds(entity.Creator, entity.Modifier, (creatorName, modifierName) => { dto.CreatorName = creatorName; dto.ModifierName = modifierName; }); return(await Task.FromResult(dto)); }); return(await _PagingRequest(model, toDTO)); }
public async Task <IActionResult> Get([FromQuery] PagingRequestModel model, string organType, bool excludeInner = false, bool innerOnly = false) { var advanceQuery = new Func <IQueryable <UserRole>, Task <IQueryable <UserRole> > >(async(query) => { if (!string.IsNullOrWhiteSpace(organType)) { query = query.Where(x => x.ApplyOrgans.Contains(organType)); } if (excludeInner) { query = query.Where(x => x.IsInner == false); } if (innerOnly) { query = query.Where(x => x.IsInner == true); } query = query.Where(x => x.ActiveFlag == AppConst.I_DataState_Active); return(await Task.FromResult(query)); }); return(await _GetPagingRequest(model, null, advanceQuery)); }
public async Task <IActionResult> Get([FromQuery] PagingRequestModel model, string categoryId = "") { var advanceQuery = new Func <IQueryable <ProductReplaceGroup>, Task <IQueryable <ProductReplaceGroup> > >(async(query) => { #region 根据分类Id查询 if (!string.IsNullOrWhiteSpace(categoryId)) { var curCategoryTree = await _Repository._DbContext.AssetCategoryTrees.FirstOrDefaultAsync(x => x.ObjId == categoryId); //如果是根节点,把所有取出,不做分类过滤 if (curCategoryTree != null && curCategoryTree.LValue > 1) { var categoryIdsQ = from it in _Repository._DbContext.AssetCategoryTrees where it.NodeType == curCategoryTree.NodeType && it.OrganizationId == curCategoryTree.OrganizationId && it.LValue >= curCategoryTree.LValue && it.RValue <= curCategoryTree.RValue select it.ObjId; var categoryIds = await categoryIdsQ.ToListAsync(); query = from it in query join prod in _Repository._DbContext.Products on it.DefaultItemId equals prod.Id into prq where categoryIds.Contains(prq.First().CategoryId) select it; } } #endregion query = query.Where(x => x.ActiveFlag == AppConst.I_DataState_Active); return(await Task.FromResult(query)); }); return(await _GetPagingRequest(model, null, advanceQuery)); }
public async Task <IActionResult> Get([FromQuery] PagingRequestModel model, string categoryId = "", bool classify = true) { var advanceQuery = new Func <IQueryable <ProductGroup>, Task <IQueryable <ProductGroup> > >(async(query) => { if (classify) { if (!string.IsNullOrWhiteSpace(categoryId)) { var curCategoryTree = await _Repository._DbContext.AssetCategoryTrees.FirstOrDefaultAsync(x => x.ObjId == categoryId); //如果是根节点,把所有取出,不做分类过滤 if (curCategoryTree != null && curCategoryTree.LValue > 1) { var categoryQ = from it in _Repository._DbContext.AssetCategoryTrees where it.NodeType == curCategoryTree.NodeType && it.OrganizationId == curCategoryTree.OrganizationId && it.LValue >= curCategoryTree.LValue && it.RValue <= curCategoryTree.RValue select it; query = from it in query join cat in categoryQ on it.CategoryId equals cat.ObjId select it; } } } else { query = query.Where(x => string.IsNullOrWhiteSpace(x.CategoryId)); } query = query.Where(x => x.ActiveFlag == AppConst.I_DataState_Active); return(await Task.FromResult(query)); }); return(await _GetPagingRequest(model, null, advanceQuery)); }
public async Task <PagingResponseModel <PushNotificationListModel> > GetList(PagingRequestModel model) { var query = _repository.GetAll <PushNotification>(); var count = await query.CountAsync(); var page = Convert.ToInt32(Math.Ceiling(decimal.Divide(count, model.Count))); var result = await query.OrderByDescending(x => x.CreatedDt).Skip((model.Page - 1) * model.Count) .Take(model.Count).Select(x => new PushNotificationListModel { Id = x.Id, Description = x.Description, Title = x.Title, PushNotificationStatusType = x.PushNotificationStatusType, SendingDate = x.SendingDate, PushNotificationUserType = x.PushNotificationUserType, PushNotificationActionType = x.PushNotificationActionType }).ToListAsync(); return(new PagingResponseModel <PushNotificationListModel> { ItemCount = count, PageCount = page, DateFrom = null, Data = result }); }
public async Task <IActionResult> Get([FromQuery] PagingRequestModel model) { var qMapping = new Action <List <string> >((query) => { }); return(await _GetPagingRequest(model, qMapping)); }
public async Task <IActionResult> GetPoints([FromQuery] int?pagesize, [FromQuery] int?page) { var model = new PagingRequestModel(page, pagesize); var result = await _routeService.GetPoints(model, string.Empty); return(WrapResponse(result, HttpStatusCode.OK)); }
public async Task<PagedData<ProductPackage>> SimplePagedQueryAsync(PagingRequestModel model, string accountId, Func<IQueryable<ProductPackage>, Task<IQueryable<ProductPackage>>> advanceQuery = null) { var query = _Context.ProductPackages.AsQueryable(); if (advanceQuery != null) query = await advanceQuery(query); //关键词过滤查询 if (!string.IsNullOrWhiteSpace(model.Search)) query = query.Where(d => d.Name.Contains(model.Search)); var result = await query.SimplePaging(model.Page, model.PageSize, model.OrderBy, "Name", model.Desc); return result; }
public async Task <IActionResult> Get([FromQuery] PagingRequestModel model) { var accountMicroService = new AccountMicroService(_AppConfig.APIGatewayServer); var nationalUrbanMicroService = new NationalUrbanMicroService(_AppConfig.APIGatewayServer); var toDTO = new Func <Member, Task <MemberDTO> >(async(entity) => { var dto = new MemberDTO(); dto.Id = entity.Id; dto.Name = entity.Name; dto.Description = entity.Description; dto.Creator = entity.Creator; dto.Modifier = entity.Modifier; dto.CreatedTime = entity.CreatedTime; dto.ModifiedTime = entity.ModifiedTime; dto.Province = entity.Province; dto.City = entity.City; dto.County = entity.County; dto.Company = entity.Company; await nationalUrbanMicroService.GetNameByIds(entity.Province, entity.City, entity.County, (provinceName, cityName, countyName) => { dto.ProvinceName = provinceName; dto.CityName = cityName; dto.CountyName = countyName; }); var account = await accountMicroService.GetById(entity.AccountId); if (account != null) { dto.Name = account.Name; dto.Description = account.Description; dto.Phone = account.Phone; dto.Mail = account.Mail; dto.Icon = account.Icon; } //dto.Inviter = entity.Inviter; //dto.InviterName = await accountMicroService.GetNameById(entity.Inviter); dto.Superior = entity.Superior; dto.SuperiorName = await accountMicroService.GetNameById(entity.Superior); await accountMicroService.GetNameByIds(entity.Creator, entity.Modifier, (creatorName, modifierName) => { dto.CreatorName = creatorName; dto.ModifierName = modifierName; }); return(await Task.FromResult(dto)); }); return(await _PagingRequest(model, toDTO)); }
protected BaseListResponseModel <TResult> GetListResponse <TResult>(PagingRequestModel searchModel, IQueryable <TResult> entities) { var result = new BaseListResponseModel <TResult> { TotalCount = entities.Count(), }; entities = PagingQuery(entities, searchModel.Page, searchModel.Limit); result.Data = entities.ToArray(); return(result); }
public async Task <IActionResult> Get([FromQuery] PagingRequestModel model, string nodeTypes) { var advanceQuery = new Func <IQueryable <Navigation>, Task <IQueryable <Navigation> > >(async(query) => { if (!string.IsNullOrWhiteSpace(nodeTypes)) { var typeArr = nodeTypes.Split(",").ToList(); query = query.Where(x => typeArr.Contains(x.NodeType)); } return(await Task.FromResult(query)); }); return(await _GetPagingRequest(model, null, advanceQuery)); }
public async Task <IActionResult> Get([FromQuery] PagingRequestModel model, int?fileState = null) { var advanceQuery = new Func <IQueryable <FileAsset>, Task <IQueryable <FileAsset> > >(async(query) => { if (fileState != null) { query = query.Where(x => x.FileState == fileState); } query = query.Where(x => x.ActiveFlag == AppConst.I_DataState_Active); return(await Task.FromResult(query)); }); return(await _GetPagingRequest(model, null, advanceQuery)); }
/// <summary> /// 处理导出数据请求 /// </summary> /// <typeparam name="CSV"></typeparam> /// <param name="model"></param> /// <param name="transMapping"></param> /// <param name="qMapping"></param> /// <param name="advanceQuery"></param> /// <returns></returns> protected async Task <IActionResult> _ExportDataRequest <CSV>(PagingRequestModel model, Func <DTO, Task <CSV> > transMapping, Action <List <string> > qMapping = null, Func <IQueryable <T>, Task <IQueryable <T> > > advanceQuery = null) where CSV : ClassMap, new() { model.Page = 0; model.PageSize = int.MaxValue; var accid = AuthMan.GetAccountId(this); var qs = new List <string>(); qMapping?.Invoke(qs); if (qs.Count > 0) { var builder = new StringBuilder(); foreach (var item in qs) { builder.AppendFormat(";{0}", item); } model.Q = builder.ToString(); } var list = new List <CSV>(); var res = await _Repository.SimplePagedQueryAsync(model, accid, advanceQuery); var resource = RepositoryBase <T, DTO> .PageQueryDTOTransfer(res); if (resource.Data != null && resource.Data.Count > 0) { foreach (var item in resource.Data) { var csData = await transMapping(item); list.Add(csData); } } var ms = new MemoryStream(); using (var stream = new MemoryStream()) using (var writer = new StreamWriter(stream, Encoding.UTF8)) using (var csv = new CsvWriter(writer)) { csv.WriteHeader <CSV>(); csv.NextRecord(); csv.WriteRecords(list); writer.Flush(); stream.Position = 0; stream.CopyTo(ms); ms.Position = 0; } return(File(ms, "application/octet-stream")); }
public async Task <IActionResult> Get([FromQuery] PagingRequestModel model, string categoryId = "", string categoryName = "", bool classify = true) { var advanceQuery = new Func <IQueryable <Product>, Task <IQueryable <Product> > >(async(query) => { if (classify) { #region 根据分类Id查询 if (!string.IsNullOrWhiteSpace(categoryId)) { var curCategoryTree = await _Repository._DbContext.AssetCategoryTrees.FirstOrDefaultAsync(x => x.ObjId == categoryId); //如果是根节点,把所有取出,不做分类过滤 //if (curCategoryTree != null && curCategoryTree.LValue > 1) //{ var categoryQ = from it in _Repository._DbContext.AssetCategoryTrees where it.NodeType == curCategoryTree.NodeType && it.OrganizationId == curCategoryTree.OrganizationId && it.LValue >= curCategoryTree.LValue && it.RValue <= curCategoryTree.RValue select it; query = from it in query join cat in categoryQ on it.CategoryId equals cat.ObjId select it; //} } //else //{ // query = query.Where(x => !string.IsNullOrWhiteSpace(x.CategoryId)); //} #endregion #region 根据分类名称查询 if (!string.IsNullOrWhiteSpace(categoryName)) { var accid = AuthMan.GetAccountId(this); var account = await _Repository._DbContext.Accounts.FindAsync(accid); var categoryIds = _Repository._DbContext.AssetCategories.Where(x => x.Type == AppConst.S_Category_Product && x.OrganizationId == account.OrganizationId && x.Name.Contains(categoryName)).Select(x => x.Id); query = query.Where(x => categoryIds.Contains(x.CategoryId)); } #endregion } else { query = query.Where(x => string.IsNullOrWhiteSpace(x.CategoryId)); } query = query.Where(x => x.ActiveFlag == AppConst.I_DataState_Active); return(await Task.FromResult(query)); }); return(await _GetPagingRequest(model, null, advanceQuery)); }
private static List <string> SetPaging(PagingRequestModel pagingRequestModel, IEnumerable <Grid> s) { var groupedData = s.ToLookup( k => new ValueKey( k.Description, // 1st dimension k.Document // 2nd dimension )); var rowKeys = groupedData.Select(g => (string)g.Key.DimKeys[0]).Distinct().OrderBy(k => k)?.ToList(); pagingRequestModel.TotalRecord = rowKeys.Count; var pagedRowKeys = rowKeys .Skip(pagingRequestModel.PageSize * (pagingRequestModel.PageNumber - 1)) .Take(pagingRequestModel.PageSize)?.ToList(); return(pagedRowKeys); }
public async Task <IActionResult> Get([FromQuery] PagingRequestModel model) { var accountMicroService = new AccountMicroService(_AppConfig.APIGatewayServer); var nationalUrbanMicroService = new NationalUrbanMicroService(_AppConfig.APIGatewayServer); var toDTO = new Func <MemberRegistry, Task <MemberRegistryDTO> >(async(entity) => { var dto = new MemberRegistryDTO(); dto.Id = entity.Id; dto.Name = entity.Name; dto.Description = entity.Description; dto.Creator = entity.Creator; dto.Modifier = entity.Modifier; dto.CreatedTime = entity.CreatedTime; dto.ModifiedTime = entity.ModifiedTime; dto.OrganizationId = entity.OrganizationId; dto.Province = entity.Province; dto.City = entity.City; dto.County = entity.County; dto.Phone = entity.Phone; dto.Mail = entity.Mail; dto.Company = entity.Company; dto.Inviter = entity.Inviter; dto.InviterName = await accountMicroService.GetNameById(entity.Inviter); await accountMicroService.GetNameByIds(entity.Creator, entity.Modifier, (creatorName, modifierName) => { dto.CreatorName = creatorName; dto.ModifierName = modifierName; }); await nationalUrbanMicroService.GetNameByIds(entity.Province, entity.City, entity.County, (provinceName, cityName, countyName) => { dto.ProvinceName = provinceName; dto.CityName = cityName; dto.CountyName = countyName; }); return(await Task.FromResult(dto)); }); var advanceQuery = new Func <IQueryable <MemberRegistry>, Task <IQueryable <MemberRegistry> > >(async(query) => { query = query.Where(x => x.OrganizationId == CurrentAccountOrganizationId && x.IsApprove == false); return(await Task.FromResult(query)); }); return(await _PagingRequest(model, toDTO, advanceQuery)); }
public async Task <PagedData <Order> > SimplePagedQueryAsync(PagingRequestModel model, string accountId, Func <IQueryable <Order>, Task <IQueryable <Order> > > advanceQuery = null) { var query = _Context.Orders.AsQueryable(); if (advanceQuery != null) { query = await advanceQuery(query); } //关键词过滤查询 if (!string.IsNullOrWhiteSpace(model.Search)) { query = query.Where(d => d.Name.Contains(model.Search)); } var result = await query.Where(x => x.ActiveFlag == AppConst.Active).SimplePaging(model.Page, model.PageSize, model.OrderBy, "Name", model.Desc); return(result); }
public Task <IActionResult> ExportData([FromQuery] PagingRequestModel model, string categoryId = "", bool classify = true) { var advanceQuery = new Func <IQueryable <Material>, Task <IQueryable <Material> > >(async(query) => { if (classify) { if (!string.IsNullOrWhiteSpace(categoryId)) { var curCategoryTree = await _Repository._DbContext.AssetCategoryTrees.FirstOrDefaultAsync(x => x.ObjId == categoryId); //如果是根节点,把所有取出,不做分类过滤 if (curCategoryTree != null && curCategoryTree.LValue > 1) { var categoryQ = from it in _Repository._DbContext.AssetCategoryTrees where it.NodeType == curCategoryTree.NodeType && it.OrganizationId == curCategoryTree.OrganizationId && it.LValue >= curCategoryTree.LValue && it.RValue <= curCategoryTree.RValue select it; query = from it in query join cat in categoryQ on it.CategoryId equals cat.ObjId select it; } } } else { query = query.Where(x => string.IsNullOrWhiteSpace(x.CategoryId)); } query = query.Where(x => x.ActiveFlag == AppConst.I_DataState_Active); return(await Task.FromResult(query)); }); var transMapping = new Func <MaterialDTO, Task <MaterialExportDataCSV> >(async(entity) => { var csData = new MaterialExportDataCSV(); csData.MaterialName = entity.Name; csData.CategoryName = entity.CategoryName; csData.Description = entity.Description; csData.CreatedTime = entity.CreatedTime.ToString("yyyy-MM-dd hh:mm:ss"); csData.ModifiedTime = entity.ModifiedTime.ToString("yyyy-MM-dd hh:mm:ss"); csData.Creator = entity.Creator; csData.Modifier = entity.Modifier; return(await Task.FromResult(csData)); }); return(_ExportDataRequest(model, transMapping)); }
private static List <RowModel> SortBy(PagingRequestModel pagingRequestModel, ref IEnumerable <Grid> s) { var rowModels = new List <RowModel>(); if (pagingRequestModel.SortColumn && !pagingRequestModel.SortRow) { s = s.OrderBy(x => x.Document)?.ToList(); } else if (!pagingRequestModel.SortColumn && pagingRequestModel.SortRow) { s = s.OrderBy(x => x.Description)?.ToList(); } else if (pagingRequestModel.SortColumn && pagingRequestModel.SortRow) { s = s.OrderBy(x => x.Description).ThenBy(x => x.Document)?.ToList(); } return(rowModels); }
public async Task <IActionResult> Get([FromQuery] PagingRequestModel model, bool onlyShare = false, bool mine = false) { var advanceQuery = new Func <IQueryable <Solution>, Task <IQueryable <Solution> > >(async(query) => { if (onlyShare) { query = query.Where(x => x.ResourceType == (int)ResourceTypeEnum.Organizational_SubShare); } if (mine) { var accid = AuthMan.GetAccountId(this); query = query.Where(x => x.Creator == accid); } query = query.Where(x => x.ActiveFlag == AppConst.I_DataState_Active && x.IsSnapshot == false); return(await Task.FromResult(query)); }); return(await _GetPagingRequest(model, null, advanceQuery)); }
/// <summary> /// SimplePagedQueryAsync /// </summary> /// <param name="model"></param> /// <param name="accid"></param> /// <param name="advanceQuery"></param> /// <returns></returns> public override async Task <PagedData <Account> > SimplePagedQueryAsync(PagingRequestModel model, string accid, Func <IQueryable <Account>, Task <IQueryable <Account> > > advanceQuery = null) { var res = await base.SimplePagedQueryAsync(model, accid, advanceQuery); if (res.Data != null && res.Data.Count > 0) { var account = await _DbContext.Accounts.FindAsync(accid); var departments = await _DbContext.Departments.Where(x => x.OrganizationId == account.OrganizationId && x.ActiveFlag == AppConst.I_DataState_Active).ToListAsync(); for (int idx = res.Data.Count - 1; idx >= 0; idx--) { var curAccount = res.Data[idx]; if (!string.IsNullOrWhiteSpace(curAccount.DepartmentId)) { curAccount.Department = departments.FirstOrDefault(x => x.Id == curAccount.DepartmentId); } } } return(res); }
public override async Task <PagedData <Order> > SimplePagedQueryAsync(PagingRequestModel model, string accid, Func <IQueryable <Order>, Task <IQueryable <Order> > > advanceQuery = null) { var result = await base.SimplePagedQueryAsync(model, accid, advanceQuery); var rootOrgan = await GetUserRootOrgan(accid); var ruleDetail = await _DbContext.WorkFlowRuleDetails.Where(x => x.OrganizationId == rootOrgan.Id).FirstOrDefaultAsync(); if (ruleDetail != null) { var workFlowItems = await _DbContext.WorkFlowItems.Where(x => x.WorkFlow.Id == ruleDetail.WorkFlowId).ToListAsync(); if (result.Data != null && result.Data.Count > 0) { for (var idx = result.Data.Count - 1; idx >= 0; idx--) { var item = result.Data[idx]; if (!string.IsNullOrWhiteSpace(item.WorkFlowItemId)) { var refFlowItem = workFlowItems.Where(x => x.Id == item.WorkFlowItemId).FirstOrDefault(); if (refFlowItem != null) { item.WorkFlowItemName = refFlowItem.Name; } } else { var defaultFlowItem = workFlowItems.Where(x => x.FlowGrade <= 0).FirstOrDefault(); if (defaultFlowItem != null) { item.WorkFlowItemId = defaultFlowItem.Id; item.WorkFlowItemName = defaultFlowItem.Name; } } } } } return(result); }
private DynamicGridModel CreateGridModel(PagingRequestModel pagingRequestModel) { var dynamicModel = new DynamicGridModel() { }; IEnumerable <Grid> s = GetRecordsFromDb(pagingRequestModel.SearchTerm); var rowModels = SortBy(pagingRequestModel, ref s); var pagedRowKeys = SetPaging(pagingRequestModel, s); var columnKeys = ConstructPivot(s, pagedRowKeys, rowModels); dynamicModel.RowModels = rowModels; dynamicModel.ColumnModel = new ColumnModel() { Heading = "Description", Columns = columnKeys }; pagingRequestModel.PagingUrl = "/Home/Ajaxget/"; dynamicModel.PagingRequest = pagingRequestModel; dynamicModel.ColumnHeading = "Document"; dynamicModel.RowHeading = "Description"; return(dynamicModel); }
public async Task <IActionResult> Get([FromQuery] PagingRequestModel model) { //var model = new //{ // Resource = modelName, // ModelType = "List", // Icon = "map", // DisplayModel = new List<string>() { "List" }, // Fields = new List<BSModelField>() // { // new BSModelField(){ Id="Icon",Name="Icon",Width=85} // ,new BSModelField(){ Id="Name",Name="Name",Width=125} // , new BSModelField(){ Id="Description",Name="Description",Width=185} // }, // PageSizeOptions = new List<int>() { 15, 25, 500 } //}; //return Ok(model); return(Ok(new PagedData <BSModelDefine>() { })); }