public async Task UpdateHolderInfo(string holderCode) { var request = WebRequest.Create(_baseUrl); request.Method = "POST"; using (Stream requestStream = request.GetRequestStream()) { var holderRequest = new HolderRequest() { EquipmentSn = holderCode, DeviceType = "8", DeviceVersion = "1", SessionId = "94868768687778", PackageType = "175" }; var holderRequestString = JsonConvert.SerializeObject(holderRequest); var holderRequestBuf = Encoding.UTF8.GetBytes(holderRequestString); requestStream.Write(holderRequestBuf); } var response = await request.GetResponseAsync(); string responceString = ""; using (Stream dataStream = response.GetResponseStream()) { StreamReader reader = new StreamReader(dataStream); responceString = await reader.ReadToEndAsync(); } }
private async Task <bool> PrvidePowerBank(HolderModel holderModel, PowerbankModel powerbank) { var request = WebRequest.Create(_baseUrl); request.Method = "POST"; using (Stream requestStream = request.GetRequestStream()) { var holderRequest = new HolderRequest() { Position = powerbank.Position.ToString(), EquipmentSn = holderModel.Code, DeviceType = "8", DeviceVersion = "1", SessionId = "94868768687778", PackageType = "171" }; var holderRequestString = JsonConvert.SerializeObject(holderRequest); var holderRequestBuf = Encoding.UTF8.GetBytes(holderRequestString); requestStream.Write(holderRequestBuf); } var response = await request.GetResponseAsync(); string responceString = ""; using (Stream dataStream = response.GetResponseStream()) { StreamReader reader = new StreamReader(dataStream); responceString = await reader.ReadToEndAsync(); } return(true); }