Exemplo n.º 1
0
        private static async Task LoadTaxSchedules(List <IMunicipalityTaxScheduleModel> taxSchedules, string connectionString)
        {
            var optionsBuilder = new DbContextOptionsBuilder <MunicipalityTaxScheduleDbContext>();

            optionsBuilder.UseSqlServer(connectionString);
            var context = new MunicipalityTaxScheduleDbContext(optionsBuilder.Options);
            var businessMunicipalityTaxScheduleUpdaterEngine = new BusinessMunicipalityTaxScheduleUpdaterEngine(
                new ResourceMunicipalityTaxScheduleEngine(context)
                );

            // TODO load in transaction
            // TODO create bulk-load method in ResourceAccess engine
            foreach (var taxSchedule in taxSchedules)
            {
                UpdateMunicipalityTaxStatus status = (await businessMunicipalityTaxScheduleUpdaterEngine.UpdateMunicipalityTax(
                                                          new UpdateMunicipalityTaxRequest
                {
                    MunicipalityTaxSchedule = taxSchedule
                })).Status;
                if (status != UpdateMunicipalityTaxStatus.OK)
                {
                    throw new ApplicationException($"Illegal input {JsonSerializer.Serialize<IMunicipalityTaxScheduleModel>(taxSchedule)}");
                }
            }
        }
Exemplo n.º 2
0
 public UpdateTaxTest()
 {
     businessMunicipalityTaxScheduleuUpdaterEngine = new BusinessMunicipalityTaxScheduleUpdaterEngine(
         new ResourceMunicipalityTaxScheduleEngineMock()
         );
 }