Esempio n. 1
0
        //    private readonly IIoTHubResourceDto _ioTHubResourceDto;



        //public IoTHubResourceBus(IIoTHubResourceDto ioTHubResourceDto)
        //{
        //    this._ioTHubResourceDto = ioTHubResourceDto;

//        }
        public async Task <string> GetBySubId(string email, string subid)
        {
            string access_token = _tokenDto.GetTokenString(email, _tokenResource.Value.manage);

            //var accountModel= this._configuration.GetSection("appsettings").Value;
            //SubId = this._accountModel.subscriptionId;
            //subId = "6273fbea-8a11-498b-8218-02b6f4398e12";

            Model.ResponseModel.IoTHubResourceModel objs = null;
            //IoTHubResourceDto ioTHubResourceDto = new IoTHubResourceDto();
            objs = await this._ioTHubResourceDto.ListBySubId(subid, access_token);

            List <Model.IoTHubResourceViewModel> listBySubIdResponse = new List <Model.IoTHubResourceViewModel>();

            foreach (var ob in objs.value)
            {
                Model.IoTHubResourceViewModel ioTHubResource = new Model.IoTHubResourceViewModel();
                ioTHubResource.name           = ob.name;
                ioTHubResource.location       = ob.location;
                ioTHubResource.resourcegroup  = ob.resourcegroup;
                ioTHubResource.type           = ob.type;
                ioTHubResource.subscriptionid = ob.subscriptionid;
                listBySubIdResponse.Add(ioTHubResource);
            }
            string result = JsonConvert.SerializeObject(listBySubIdResponse);

            return(result);
        }
Esempio n. 2
0
        //    private readonly IIoTHubResourceDto _ioTHubResourceDto;



        //public IoTHubResourceBus(IIoTHubResourceDto ioTHubResourceDto)
        //{
        //    this._ioTHubResourceDto = ioTHubResourceDto;

//        }
        public async Task <string> GetBySubId(string SubId)
        {
            //SubId = this._configuration["accountsetting:subscriptionId"];
            SubId = "6273fbea-8a11-498b-8218-02b6f4398e12";
            TokenModel Token = this._tokenDto.GetToken().Result;

            Model.ResponseModel.IoTHubResourceModel objs = null;
            //IoTHubResourceDto ioTHubResourceDto = new IoTHubResourceDto();
            objs = await this._ioTHubResourceDto.ListBySubId(SubId, Token.access_token);

            List <Model.IoTHubResourceViewModel> listBySubIdResponse = new List <Model.IoTHubResourceViewModel>();

            foreach (var ob in objs.value)
            {
                Model.IoTHubResourceViewModel ioTHubResource = new Model.IoTHubResourceViewModel();
                ioTHubResource.name           = ob.name;
                ioTHubResource.location       = ob.location;
                ioTHubResource.resourcegroup  = ob.resourcegroup;
                ioTHubResource.type           = ob.type;
                ioTHubResource.subscriptionid = ob.subscriptionid;
                listBySubIdResponse.Add(ioTHubResource);
            }
            string result = JsonConvert.SerializeObject(listBySubIdResponse);

            return(result);
        }