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));
        }
Exemple #2
0
/*
 *      public static bool GetSchoolTermParts(string schoolTermId, out string validFrom, out string validTo)
 *      {
 *          string[] schoolTermParts = schoolTermId.Split('-');
 *          validFrom = null;
 *          validTo = null;
 *
 *          if (schoolTermParts.Length == 2)
 *          {
 *              int year = -1;
 *              int section = -1;
 *
 *              if (!String.IsNullOrEmpty(schoolTermParts[0]))
 *              {
 *                  year = int.Parse(schoolTermParts[0]);
 *              }
 *
 *              if (!String.IsNullOrEmpty(schoolTermParts[1]))
 *              {
 *                  section = int.Parse(schoolTermParts[1]);
 *              }
 *
 *              switch (section)
 *              {
 *                  case 1:
 *                      validFrom = $"01.08.{year}";
 *                      validTo = $"31.01.{year + 1}";
 *                      break;
 *                  case 2:
 *                      validFrom =$"01.02.{year + 1}";
 *                      validTo = $"31.07.{year + 1}";
 *                      break;
 *              }
 *
 *              return true;
 *          }
 *
 *          return false;
 *      }
 *
 */
        public static async Task <DbResult> GetSubject(FbConnection fbConnection, Dictionary <string, int> subjects, string code)
        {
            if (subjects.TryGetValue(code, out int id))
            {
                return(new DbResult(true, id));
            }
            else
            {
                DbResult dbResult = await RecordExists.ByCode(fbConnection, MappingTables.Map("ForeignLanguages"), code);

                return(dbResult);
            }
        }