public async Task <PagingQueryResult <SLT_DayChiDTO> > GetList([FromQuery] int skipCount, [FromQuery] int maxCount, [FromQuery] DateTime Date) { var pickedDate = Date.ToString("yyyy-MM-dd"); var slt_DayChi = await(from NQL_DayChi in _db.NQL_DayChis join kdv in _db.KDV_DayChis on new { NQL_DayChi.KDV_ID, NQL_DayChi.Daychi_ID } equals new { kdv.KDV_ID, kdv.Daychi_ID } where NQL_DayChi.Ngay_Cap_Phat.Date.ToString() == pickedDate select new SLT_DayChiDTO { Ngay_Cap_Phat = NQL_DayChi.Ngay_Cap_Phat, KDV_ID = NQL_DayChi.KDV_ID, Daychi_ID = NQL_DayChi.Daychi_ID, SoLuong = NQL_DayChi.SoLuong, SoLuongDayChi = kdv.SoLuongDayChi, SoLuongDayChi_Huy = kdv.SoLuongDayChi_Huy }).ToListAsync(); var result = new PagingQueryResult <SLT_DayChiDTO>(); result.Total = slt_DayChi.Count(); result.Items = slt_DayChi; foreach (SLT_DayChiDTO item in result.Items) { item.SoLuongDayChi_Ton = item.SoLuong - item.SoLuongDayChi; } return(result); }
public async Task <PagingQueryResult <MaterialPagingQueryDTO> > Handle(MaterialPagingQuery request, CancellationToken cancellationToken) { var result = new PagingQueryResult <MaterialPagingQueryDTO>(); request.CheckPagingParam(); if (!request.UnClassified) { request.CategoryId = await categoryRepository.GetAllSubCategoryIds(request.CategoryId); } var clientOrganId = await clientAssetPermissionControlService.ClientAssetOrganIdRedirection(); var specification = new MaterialPagingSpecification(clientOrganId, request.Page, request.PageSize, request.OrderBy, request.Desc, request.Search, request.CategoryId, request.UnClassified); var datas = await materialRepository.Paging(specification).Select(x => new { x.Id, x.Name, x.Description, x.Icon, x.CategoryId, x.CreatedTime, x.ModifiedTime }).ToListAsync(); var dtos = datas.Select(x => MaterialPagingQueryDTO.From(x.Id, x.Name, x.Description, x.Icon, x.CategoryId, x.CreatedTime, x.ModifiedTime)).ToList(); for (var idx = dtos.Count - 1; idx >= 0; idx--) { var it = dtos[idx]; it.CategoryName = await categoryRepository.GetCategoryName(it.CategoryId); } result.Total = await materialRepository.Get(specification).CountAsync(); result.Data = dtos; return(result); }
public async Task <PagingQueryResult <ProductPagingQueryDTO> > Handle(ProductPagingQuery request, CancellationToken cancellationToken) { var result = new PagingQueryResult <ProductPagingQueryDTO>(); request.CheckPagingParam(); if (!request.UnClassified) { request.CategoryId = await categoryRepository.GetAllSubCategoryIds(request.CategoryId); } var currentOrganId = identityService.GetOrganizationId(); var clientOrganId = await clientAssetPermissionControlService.ClientAssetOrganIdRedirection(); var pointKey = await accountService.GetAccessPoint(); var showPrice = pointKey.Keys.Any(k => k == AccessPointInnerPointKeyConst.PriceRetrieve); var showPartnerPrice = pointKey.Keys.Any(k => k == AccessPointInnerPointKeyConst.PartnerPriceRetrieve); var showPurchasePrice = pointKey.Keys.Any(k => k == AccessPointInnerPointKeyConst.PurchasePriceRetrieve); var specification = new ProductPagingSpecification(currentOrganId, request.Page, request.PageSize, request.Search, request.OrderBy, request.Desc, request.CategoryId, request.UnClassified); if (currentOrganId != clientOrganId) { specification.SignPermissionPaging(); } var datas = await productRepository.Paging(specification).ToListAsync(); var dtos = datas.Select(x => ProductPagingQueryDTO.From(x)).ToList(); for (var idx = dtos.Count - 1; idx >= 0; idx--) { var it = dtos[idx]; it.CategoryName = await categoryRepository.GetCategoryName(it.CategoryId); if (!showPrice) { it.HidePrice(); } if (!showPartnerPrice) { it.HidePartnerPrice(); } if (!showPurchasePrice) { it.HidePurchasePrice(); } } result.Total = await productRepository.Get(specification).CountAsync(); result.Data = dtos; return(result); }
protected virtual IPagingQueryResult <TViewModel> ConvertPagingQueryResultToViewModel(IPagingQueryResult <TEntity> entityPagingResult) { var pagingViewModelResult = new PagingQueryResult <TViewModel> { Result = entityPagingResult.Result.Select(AssignEntityToViewModel), TotalRecord = entityPagingResult.TotalRecord }; return(pagingViewModelResult); }
public virtual IPagingQueryResult <T> GetPageResult(int skip, int take, Expression <Func <T, bool> > filter = null) { int totalRecord; var result = Query().Filter(filter).GetPage(skip, take, out totalRecord); var queryResult = new PagingQueryResult <T> { Result = result, TotalRecord = totalRecord }; return(queryResult); }
public async Task <PagingQueryResult <FilePagingQueryDTO> > Handle(FilePagingQuery request, CancellationToken cancellationToken) { request.CheckPagingParam(); var result = new PagingQueryResult <FilePagingQueryDTO>(); var specification = new FilePagingSpecification(request.Page, request.PageSize, request.Search, request.OrderBy, request.Desc); result.Total = await fileAssetRepository.Get(specification).CountAsync(); result.Data = await fileAssetRepository.Paging(specification).Select(x => mapper.Map <FilePagingQueryDTO>(x)).ToListAsync(); return(result); }
public async Task <PagingQueryResult <DM_DayChiDTO> > GetList([FromQuery] int skipCount, [FromQuery] int maxCount, [FromQuery] string sortBy, [FromQuery] bool?ascSorting, [FromQuery] string thenSortBy, [FromQuery] string keyWord) { IQueryable <DM_DayChi> dM_DayChis = _db.DM_DayChis; if (!string.IsNullOrEmpty(keyWord)) { dM_DayChis = dM_DayChis.Where(p => p.Loai_DayChi.Contains(keyWord)); } var result = new PagingQueryResult <DM_DayChiDTO>(); result.Total = dM_DayChis.Count(); IOrderedQueryable <DM_DayChi> dM_DayChis1; if (string.IsNullOrEmpty(sortBy)) { sortBy = "Loai_Chi"; } if (maxCount <= 0) { maxCount = 50; } Expression <Func <DM_DayChi, object> > property_exp = ExpressionHelper.GetProperty <DM_DayChi>(sortBy); if (property_exp != null) { if (ascSorting ?? true) { dM_DayChis1 = dM_DayChis.OrderBy(property_exp); } else { dM_DayChis1 = dM_DayChis.OrderByDescending(property_exp); } if (!string.IsNullOrEmpty(thenSortBy)) { property_exp = ExpressionHelper.GetProperty <DM_DayChi>(thenSortBy); if (property_exp != null) { dM_DayChis1 = dM_DayChis1.ThenBy(property_exp); } } dM_DayChis = dM_DayChis1; } dM_DayChis = dM_DayChis.Skip(skipCount).Take(maxCount); result.Items = await _mapper.ProjectTo <DM_DayChiDTO>(dM_DayChis).ToListAsync(); return(result); }
public async Task <PagingQueryResult <KDV_TemDTO> > GetList([FromQuery] int skipCount, [FromQuery] int maxCount, [FromQuery] string sortBy, [FromQuery] bool?ascSorting, [FromQuery] string thenSortBy, [FromQuery] string keyWord) { IQueryable <KDV_Tem> kDV_Tems = _db.KDV_Tems; if (!string.IsNullOrEmpty(keyWord)) { //kDV_Chis = kDV_Chis.Where(p => p.KDV_ID.Contains(keyWord) || p.Serial.Contains(keyWord)); } var result = new PagingQueryResult <KDV_TemDTO>(); result.Total = kDV_Tems.Count(); IOrderedQueryable <KDV_Tem> kDV_Tems1; if (string.IsNullOrEmpty(sortBy)) { sortBy = "Name"; } if (maxCount <= 0) { maxCount = 50; } Expression <Func <KDV_Tem, object> > property_exp = ExpressionHelper.GetProperty <KDV_Tem>(sortBy); if (property_exp != null) { if (ascSorting ?? true) { kDV_Tems1 = kDV_Tems.OrderBy(property_exp); } else { kDV_Tems1 = kDV_Tems.OrderByDescending(property_exp); } if (!string.IsNullOrEmpty(thenSortBy)) { property_exp = ExpressionHelper.GetProperty <KDV_Tem>(thenSortBy); if (property_exp != null) { kDV_Tems1 = kDV_Tems1.ThenBy(property_exp); } } kDV_Tems = kDV_Tems1; } kDV_Tems = kDV_Tems.Skip(skipCount).Take(maxCount); result.Items = await _mapper.ProjectTo <KDV_TemDTO>(kDV_Tems).ToListAsync(); return(result); }
public async Task <PagingQueryResult <SolutionPagingQueryDTO> > Handle(SolutionPagingQuery request, CancellationToken cancellationToken) { request.CheckPagingParam(); var result = new PagingQueryResult <SolutionPagingQueryDTO>(); var specification = new SolutionPagingSpecification(identityService.GetUserId(), request.Page, request.PageSize, request.Search, request.OrderBy, request.Desc); result.Total = await solutionRepository.Get(specification).CountAsync(); result.Data = await solutionRepository.Paging(specification).Select(x => mapper.Map <SolutionPagingQueryDTO>(x)).ToListAsync(); return(result); }
public async Task <PagingQueryResult <CustomRolePagingQueryDTO> > Handle(CustomRolePagingQuery request, CancellationToken cancellationToken) { var result = new PagingQueryResult <CustomRolePagingQueryDTO>(); request.CheckPagingParam(); var specification = new CustomRolePagingSpecification(identityService.GetOrganizationId(), request.Page, request.PageSize, request.OrderBy, request.Desc, request.Search); result.Total = await customRoleRepository.Get(specification).CountAsync(); result.Data = await customRoleRepository.Paging(specification).Select(x => CustomRolePagingQueryDTO.From(x)).ToListAsync();; return(result); }
public async Task <PagingQueryResult <PackageMapPagingQueryDTO> > Handle(PackageMapPagingQuery request, CancellationToken cancellationToken) { var result = new PagingQueryResult <PackageMapPagingQueryDTO>(); request.CheckPagingParam(); var specification = new PackageMapPagingSpecification(request.Page, request.PageSize, request.Search, request.OrderBy, request.Desc); var datas = await packageMapRepository.Paging(specification).Select(x => new { x.Id, x.Package, x.ResourceId, x.ResourceType }).ToListAsync(); result.Total = await packageMapRepository.Get(specification).CountAsync(); result.Data = datas.Select(x => PackageMapPagingQueryDTO.From(x.Id, x.Package, x.ResourceId, x.ResourceType)).ToList(); return(result); }
public async Task <PagingQueryResult <IdentityPagingQueryDTO> > Handle(IdentityPagingQuery request, CancellationToken cancellationToken) { var result = new PagingQueryResult <IdentityPagingQueryDTO>(); request.CheckPagingParam(); var specification = new IdentityPagingSpecification(request.Page, request.PageSize, request.OrderBy, request.Desc, request.Search); result.Count = await identityRepository.Get(specification).CountAsync(); var datas = await identityRepository.Paging(specification).ToListAsync(); result.Items = mapper.Map <List <IdentityPagingQueryDTO> >(datas); return(result); }
public async Task <PagingQueryResult <CategoryPagingQueryDTO> > Handle(CategoryPagingQuery request, CancellationToken cancellationToken) { var result = new PagingQueryResult <CategoryPagingQueryDTO>(); request.CheckPagingParam(); var specification = new CategoryPagingSpecification(request.Page, request.PageSize, request.Search); var data = await categoryRepository.Paging(specification).ToListAsync(); result.Total = await categoryRepository.Get(specification).CountAsync(); result.Data = data.Select(x => mapper.Map <CategoryPagingQueryDTO>(x)).ToList(); return(result); }
public async Task <PagingQueryResult <TexturePagingQueryDTO> > Handle(TexturePagingQuery request, CancellationToken cancellationToken) { var result = new PagingQueryResult <TexturePagingQueryDTO>(); request.CheckPagingParam(); var clientOrganId = await clientAssetPermissionControlService.ClientAssetOrganIdRedirection(); var specification = new TexturePagingSpecification(clientOrganId, request.Page, request.PageSize, request.Search, request.OrderBy, request.Desc); var datas = await textureRepository.Paging(specification).Select(x => new { x.Id, x.Name, x.CreatedTime, x.ModifiedTime }).ToListAsync(); result.Total = await textureRepository.Get(specification).CountAsync(); result.Data = datas.Select(x => TexturePagingQueryDTO.From(x.Id, x.Name, x.CreatedTime, x.ModifiedTime)).ToList(); return(result); }
public async Task <PagingQueryResult <OrganizationTypePagingQueryDTO> > Handle(OrganizationTypePagingQuery request, CancellationToken cancellationToken) { var result = new PagingQueryResult <OrganizationTypePagingQueryDTO>(); var list = Enumeration.GetAll <OrganizationType>().ToList(); result.Total = list.Count; result.Data = list.Skip((request.Page - 1) * request.PageSize).Take(request.PageSize).Select(x => { var dto = new OrganizationTypePagingQueryDTO(); dto.Id = x.Id; dto.Name = appLocalizer[x.Name]; dto.Description = appLocalizer[x.Description]; return(dto); }).ToList(); return(await Task.FromResult(result)); }
public async Task <PagingQueryResult <StaticMeshPagingQueryDTO> > Handle(StaticMeshPagingQuery request, CancellationToken cancellationToken) { var result = new PagingQueryResult <StaticMeshPagingQueryDTO>(); request.CheckPagingParam(); var clientOrganId = await clientAssetPermissionControlService.ClientAssetOrganIdRedirection(); var yesTranslated = commonLocalizer["IsDefaultValue"]; var specification = new StaticMeshPagingSpecification(clientOrganId, request.Page, request.PageSize, request.Search); var datas = await staticMeshRepository.Paging(specification).Select(x => new { x.Id, x.Name, x.RelatedProductSpecIds, x.CreatedTime, x.ModifiedTime }).ToListAsync(); result.Total = await staticMeshRepository.Get(specification).CountAsync(); result.Data = datas.Select(x => StaticMeshPagingQueryDTO.From(x.Id, x.Name, string.IsNullOrWhiteSpace(x.RelatedProductSpecIds) ? "" : yesTranslated, x.CreatedTime, x.ModifiedTime)).ToList(); return(result); }
public async Task <PagingQueryResult <DialogFlowDto> > GetFlows() { var result = new PagingQueryResult <DialogFlowDto>(); result.Total = await _dbContext.KnowledgeMaps.CountAsync(m => m.IsDeleted == false); result.Data = _dbContext.KnowledgeMaps.Where(m => m.IsDeleted == false).Select(m => new DialogFlowDto { Id = m.Id, Name = m.Name, Key = m.Identifier, Remark = m.Remark, CreationTime = m.CreationTime }).OrderBy(d => d.CreationTime); return(result); }
public async Task <PagingQueryResult <RolePagingQueryDTO> > Handle(RolePagingQuery request, CancellationToken cancellationToken) { request.CheckPagingParam(); var result = new PagingQueryResult <RolePagingQueryDTO>(); var roles = Enumeration.GetAll <SystemRole>(); result.Total = roles.Count(); result.Data = roles.Skip((request.Page - 1) * request.PageSize).Take(request.PageSize).Select(x => { var dto = new RolePagingQueryDTO(); dto.Id = x.Id; dto.Name = appLocalizer[x.Name]; dto.Description = appLocalizer[x.Description]; dto.AccessPointKeys = x.AccessPointKeys; return(dto); }).ToList(); return(await Task.FromResult(result)); }
public async Task <PagingQueryResult <AccessPointPagingQueryDTO> > Handle(AccessPointPagingQuery request, CancellationToken cancellationToken) { var result = new PagingQueryResult <AccessPointPagingQueryDTO>(); request.CheckPagingParam(); var specification = new AccessPointPagingSpecification(request.Page, request.PageSize, request.OrderBy, request.Desc, request.Search, identityService.GetOrganizationTypeId()); var dtos = await accessPointRepository.Paging(specification).Select(x => AccessPointPagingQueryDTO.From(x)).ToListAsync(); for (var idx = dtos.Count - 1; idx >= 0; idx--) { var it = dtos[idx]; it.IsInnerName = it.IsInner == EntityStateConst.No ? "" : commonLocalizer["IsDefaultValue"]; it.Name = appLocalizer[it.Name]; } result.Total = await accessPointRepository.Get(specification).CountAsync(); result.Data = dtos; return(result); }
public async Task <PagingQueryResult <OrganizationPagingQueryDTO> > Handle(OrganizationPagingQuery request, CancellationToken cancellationToken) { var result = new PagingQueryResult <OrganizationPagingQueryDTO>(); request.CheckPagingParam(); var specification = new OrganizationPagingSpecification(identityService.GetOrganizationId(), request.Page, request.PageSize, request.OrderBy, request.Desc, request.Search); var dtos = await organizationRepository.Paging(specification).Select(x => OrganizationPagingQueryDTO.From(x)).ToListAsync(); //翻译组织类型名称 for (var idx = dtos.Count - 1; idx >= 0; idx--) { var it = dtos[idx]; var organType = Enumeration.FromValue <OrganizationType>(it.OrganizationTypeId); it.OrganizationTypeName = appLocalizer[organType.Name]; } result.Total = await organizationRepository.Get(specification).CountAsync(); result.Data = dtos; return(result); }
public async Task <PagingQueryResult <SLT_ChiDTO> > GetList([FromQuery] int skipCount, [FromQuery] int maxCount, [FromQuery] DateTime Date) { //IOrderedQueryable<SLT_Chi> sLT_Chis1; //IQueryable<SLT_Chi> sLT_Chis = _db.SLT_Chis; var pickedDate = Date.ToString("yyyy-MM-dd"); var sLT_Chis = await(from NQL_Chi in _db.NQL_Chis join kdv in _db.KDV_Chis on new { NQL_Chi.KDV_ID, NQL_Chi.Chi_ID } equals new { kdv.KDV_ID, kdv.Chi_ID } where NQL_Chi.Ngay_Cap_Phat.Date.ToString() == pickedDate select new SLT_ChiDTO { Ngay_Cap_Phat = NQL_Chi.Ngay_Cap_Phat, KDV_ID = NQL_Chi.KDV_ID, Chi_ID = NQL_Chi.Chi_ID, SoLuong = NQL_Chi.SoLuong, SoLuongChi = kdv.SoLuongChi, SoLuongChi_Huy = kdv.SoLuongChi_Huy }).ToListAsync(); //sLT_Chis = _db.SLT_Chis.Where(p => p.Ngay_Cap_Phat.Date == Date); var result = new PagingQueryResult <SLT_ChiDTO>(); result.Total = sLT_Chis.Count(); //sLT_Chis = sLT_Chis.Skip(skipCount).Take(maxCount); result.Items = sLT_Chis; // await _mapper.ProjectTo<SLT_ChiDTO>(sLT_Chis).ToListAsync(); foreach (SLT_ChiDTO item in result.Items) { item.SoLuongChi_Ton = item.SoLuong - item.SoLuongChi; } return(result); }
public async Task <PagingQueryResult <Log> > GetLogsAsync(List <int> levels, DateTime?start, DateTime?end, int offset = 0, int limit = 20) { var result = new PagingQueryResult <Log>(); var where = new StringBuilder(); var hasWhere = false; if (levels?.Count > 0) { var level = string.Join(",", levels); where.Append($"WHERE \"level\" IN({level}) "); hasWhere = true; } if (start.HasValue && end.HasValue) { if (hasWhere) { where.Append($"AND to_char(\"timestamp\",'YYYY-MM-DD') BETWEEN {start.Value.ToString("yyyy-MM-dd")} AND {end.Value.ToString("yyyy-MM-dd")}"); } else { where.Append($"WHERE to_char(\"timestamp\",'YYYY-MM-DD') BETWEEN {start.Value.ToString("yyyy-MM-dd")} AND {end.Value.ToString("yyyy-MM-dd")}"); } } var query = $"SELECT message, \"level\", \"timestamp\", \"exception\", log_event FROM system_logs {where} ORDER BY \"timestamp\" DESC OFFSET @offset LIMIT @limit"; var count = $"SELECT count(*) from system_logs {where}"; result.Data = await _dbContext.SqlQueryAsync <Log>(query, new { levels, offset, limit }); result.Total = await _dbContext.SqlQueryFirstOrDefaultAsync <int>(count, new { levels }); return(result); }
public async Task <PagingQueryResult <UserItemDto> > GetAllUserPagingQueryAsync(int pageIndex = 1, int pageSize = 10) { var result = new PagingQueryResult <UserItemDto>(); result.Total = await _context.Users.CountAsync(); var skip = (pageIndex - 1) * pageSize; var details = from user in (from user1 in _context.Users //orderby user1.UserName select user1).Skip(skip).Take(pageSize) join userrole in _context.UserRoles on user.Id equals userrole.UserId into ur_join from UR in ur_join.DefaultIfEmpty() join role in _context.Roles on UR.RoleId equals role.Id into r_join from R in r_join.DefaultIfEmpty() select new UserDetailDto { Id = user.Id, RoleName = R.NormalizedName, UserName = user.UserName, Email = user.Email, Nickname = user.Nickname }; var userRole = new Dictionary <string, List <string> >(); if (details != null) { foreach (var item in details) { if (userRole.ContainsKey(item.Id)) { userRole[item.Id].Add(item.RoleName ?? ""); } else { userRole.Add(item.Id, new List <string> { item.RoleName ?? "" }); } } } //var users = await details.Select(r => new UserItemDto //{ // Email = r.Email, // Id = r.Id, // UserName = r.UserName, // LockoutEnabled = r.LockoutEnabled, // Roles = userRole[r.Id], // Nickname = r.Nickname //}).GroupBy(u => u.Id) //.Select(g => g.First()) //.OrderBy(u => u.UserName) //.ToListAsync(); var users2 = from r in from u in from user in details select new UserItemDto { Email = user.Email, Id = user.Id, UserName = user.UserName, LockoutEnabled = user.LockoutEnabled, Roles = userRole[user.Id], Nickname = user.Nickname } group u by u.Id into g select g.First() orderby r.UserName select r; result.Data = users2; return(result); }