Пример #1
0
        private async Task <int> ImportCustodians(FbConnection fbConnection, EcfTableReader ecfTableReader)
        {
            var recordCounter = 0;

            while (ecfTableReader.ReadAsync().Result > 0)
            {
                // read needed field-values
                var ecfId = ecfTableReader.GetValue <string>("Id");

                DbResult dbResult = await RecordExists.ByGuidExtern(fbConnection, MappingTables.Map(_currentCsv), _tenantId, ecfId);

                if (dbResult.Success)
                {
                    // UPDATE
                    await RecordUpdate.Custodian(fbConnection, ecfTableReader, _tenantId, (int)dbResult.Value);
                }
                else
                {
                    // INSERT
                    await RecordInsert.Custodian(fbConnection, ecfTableReader, _tenantId);
                }

                recordCounter += 1;
            }

            return(await Task.FromResult(recordCounter));
        }
Пример #2
0
            static async void InsertSchoolClassAndTerm(FbConnection fbConnection, EcfTableReader ecfTableReader, int tenantId, int schoolTermId, string classTermId)
            {
                DbResult SchoolClassResult = await RecordInsert.SchoolClass(fbConnection, ecfTableReader, tenantId);

                if (SchoolClassResult.Success)
                {
                    await RecordInsert.SchoolClassTerm(fbConnection, tenantId, (int)SchoolClassResult.Value, schoolTermId, classTermId, ecfTableReader);
                }
                else
                {
                    Console.WriteLine("[ERROR] [SchoolClass] could not be inserted");
                }
            }