public IHttpActionResult Get() { List <Account> accounts = new List <Account>(); AccountQueries _accountQueries = new AccountQueries(); accounts = _accountQueries.GetAll(); List <AccountModel> accountModels = new List <AccountModel>(); foreach (var account in accounts) { AccountModel accountModel = new AccountModel(); accountModel.Id = account.Id; accountModel.Name = account.Name; foreach (var contact in account.Contacts) { ContactDetails contactDetails = new ContactDetails(); contactDetails.Id = contact.Id; contactDetails.FirstName = contact.FirstName; contactDetails.LastName = contact.LastName; contactDetails.Email = contact.Email; accountModel.Contacts.Add(contactDetails); } accountModels.Add(accountModel); } return(Ok(accountModels)); }
public IEnumerable <Account> GetAllAccounts() { AccountQueries accountQueries = new AccountQueries(); List <Account> accounts = new List <Account>(); accounts = accountQueries.GetAll(); return(accounts); }