Пример #1
0
        /// <summary>
        /// Get the Location details.
        /// </summary>
        /// <param name="LocationID">Unique ID of the location</param>
        /// <returns>LocationDetailsDTO</returns>
        public async Task <LocationDetails> GetLocationDetails(int ID)
        {
            LocationDetails locDetails = new LocationDetails();

            //Get the Network info from the Integrated API
            var netWork = await _networkClient.GetNetworkByID(ID);

            //If the newtwork found then
            if (netWork != null)
            {
                //Map the network info.
                locDetails = _mapper.Map <LocationDetails>(netWork);

                //Get the address detais for the network
                var netWorkLocation = await _networkLocationClient.GetNetworkLocationByID(ID);

                if (netWorkLocation != null)
                {
                    locDetails = _mapper.Map <LocationDetails>(netWorkLocation);
                }

                //get gayway list for a network
                var gateWayList = await _gatewayClient.GetGatewayListByNetworkID(netWork.CSNetID);

                locDetails.Gateways     = _mapper.Map <List <GatewayDetails> >(gateWayList);
                locDetails.NoOfGateways = locDetails.Gateways.Count;

                //get the sensor list for a given network
                var sensorList = await _sensorClient.GetSensorListByNetworkID(netWork.CSNetID);

                locDetails.Sensors     = _mapper.Map <List <SensorDetails> >(sensorList);
                locDetails.NoOfSensors = locDetails.Sensors.Count;
            }

            return(locDetails);
        }
        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);
        }