public async Task <AccountResource> GetAccountResources(long AccountID) { AccountResource AccountResource = new AccountResource(); var AccountDetails = await _accountClient.GetAccountByID(AccountID); if (AccountDetails != null && AccountDetails.AccountData != null && AccountDetails.AccountData.Count > 0) { AccountResource.Users = await _accountClient.GetAccountUserListForUser(AccountID, AccountDetails.AccountData[0].UserName); AccountResource.Networks = await _networkClient.GetNetworkListByAccountID(AccountID); foreach (var network in AccountResource.Networks) { var sensors = await _sensorClient.GetSensorListByNetworkID(network.CSNetID, AccountDetails.AccountData[0].UserName); AccountResource.Sensors.AddRange(_mapper.Map <List <SensorInfo> >(sensors)); var gateways = await _gatewayClient.GetGatewayListByNetworkID(network.CSNetID, AccountDetails.AccountData[0].UserName); AccountResource.Gateways.AddRange(_mapper.Map <List <GatewayInfo> >(gateways)); } } List <AccountSensors> AccountNumSensors = new List <AccountSensors> { new AccountSensors { AccountID = AccountDetails.AccountData[0].AccountID, NumSensors = AccountDetails.NumSensors } }; AccountResource.Customer = (await PrepareCuctomersSummary(AccountDetails.AccountData, AccountNumSensors))[0]; AccountResource.Customer.NumberOfGateways = AccountDetails.NumGateways; AccountResource.PaymentHistories = await _paymentHistoryApplicationService.GetPaymentHistoryList(); return(AccountResource); }