private async Task <QRCodes> Authenticate() { var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost:57198/api/QRGenerator"); request.Content = new StringContent(JsonSerializer.Serialize(new QRDataCatering() { CateringName = "nikola", LocationCordinates = "12.43.214.21" })); request.Content.Headers.ContentType = new MediaTypeWithQualityHeaderValue("application/json"); var client = _httpClientFactory.CreateClient(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = await client.SendAsync(request); QRCodes qRCodes = null; if (response.IsSuccessStatusCode) { var responseStream = await response.Content.ReadAsStringAsync(); qRCodes = Newtonsoft.Json.JsonConvert.DeserializeObject <QRCodes>(responseStream); } return(qRCodes); }
// qrcodes table insert/update public async Task InsertOrUpdateTableAsyncQRCodes(QRCodes qr) { QRCodesL qR = new QRCodesL(); qR.QRCodes_Name = qr.QRCodes_Name; qR.QRCodes_IMG = qr.QRCodes_IMG; qR.QRCodes_Pos = qr.QRCodes_Pos; if (qR.QRCodes_ID != 0) { await CreateConnection().UpdateAsync(qR); } else { await CreateConnection().InsertAsync(qR); } }