PostService

This commit is contained in:
2023-06-23 15:40:59 -07:00
parent 9452454b8a
commit 98c6262a4d
19 changed files with 338 additions and 6 deletions

View File

@ -0,0 +1,34 @@
using Barcode.Host.Shared.Models;
using Barcode.Host.Shared.Models.Stateless;
using System.Text;
namespace Barcode.Host.Server.Services;
public class PostService : IPostService
{
private static Task<HttpResponseMessage> PostAsync(string postTo, HttpClient httpClient, Notification notification)
{
Task<HttpResponseMessage> result;
string json = System.Text.Json.JsonSerializer.Serialize(notification);
StringContent stringContent = new(json, Encoding.UTF8, "application/json");
result = httpClient.PostAsync(postTo, stringContent);
return result;
}
Task<HttpResponseMessage> IPostService.PostAsync(string postTo, HttpClient httpClient, Notification notification)
{
Task<HttpResponseMessage> result = PostAsync(postTo, httpClient, notification);
return result;
}
HttpResponseMessage IPostService.Post(string postTo, HttpClient httpClient, Notification notification)
{
HttpResponseMessage result;
Task<HttpResponseMessage> httpResponseMessage = PostAsync(postTo, httpClient, notification);
httpResponseMessage.Wait();
result = httpResponseMessage.Result;
return result;
}
}