Example #1
0
        private static ContractTypesTableColumnStructure ParseContractTypesTableStructure(Table contractTypes)
        {
            var structure = new ContractTypesTableColumnStructure();

            for (var c = 0; c < contractTypes.Header.Count; c++)
            {
                var header = contractTypes.Header.ElementAt(c);
                switch (header)
                {
                case "contract type":
                    structure.ContractTypeIndex = c;
                    break;

                case "date from":
                    structure.DateFromIndex = c;
                    break;

                case "date to":
                    structure.DateToIndex = c;
                    break;

                default:
                    throw new ArgumentException($"Unexpected column in contract types table: {header}");
                }
            }

            if (structure.ContractTypeIndex == -1)
            {
                throw new ArgumentException("Contract types table is missing contract type column");
            }
            if (structure.DateFromIndex == -1)
            {
                throw new ArgumentException("Contract types table is missing date from column");
            }
            if (structure.DateToIndex == -1)
            {
                throw new ArgumentException("Contract types table is missing date to column");
            }

            return(structure);
        }
Example #2
0
 private static ContractTypeReferenceData ParseContractTypeTableRow(TableRow row, ContractTypesTableColumnStructure structure)
 {
     return(new ContractTypeReferenceData
     {
         ContractType = (ContractType)row.ReadRowColumnValue <string>(structure.ContractTypeIndex, "contract type").ToEnumByDescription(typeof(ContractType)),
         DateFrom = row.ReadRowColumnValue <DateTime>(structure.DateFromIndex, "date from"),
         DateTo = row.ReadRowColumnValue <DateTime>(structure.DateToIndex, "date to")
     });
 }