public async Task RunAsync() { await foreach (var documentCollectionItem in _documentCollectionRepository.GetAllItemsAsync()) { var query = new ApiQueryRequest { Filter = $"{common.ImageIds}~{All}~{documentCollectionItem.Id}" }; var count = await _animalRepository.GetCountAsync(query.ToDbQuery()); if (count == 0) { count = await _articleRepository.GetCountAsync(query.ToDbQuery()); } if (count == 0) { foreach (var fileId in documentCollectionItem.TypeNameToDocumentId.Values) { await _bucket.RemoveFileAsync(fileId); _logger.LogInformation($"Deleted file from 'bucket' with id: {fileId}"); } await _documentCollectionRepository.DeleteAsync(documentCollectionItem.Id); _logger.LogInformation($"Deleted item from 'document collection' with id: {documentCollectionItem.Id}"); } } }
public async Task <ActionResult <CollectionApiResponse <RecipeShortModel> > > GetRecipesAsync( [FromQuery] ApiQueryRequest request) { var result = await Mediator.Send(new GetRecipeListCommand { Request = request }); return(Ok(result)); }
protected async Task<ActionResult<CollectionSegmentApiResponse<TResponse>>> GetCollectionAsync<TCollectin, TResponse>( IBlCollectinQueryAsync<TCollectin> service, ApiQueryRequest queryRequest, IMapper mapper) where TResponse : class { BlCollectonResponse<TCollectin> serviceResponse = await service.GetAsync(queryRequest); List<TResponse> result = mapper.Map<List<TCollectin>, List<TResponse>>(serviceResponse.Collection); return Collection(result, serviceResponse.TotalCount, queryRequest.Page, queryRequest.Size); }
public async Task <BlCollectonResponse <TEntityDto> > GetAsync(ApiQueryRequest queryRequest) { var dbQuery = queryRequest.ToDbQuery(); var count = await _repository.GetCountAsync(dbQuery); List <TEntityDto> itemDtos = await GetCollectionAsync(count, dbQuery); return(new BlCollectonResponse <TEntityDto> { Collection = itemDtos, TotalCount = count }); }
public static DbQuery ToDbQuery(this ApiQueryRequest apiQueryRequest) { var isNotDeletedExpr = $"{baseItem.IsDeleted}~{StrictFilterContractConstants.Eq}~'false'"; var filter = string.IsNullOrWhiteSpace(apiQueryRequest.Filter) ? isNotDeletedExpr : $"{isNotDeletedExpr};{apiQueryRequest.Filter}"; return(new DbQuery { Filter = filter, Page = apiQueryRequest.Page, Size = apiQueryRequest.Size, Sort = apiQueryRequest.Sort }); }
public async Task <BlCollectonResponse <RequestDto> > GetAsync(ApiQueryRequest queryRequest, ICollection <Claim> roles) { var initStatuses = GetQueryStatuses(queryRequest.Filter, $"status.id~{StrictFilterContractConstants.Eq}~"); var dbQuery = queryRequest.ToDbQuery(); var isAdmin = IsRoleAdmin(roles); if (!isAdmin) { List <string> requestStatuses = GetRequestStatuses(roles, actions.Get); foreach (var initStatus in initStatuses) { var isContain = requestStatuses.Contains(initStatus); if (!isContain) { throw new ForbiddenOperationRequestException(_messageForbiddenFields); } } string filterExpr = string.Empty; if (requestStatuses.Count > 0) { filterExpr = string.Join("OR", requestStatuses.Select(x => @"{status.id~" + StrictFilterContractConstants.Eq + "~'" + x + "'}").ToList()); dbQuery.Filter = filterExpr; } else { throw new ForbiddenOperationRequestException(_messageMissingRole); } } var count = await _repository.GetCountAsync(dbQuery); var filteredByRoleItems = await GetCollectionAsync(count, dbQuery); return(new BlCollectonResponse <RequestDto> { Collection = filteredByRoleItems, TotalCount = count }); }
private async Task <CollectionApiResponse <RecipeShortModel> > GetRecipeShortModels( ApiQueryRequest request, CancellationToken cancellationToken) { var parentId = request.ParentId?.ToString(); var page = await _applicationDbContext.Set <Recipe>() .Where(x => x.ParentId == parentId) .OrderBy(x => x.Title) .Select(x => new RecipeShortModel { Id = x.Id, ParentId = x.ParentId, Title = x.Title, CreatedAt = x.CreatedAt }) .GetPageAsync(request, cancellationToken); return(page); }
public async Task <int> GetCountAsync(ApiQueryRequest query) { var dbQuery = query.ToDbQuery(); return(await _repository.GetCountAsync(dbQuery)); }
public static async Task <CollectionApiResponse <T> > GetPageAsync <T>(this IQueryable <T> source, ApiQueryRequest request, CancellationToken cancellationToken) { return(await GetPageAsync(source, request.Page, request.Size, cancellationToken)); }
public async Task <ActionResult <CollectionSegmentApiResponse <RequestModel> > > GetAsync([FromQuery] ApiQueryRequest queryRequest) { var roles = GetUserRoles(); var serviceResponse = await _requestService.GetAsync(queryRequest, roles); List <RequestModel> result = _mapper.Map <List <RequestDto>, List <RequestModel> >(serviceResponse.Collection); return(Collection(result, serviceResponse.TotalCount, queryRequest.Page, queryRequest.Size)); }
public async Task <BlCollectonResponse <RequestDto> > GetAsync(ApiQueryRequest queryRequest, ICollection <Claim> roles) => await requestService.GetAsync(queryRequest, roles);
public async Task <ActionResult <CollectionSegmentApiResponse <FinancialReportModel> > > GetAsync([FromQuery] ApiQueryRequest queryRequest) { return(await GetCollectionAsync <FinancialReportDto, FinancialReportModel>(_financialReportService, queryRequest, _mapper)); }
public async Task <BlCollectonResponse <TOut> > GetAsync(ApiQueryRequest query) => await fullCrudService.GetAsync(query);
public async Task <ActionResult <CollectionSegmentApiResponse <TagModel> > > GetAsync([FromQuery] ApiQueryRequest queryRequest) { return(await GetCollectionAsync <TagDto, TagModel>(_tagService, queryRequest, _mapper)); }
public virtual async Task <BlCollectonResponse <GetUsersManagementViewModel> > GetAsync(ApiQueryRequest queryRequest) { var dbQuery = queryRequest.ToDbQuery(); var users = await _userRepository.GetAsync(dbQuery); var totalNumberOf = await _userRepository.GetCountAsync(dbQuery); var userCollection = _mapper.Map <IEnumerable <ApplicationUser>, List <GetUsersManagementViewModel> >(users); foreach (var userModel in userCollection) { var identityUser = users.SingleOrDefault(x => x.Id == userModel.UserId); userModel.Roles.AddRange(await _userManager.GetRolesAsync(identityUser)); } return(new BlCollectonResponse <GetUsersManagementViewModel> { Collection = userCollection, TotalCount = totalNumberOf }); }
public async Task <ActionResult <List <FinancialReportByYearDto> > > GetYearsAsync([FromQuery] ApiQueryRequest queryRequest) { return(Item(await _financialReportService.GetReportsByYearsAsync())); }
public async Task <BlCollectonResponse <GetDocumentsOrganizationViewItem> > GetAsync(ApiQueryRequest queryRequest) { var dbQuery = queryRequest.ToDbQuery(); var files = await _orgDocRepository.GetAsync(dbQuery); var totalNumberOf = await _orgDocRepository.GetCountAsync(dbQuery); var result = files.Select(x => new GetDocumentsOrganizationViewItem { Id = x.BucketId, FileName = x.Name }).ToList(); return(new BlCollectonResponse <GetDocumentsOrganizationViewItem> { Collection = result, TotalCount = totalNumberOf }); }
GetDocuments([FromQuery] ApiQueryRequest queryRequest) { var source = await _organizationDocumentsService.GetAsync(queryRequest); return(Collection(source.Collection, source.TotalCount, queryRequest.Page, queryRequest.Size)); }
public async Task <ActionResult <CollectionSegmentApiResponse <HistoryModel> > > GetAsync([FromQuery] ApiQueryRequest queryRequest) { return(await GetCollectionAsync <HistoryDto, HistoryModel>(service, queryRequest, mapper)); }
public async Task <ActionResult <CollectionSegmentApiResponse <GetUsersManagementViewModel> > > GetAsync([FromQuery] ApiQueryRequest queryParams) { var source = await _usersManagementService.GetAsync(queryParams); return(Collection(source.Collection, source.TotalCount, queryParams.Page, queryParams.Size)); }
public async Task <int> GetCountAsync(ApiQueryRequest query) => await fullCrudService.GetCountAsync(query);
public async Task <ActionResult <CollectionSegmentApiResponse <VacancyModel> > > GetAsync([FromQuery] ApiQueryRequest queryRequest) { return(await GetCollectionAsync <VacancyDto, VacancyModel>(_vacancyService, queryRequest, _mapper)); }