public CsvLoadedSuccess()
        {
            var fileReader = new CsvEmployerFileReader();

            using (var stream = File.Open(DataFilePath, FileMode.Open))
            {
                _loadResult  = fileReader.Load(stream);
                _firstRecord = _loadResult.Data[0];
            }
        }
        private static FileUploadEmployer CreateEmployer(SpreadsheetDocument document, OpenXmlElement row)
        {
            var account        = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(EmployerColumnIndex.Account));
            var checksum       = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(EmployerColumnIndex.Checksum));
            var modifiedOn     = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(EmployerColumnIndex.ModifiedOn));
            var companyName    = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(EmployerColumnIndex.CompanyName));
            var companyAka     = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(EmployerColumnIndex.CompanyAka));
            var aupa           = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(EmployerColumnIndex.Aupa));
            var companyType    = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(EmployerColumnIndex.CompanyType));
            var primaryContact = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(EmployerColumnIndex.PrimaryContact));
            var phone          = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(EmployerColumnIndex.Phone));
            var email          = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(EmployerColumnIndex.Email));
            var website        = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(EmployerColumnIndex.Website));
            var address1       = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(EmployerColumnIndex.Address1));
            var city           = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(EmployerColumnIndex.City));
            var countryRegion  = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(EmployerColumnIndex.CountryRegion));
            var postCode       = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(EmployerColumnIndex.PostCode));
            var createdBy      = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(EmployerColumnIndex.CreatedBy));
            var created        = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(EmployerColumnIndex.Created));
            var modified       = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(EmployerColumnIndex.Modified));
            var modifiedBy     = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(EmployerColumnIndex.ModifiedBy));
            var owner          = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(EmployerColumnIndex.Owner));

            var fileUploadEmployer = new FileUploadEmployer
            {
                Account        = new Guid(account),
                Checksum       = checksum,
                ModifiedOn     = modifiedOn.ToDate(),
                CompanyName    = companyName,
                CompanyAka     = companyAka,
                Aupa           = aupa,
                CompanyType    = companyType,
                PrimaryContact = primaryContact,
                Phone          = phone,
                Email          = email,
                Website        = website,
                Address1       = address1,
                City           = city,
                CountryRegion  = countryRegion,
                PostCode       = postCode,
                CreatedBy      = createdBy,
                Created        = created.ToDate(),
                ModifiedBy     = modifiedBy,
                Modified       = modified.ToDate(),
                Owner          = owner
            };

            return(fileUploadEmployer);
        }
Ejemplo n.º 3
0
        public static Entities.Employer Map(FileUploadEmployer fileEmployer,
                                            Entities.Employer employer)
        {
            if (employer == null)
            {
                employer = new Entities.Employer
                {
                    Id = fileEmployer.Account
                };
            }

            Enum.TryParse(fileEmployer.Aupa, out AupaStatus aupa);
            var companyType = GetCompanyType(fileEmployer.CompanyType);

            employer.AlsoKnownAs = fileEmployer.CompanyAka;
            employer.AupaStatus  = (int)aupa;
            employer.CompanyName = fileEmployer.CompanyName;
            employer.CompanyType = (int)companyType;
            employer.CreatedOn   = fileEmployer.Created;

            return(employer);
        }