public async Task UpdateDatabase(TestDataModel project, UpdateTypeEnum updateType) { try { UpdateDataRequest request = new UpdateDataRequest() { Project = project, UpdateType = new UpdateTypeModel() { Type = updateType } }; var response = (await TestDataServiceClient.UpdateDataRecordAsync(request)); if (!response.Result.IsValid) { _message = new MessageWindowModel() { Title = "Server error updating Data", Message = response.Result.ErrorMessage, }; } // Refresh the Grid await ReadHandler(_lastArgs); } catch (Exception ex) { _message = new MessageWindowModel() { Title = "Error Updating Data", Message = ExHelper.GetExceptionText(ex), }; } }
/// <summary> /// The Grid Read Handler /// The DataSourceRequest is serialised and the sent to the service /// The response is processed. /// The structure is flat without grouping and passed to the grid. /// Grouped data is processed to produce the required structure for the grid. /// The callback function below is used for the grouping. /// </summary> /// <param name="args"></param> /// <returns></returns> private async Task ReadHandler(GridReadEventArgs args) { try { _lastArgs = args; // Use the following lines to add the Token //CallOptions options = await GrpcBearerTokenProvider.GetCallOptionsAsync(); //var dataListResponse = (await TestDataServiceClient.GetTestDataAsync(new DataSourceProtoRequest(args.Request), options)); var dataListResponse = (await TestDataServiceClient.GetTestDataAsync(new DataSourceProtoRequest(args.Request))); if (dataListResponse.Result.IsValid) { TotalRecords = dataListResponse.Result.TotalRecords; if (dataListResponse.GridData.SubGroups.Count == 0) { // Process the flat item list var gridData = dataListResponse.GridData.GridRows.Unpack <TestDataListModel>(); GridData = gridData.Records.ToList(); } else { // Process the grouped data GridData = GridHelper.GetGroupedData(dataListResponse.GridData.SubGroups.ToList(), new DataListModelCallBack(UnpackProtoList)); } } else { // Show Error message _message = new MessageWindowModel() { Title = "Server error getting Test Data", Message = dataListResponse.Result.ErrorMessage, }; } StateHasChanged(); } catch (Exception ex) { // Show Error message _message = new MessageWindowModel() { Title = "Error getting Test Data", Message = ExHelper.GetExceptionText(ex) }; } }