public MapDataDownloadService(IApplicationReleaseConfiguration configuration, IHttpClientFactory httpClientFactory) { var server = configuration.GetString("MAPDATA_SERVER"); hasMapServer = server != null; this.mapServerUrl = new Uri(server ?? "http://localhost"); this.client = httpClientFactory.Factory(); }
public async Task <CommentResult> Publish(string username, string text) { var http = httpClientFactory.Factory(); var json = JsonConvert.SerializeObject(new Request() { Username = username, Text = text }); var content = new StringContent(json, Encoding.UTF8, "application/json"); try { var result = await http.PostAsync($"{updateServer}/Comments/Add", content); if (result.StatusCode == HttpStatusCode.Unauthorized) { return(CommentResult.TooManyComments); } if (result.StatusCode == HttpStatusCode.Forbidden) { return(CommentResult.InvalidIpAddress); } if (result.StatusCode == HttpStatusCode.OK) { return(CommentResult.Success); } return(CommentResult.ServerProblem); } catch (Exception e) { Console.WriteLine(e); return(CommentResult.InternetProblem); } }
public IUpdateClient Create(Uri updateServerUrl, string marketplace, string?key, Platforms platform) { var httpClient = httpClientFactory.Factory(); return(new UpdateClient(updateServerUrl, marketplace, key, platform, httpClient)); }