|
109 | 109 |
|
110 | 110 | public override async Task<object> ReadAsync(DataManagerRequest dataManagerRequest, string? key = null) |
111 | 111 | { |
112 | | - IEnumerable<Asset> dataSource = await _assetService!.GetAssetsAsync(); |
| 112 | + IEnumerable dataSource = await _assetService!.GetAssetsAsync(); |
113 | 113 |
|
114 | 114 | // Handling Search |
115 | 115 | if (dataManagerRequest.Search != null && dataManagerRequest.Search.Count > 0) |
|
129 | 129 | dataSource = DataOperations.PerformSorting(dataSource, dataManagerRequest.Sorted); |
130 | 130 | } |
131 | 131 |
|
132 | | - // Handling Aggregation |
133 | | - IDictionary<string, object>? aggregates = null; |
134 | | - if (dataManagerRequest.Aggregates != null) |
135 | | - { |
136 | | - aggregates = DataUtil.PerformAggregation(dataSource, dataManagerRequest.Aggregates); |
137 | | - //Add custom logic here if needed and remove above method |
138 | | - } |
139 | | - |
140 | | - |
141 | 132 | int totalRecordsCount = dataSource.Cast<Asset>().Count(); |
142 | 133 |
|
143 | | - // Handling Grouping |
144 | | - DataResult dataObject = new DataResult(); |
145 | | - |
146 | | - if (dataManagerRequest.Group != null) |
147 | | - { |
148 | | - IEnumerable ResultData = dataSource.ToList(); |
149 | | - foreach (var group in dataManagerRequest.Group) |
150 | | - { |
151 | | - ResultData = DataUtil.Group<Asset>(ResultData, group, dataManagerRequest.Aggregates, 0, dataManagerRequest.GroupByFormatter); |
152 | | - //Add custom logic here if needed and remove above method |
153 | | - } |
154 | | - dataObject.Result = ResultData; |
155 | | - dataObject.Count = totalRecordsCount; |
156 | | - dataObject.Aggregates = aggregates; |
157 | | - return dataManagerRequest.RequiresCounts ? dataObject : (object)ResultData; |
158 | | - } |
159 | | - |
160 | 134 | // Handling Paging |
161 | 135 | if (dataManagerRequest.Skip != 0) |
162 | 136 | { |
|
170 | 144 | //Add custom logic here if needed and remove above method |
171 | 145 | } |
172 | 146 |
|
| 147 | + //Handling Groping |
| 148 | + if (dataManagerRequest.Group != null) |
| 149 | + { |
| 150 | + foreach (var group in dataManagerRequest.Group) |
| 151 | + { |
| 152 | + dataSource = DataUtil.Group<Asset>(dataSource, group, dataManagerRequest.Aggregates, 0, dataManagerRequest.GroupByFormatter); |
| 153 | + //Add custom logic here if needed and remove above method |
| 154 | + } |
| 155 | + } |
| 156 | + |
173 | 157 | return dataManagerRequest.RequiresCounts |
174 | 158 | ? new DataResult() { Result = dataSource, Count = totalRecordsCount } |
175 | 159 | : (object)dataSource; |
|
0 commit comments