public RecruitCardGroup ImportRecruitCardGroup(RecruitShortUIModel recruitShortUIModel) { if (recruitShortUIModel == null) { throw new ArgumentNullException(nameof(recruitShortUIModel)); } var importFileReader = new ImportFileReader(recruitShortUIModel.FilePath); var words = importFileReader.ReadAllWords(); RecruitIndex idxFromRecruitShortUIModel = new RecruitIndex(recruitShortUIModel.Surname, recruitShortUIModel.Name, recruitShortUIModel.Patronymic, recruitShortUIModel.RegionalCollectionPoint); RecruitIndex firstIdxFromImportedFile = GetFirstRecruitIdxFromImportedFile(words); RecruitIndex secondIdxFromImportedFile = GetSecondRecruitIdxFromImportedFile(words); bool isFirstRecruit = idxFromRecruitShortUIModel == firstIdxFromImportedFile; bool isSecondRecruit = idxFromRecruitShortUIModel == secondIdxFromImportedFile; if (isFirstRecruit && isSecondRecruit) { var index = idxFromRecruitShortUIModel.ToString(); var msg = $"File with path: {recruitShortUIModel.FilePath} have not recruit: {index}"; throw new ArgumentException(msg); } return(CreateCardGroup(words, isFirstRecruit)); }
private RecruitIndex GetSecondRecruitIdxFromImportedFile(string[] words) { RecruitIndex secondIdxFromImportedFile = null; if (IsExistsSecondRecruit(words[64])) { secondIdxFromImportedFile = new RecruitIndex(surname: words[64], name: words[65], patronymic: words[66], regionalCollectionPoint: GetRegionalCollectionPoint(words, isFirstRecruit: false)); } return(secondIdxFromImportedFile); }
private RecruitIndex GetFirstRecruitIdxFromImportedFile(string[] words) { RecruitIndex firstIdxFromImportedFile = null; if (IsExistsSecondRecruit(words[1])) { firstIdxFromImportedFile = new RecruitIndex(surname: words[1], name: words[2], patronymic: words[3], regionalCollectionPoint: GetRegionalCollectionPoint(words, isFirstRecruit: true)); } return(firstIdxFromImportedFile); }