private async Task <int> ExportStudentSchoolClassAttendances(CsvTableReader csvTableReader, EcfTableWriter ecfTableWriter, string[] ecfHeaders)
        {
            var ecfRecordCounter = 0;

            await csvTableReader.ReadHeadersAsync();

            if (ecfHeaders != null && ecfHeaders.Length > 0)
            {
                await ecfTableWriter.WriteHeadersAsync(ecfHeaders);
            }
            else
            {
                await ecfTableWriter.WriteHeadersAsync(
                    EcfHeaders.StudentId,
                    EcfHeaders.SchoolClassId);
            }

            while (await csvTableReader.ReadAsync() > 0)
            {
                var student     = new CsvExportStudent(csvTableReader);
                var schoolClass = new CsvExportSchoolClass(csvTableReader);

                if (!string.IsNullOrEmpty(schoolClass.Id))
                {
                    ecfTableWriter.TrySetValue(EcfHeaders.StudentId, student.Id);
                    ecfTableWriter.TrySetValue(EcfHeaders.SchoolClassId, schoolClass.Id);

                    await ecfTableWriter.WriteAsync();

                    ecfRecordCounter++;
                }
            }

            return(ecfRecordCounter);
        }
        private async Task <int> ExportStudents(CsvTableReader csvTableReader, EcfTableWriter ecfTableWriter, string[] ecfHeaders)
        {
            var ecfCache         = new HashSet <string>();
            var ecfRecordCounter = 0;

            await csvTableReader.ReadHeadersAsync();

            if (ecfHeaders != null && ecfHeaders.Length > 0)
            {
                await ecfTableWriter.WriteHeadersAsync(ecfHeaders);
            }
            else
            {
                await ecfTableWriter.WriteHeadersAsync(
                    EcfHeaders.Id,
                    EcfHeaders.LastName,
                    EcfHeaders.FirstName,
                    EcfHeaders.Gender,
                    EcfHeaders.Birthdate);
            }

            while (await csvTableReader.ReadAsync() > 0)
            {
                var student = new CsvExportStudent(csvTableReader);

                if (!ecfCache.Contains(student.Id))
                {
                    ecfTableWriter.TrySetValue(EcfHeaders.Id, student.Id);
                    ecfTableWriter.TrySetValue(EcfHeaders.LastName, student.LastName);
                    ecfTableWriter.TrySetValue(EcfHeaders.FirstName, student.FirstName);
                    ecfTableWriter.TrySetValue(EcfHeaders.Gender, student.Gender);
                    ecfTableWriter.TrySetValue(EcfHeaders.Birthdate, student.BirthDate);

                    await ecfTableWriter.WriteAsync();

                    ecfCache.Add(student.Id);
                    ecfRecordCounter++;
                }
            }

            return(ecfRecordCounter);
        }
        private async Task <int> ExportStudentSubjects(CsvTableReader csvTableReader, EcfTableWriter ecfTableWriter, string[] ecfHeaders)
        {
            var ecfRecordCounter = 0;

            await csvTableReader.ReadHeadersAsync();

            if (ecfHeaders != null && ecfHeaders.Length > 0)
            {
                await ecfTableWriter.WriteHeadersAsync(ecfHeaders);
            }
            else
            {
                await ecfTableWriter.WriteHeadersAsync(
                    EcfHeaders.StudentId,
                    EcfHeaders.SchoolClassId,
                    EcfHeaders.SubjectId,
                    EcfHeaders.TeacherId);
            }

            while (await csvTableReader.ReadAsync() > 0)
            {
                var student     = new CsvExportStudent(csvTableReader);
                var schoolClass = new CsvExportSchoolClass(csvTableReader);

                if (csvTableReader.TryGetValue("Alle Lehrkräfte (Kürzel) mit Fach", out var value))
                {
                    var csvLineParser = new CsvLineParser(',');

                    var subValues = csvLineParser.Read(value);

                    csvLineParser.Configuration.Separator = ' ';

                    foreach (var subValue in subValues)
                    {
                        if (!string.IsNullOrEmpty(subValue))
                        {
                            var subValueParts = csvLineParser.Read(subValue.Trim());
                            if (subValueParts.Length == 2)
                            {
                                var teacherCode = subValueParts[0];
                                var subjectCode = subValueParts[1];

                                if (!string.IsNullOrEmpty(subjectCode))
                                {
                                    ecfTableWriter.TrySetValue(EcfHeaders.StudentId, student.Id);
                                    ecfTableWriter.TrySetValue(EcfHeaders.SchoolClassId, schoolClass.Id);
                                    ecfTableWriter.TrySetValue(EcfHeaders.SubjectId, subjectCode);
                                    ecfTableWriter.TrySetValue(EcfHeaders.TeacherId, teacherCode);

                                    await ecfTableWriter.WriteAsync();

                                    ecfRecordCounter++;
                                }
                            }
                        }
                    }
                }
            }

            return(ecfRecordCounter);
        }