@@ -116,7 +116,7 @@ public interface IDataverseRepository
116
116
Task < ( IEnumerable < PopulationCentre > populationCentres , bool ? moreData , string nextPage ) > GetPopulationCentres ( Guid calculatorId , string ? nextPage ) ;
117
117
Task CreateAccbIncomesBatchAsync ( IEnumerable < JsonObject > accbs ) ;
118
118
Task < IEnumerable < ScoreCategory > > CreateScoreCategoriesBatchAsync ( IEnumerable < JsonObject > categories ) ;
119
- Task AssociateSchoolDistrictsBatchAsync ( IEnumerable < JsonObject > schoolDistricts , Guid calculatorId ) ;
119
+ Task CreateSchoolDistrictsBatchAsync ( IEnumerable < JsonObject > schoolDistricts , Guid calculatorId ) ;
120
120
Task < Guid > CreateScoreCalculatorAsync ( JsonObject scoreCalculator ) ;
121
121
Task CreateScoreParametersBatchAsync ( IEnumerable < JsonObject > parameters ) ;
122
122
Task CreateThresholdFeesBatchAsync ( IEnumerable < JsonObject > fees ) ;
@@ -386,32 +386,20 @@ public async Task<IEnumerable<ScoreCategory>> CreateScoreCategoriesBatchAsync(IE
386
386
return response . Result . Select ( x => new ScoreCategory ( x ) ) ;
387
387
388
388
}
389
- public async Task AssociateSchoolDistrictsBatchAsync ( IEnumerable < JsonObject > schoolDistricts , Guid calcId )
389
+ public async Task CreateSchoolDistrictsBatchAsync ( IEnumerable < JsonObject > schoolDistricts , Guid calcId )
390
390
{
391
391
if ( schoolDistricts == null || ! schoolDistricts . Any ( ) )
392
392
return ;
393
-
394
- var calculator = await d365WebApiService . SendRetrieveRequestAsync ( appUserService . AZSystemAppUser , $ "ofm_application_score_calculators({ calcId } )") ;
395
- if ( ! calculator . IsSuccessStatusCode )
396
- {
397
- var responseBody = await calculator . Content . ReadAsStringAsync ( ) ;
398
- throw new Exception ( $ "AssociateSchoolDistrictsBatchAsync(Guid { calcId } ): HTTP Failure: { responseBody } ") ;
399
- }
400
-
401
-
402
393
var batchRequests = schoolDistricts . Select ( x =>
403
394
{
404
- var association = new JsonObject ( ) ;
405
- association [ "@odata.id" ] = calculator ? . RequestMessage ? . RequestUri ? . AbsoluteUri ;
406
- var requestUri = $ "ofm_school_districts({ x . GetPropertyValue < Guid > ( "ofm_school_districtid" ) } )/ofm_application_score_calculator_ofm_school_district_ofm_school_district/$ref";
407
- return new CreateRequest ( requestUri , association ) ;
395
+ return new CreateRequest ( "ofm_school_districts" , x ) ;
408
396
}
409
397
) . ToList < HttpRequestMessage > ( ) ;
410
398
411
399
var response = await d365WebApiService . SendBatchMessageAsync ( appUserService . AZSystemAppUser , batchRequests , null ) ;
412
400
if ( ! response . CompletedWithNoErrors )
413
401
{
414
- throw new Exception ( $ "Upsert of Application Score failed: Batch HTTP Failure: { string . Join ( " | " , response . Errors ) } ") ;
402
+ throw new Exception ( $ "Create of School District failed: Batch HTTP Failure: { string . Join ( " | " , response . Errors ) } ") ;
415
403
}
416
404
}
417
405
public async Task < Guid > CreateScoreCalculatorAsync ( JsonObject scoreCalculator )
@@ -439,7 +427,7 @@ public async Task CreateScoreParametersBatchAsync(IEnumerable<JsonObject> parame
439
427
var response = await d365WebApiService . SendBatchMessageAsync ( appUserService . AZSystemAppUser , batchRequests , null ) ;
440
428
if ( ! response . CompletedWithNoErrors )
441
429
{
442
- throw new Exception ( $ "Upsert of Application Score failed: Batch HTTP Failure: { string . Join ( " | " , response . Errors ) } ") ;
430
+ throw new Exception ( $ "Upsert of Application Score Parameter failed: Batch HTTP Failure: { string . Join ( " | " , response . Errors ) } ") ;
443
431
}
444
432
}
445
433
public async Task CreateThresholdFeesBatchAsync ( IEnumerable < JsonObject > fees )
@@ -450,7 +438,7 @@ public async Task CreateThresholdFeesBatchAsync(IEnumerable<JsonObject> fees)
450
438
var response = await d365WebApiService . SendBatchMessageAsync ( appUserService . AZSystemAppUser , batchRequests , null ) ;
451
439
if ( ! response . CompletedWithNoErrors )
452
440
{
453
- throw new Exception ( $ "Upsert of Application Score failed: Batch HTTP Failure: { string . Join ( " | " , response . Errors ) } ") ;
441
+ throw new Exception ( $ "Upsert of Threshold fees failed: Batch HTTP Failure: { string . Join ( " | " , response . Errors ) } ") ;
454
442
}
455
443
}
456
444
public async Task CreatePopulationCentresBatchAsync ( IEnumerable < JsonObject > centres )
@@ -462,7 +450,7 @@ public async Task CreatePopulationCentresBatchAsync(IEnumerable<JsonObject> cent
462
450
var response = await d365WebApiService . SendBatchMessageAsync ( appUserService . AZSystemAppUser , batchRequests , null ) ;
463
451
if ( ! response . CompletedWithNoErrors )
464
452
{
465
- throw new Exception ( $ "Upsert of Application Score failed: Batch HTTP Failure: { string . Join ( " | " , response . Errors ) } ") ;
453
+ throw new Exception ( $ "Upsert of Population Centres failed: Batch HTTP Failure: { string . Join ( " | " , response . Errors ) } ") ;
466
454
}
467
455
}
468
456
0 commit comments