private static Organisation ConvertToOrganisation(PublicSectorOrganisation publicSectorOrganisation) { return(new Organisation { Address = new Address { Line1 = publicSectorOrganisation.AddressLine1, Line2 = publicSectorOrganisation.AddressLine2, Line3 = publicSectorOrganisation.AddressLine3, Line4 = publicSectorOrganisation.AddressLine4, Line5 = publicSectorOrganisation.AddressLine5, Postcode = publicSectorOrganisation.PostCode }, Name = publicSectorOrganisation.Name, Sector = publicSectorOrganisation.Sector, Code = publicSectorOrganisation.OrganisationCode, RegistrationDate = null, Type = OrganisationType.PublicSector, SubType = (OrganisationSubType)Enum.Parse(typeof(OrganisationSubType), publicSectorOrganisation.Source.ToString()) }); }
public List <PublicSectorOrganisation> ReadNhsFile(string fileName) { var publicSectorOrganisationList = new List <PublicSectorOrganisation>(); using (var stream = _fileSystem.FileInfo.FromFileName(fileName).Open(FileMode.Open, FileAccess.Read)) { using (var reader = new StreamReader(stream)) { using (var csvReader = new CsvReader(reader)) { csvReader.Configuration.HasHeaderRecord = false; while (csvReader.Read()) { if (CheckForEndOfFile(csvReader)) { var organisation = new PublicSectorOrganisation { Name = csvReader.GetField <string>(1), //OrganisationCode = code plus name - see AML-1590 OrganisationCode = csvReader.GetField <string>(2) + csvReader.GetField <string>(1), AddressLine1 = csvReader.GetField <string>(4), AddressLine2 = csvReader.GetField <string>(5), AddressLine3 = csvReader.GetField <string>(6), AddressLine4 = csvReader.GetField <string>(7), AddressLine5 = csvReader.GetField <string>(8), PostCode = csvReader.GetField <string>(9), Source = DataSource.Nhs }; publicSectorOrganisationList.Add(organisation); } } } } } return(publicSectorOrganisationList); }