private static Walkin CreateWalkingFromDataset(string walkInId, WalkinDataset ds) { Walkin walkIn = new Walkin(); WalkinDataset.WalkinRow walkInRow = (WalkinDataset.WalkinRow)ds.Walkin.Rows[0]; walkIn.FirstName = walkInRow.FirstName; walkIn.LastName = walkInRow.LastName; walkIn.MiddleInitial = walkInRow.MiddleInitial; walkIn.SSNumber = walkInRow.SSNumber; walkIn.MotherMaidenName = walkInRow.MotherMaidenName; new WalkinAddressTableAdapter().Fill(ds.WalkinAddress, walkInId); if (ds.WalkinAddress.Rows.Count > 0) { List <Address> addresses = new List <Address>(); foreach (WalkinDataset.WalkinAddressRow addressRow in ds.WalkinAddress.Rows) { Address address = new Address(); addresses.Add(address); address.Address1 = addressRow.Address1; address.Address2 = addressRow.IsAddress2Null() ? null : addressRow.Address2; address.AddressType = addressRow.Type; address.City = addressRow.City; address.CountryCode = addressRow.Country; address.PostalZipCode = addressRow.PostalZipCode; address.StateProvince = addressRow.StateProvince; } walkIn.Addresses = addresses.ToArray(); } new WalkinEmailAddressTableAdapter().Fill(ds.WalkinEmailAddress, walkInId); if (ds.WalkinEmailAddress.Rows.Count > 0) { List <EmailAddress> emails = new List <EmailAddress>(); foreach (WalkinDataset.WalkinEmailAddressRow emailRow in ds.WalkinEmailAddress.Rows) { EmailAddress email = new EmailAddress(); emails.Add(email); email.EmailAddress1 = emailRow.EmailAddress; email.Type = emailRow.Type; } walkIn.EmailAddresses = emails.ToArray(); } new WalkinPhoneNumberTableAdapter().Fill(ds.WalkinPhoneNumber, walkInId); if (ds.WalkinPhoneNumber.Rows.Count > 0) { List <PhoneNumber> phones = new List <PhoneNumber>(); foreach (WalkinDataset.WalkinPhoneNumberRow phoneRow in ds.WalkinPhoneNumber.Rows) { PhoneNumber phone = new PhoneNumber(); phones.Add(phone); phone.PhoneNumber1 = phoneRow.PhoneNumber; phoneRow.Type = phoneRow.Type; } walkIn.PhoneNumbers = phones.ToArray(); } return(walkIn); }
private Walkin[] LookupWalkin(string walkInId) { using (SqlConnection conn = CreateConnection()) { conn.Open(); WalkinDataset ds = new WalkinDataset(); new WalkinTableAdapter().Fill(ds.Walkin, walkInId); if (ds.Walkin.Rows.Count == 0) { return(new Walkin[0]); } Walkin walkIn = CreateWalkingFromDataset(walkInId, ds); return(new Walkin[1] { walkIn }); } }