Exemplo n.º 1
0
        private async Task LoadData(int pageNumber, int pageSize)
        {
            var request = new GetAllPagedDocumentsRequest {
                PageSize = pageSize, PageNumber = pageNumber + 1
            };
            var response = await _documentManager.GetAllAsync(request);

            if (response.Succeeded)
            {
                totalItems  = response.TotalCount;
                currentPage = response.CurrentPage;
                var data = response.Data;
                data = data.Where(element =>
                {
                    if (string.IsNullOrWhiteSpace(searchString))
                    {
                        return(true);
                    }
                    if (element.Title.Contains(searchString, StringComparison.OrdinalIgnoreCase))
                    {
                        return(true);
                    }
                    if (element.Description.Contains(searchString, StringComparison.OrdinalIgnoreCase))
                    {
                        return(true);
                    }
                    return(false);
                }).ToList();
                pagedData = data;
            }
            else
            {
                foreach (var message in response.Messages)
                {
                    _snackBar.Add(localizer[message], Severity.Error);
                }
            }
        }
Exemplo n.º 2
0
        private async Task LoadData(int pageNumber, int pageSize, TableState state)
        {
            var request = new GetAllPagedDocumentsRequest {
                PageSize = pageSize, PageNumber = pageNumber + 1
            };
            var response = await _documentManager.GetAllAsync(request);

            if (response.Succeeded)
            {
                totalItems  = response.TotalCount;
                currentPage = response.CurrentPage;
                var data       = response.Data;
                var loadedData = data.Where(element =>
                {
                    if (string.IsNullOrWhiteSpace(searchString))
                    {
                        return(true);
                    }
                    if (element.Title.Contains(searchString, StringComparison.OrdinalIgnoreCase))
                    {
                        return(true);
                    }
                    if (element.Description.Contains(searchString, StringComparison.OrdinalIgnoreCase))
                    {
                        return(true);
                    }
                    return(false);
                });
                switch (state.SortLabel)
                {
                case "documentIdField":
                    loadedData = loadedData.OrderByDirection(state.SortDirection, d => d.Id);
                    break;

                case "documentTitleField":
                    loadedData = loadedData.OrderByDirection(state.SortDirection, d => d.Title);
                    break;

                case "documentDescriptionField":
                    loadedData = loadedData.OrderByDirection(state.SortDirection, d => d.Description);
                    break;

                case "documentIsPublicField":
                    loadedData = loadedData.OrderByDirection(state.SortDirection, d => d.IsPublic);
                    break;

                case "documentDateCreatedField":
                    loadedData = loadedData.OrderByDirection(state.SortDirection, d => d.CreatedOn);
                    break;

                case "documentOwnerField":
                    loadedData = loadedData.OrderByDirection(state.SortDirection, d => d.CreatedBy);
                    break;
                }
                data      = loadedData.ToList();
                pagedData = data;
            }
            else
            {
                foreach (var message in response.Messages)
                {
                    _snackBar.Add(localizer[message], Severity.Error);
                }
            }
        }
Exemplo n.º 3
0
        public async Task <PaginatedResult <GetAllDocumentsResponse> > GetAllAsync(GetAllPagedDocumentsRequest request)
        {
            var response = await _httpClient.GetAsync(Routes.DocumentsEndpoints.GetAllPaged(request.PageNumber, request.PageSize));

            return(await response.ToPaginatedResult <GetAllDocumentsResponse>());
        }