|
@@ -1,24 +1,30 @@
|
|
|
using Newtonsoft.Json;
|
|
|
+using System;
|
|
|
using System.Net;
|
|
|
+using System.Net.Http;
|
|
|
+using System.Net.Http.Headers;
|
|
|
|
|
|
namespace BlazorApp
|
|
|
{
|
|
|
public class Classasync
|
|
|
{
|
|
|
- static string? responseBody = null;
|
|
|
- public static List<BlazorApp.region> regions = new List<BlazorApp.region>();
|
|
|
+ public static bool userautorisate = false;
|
|
|
+ static string? responseBody = null;
|
|
|
+ public static List<BlazorApp.region> regions = new List<BlazorApp.region>();
|
|
|
static string? responseBody1 = null;
|
|
|
public static List<BlazorApp.ReciplentMessage> message = new List<BlazorApp.ReciplentMessage>();
|
|
|
public static string passwordtrue;
|
|
|
+ public static string addStatus = "";
|
|
|
|
|
|
|
|
|
- async public static Task valera()
|
|
|
+
|
|
|
+ async public static Task getRegion()
|
|
|
{
|
|
|
using (var client = new HttpClient())
|
|
|
{
|
|
|
- client.BaseAddress = new Uri("https://localhost:7152/");
|
|
|
+ client.BaseAddress = new Uri("https://localhost:7152/");
|
|
|
+
|
|
|
|
|
|
-
|
|
|
|
|
|
HttpResponseMessage response = await client.GetAsync("WeatherForecast");
|
|
|
if (response.IsSuccessStatusCode)
|
|
@@ -28,7 +34,7 @@ namespace BlazorApp
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- async public static Task valera1()
|
|
|
+ async public static Task getResiple()
|
|
|
{
|
|
|
using (var client = new HttpClient())
|
|
|
{
|
|
@@ -44,7 +50,7 @@ namespace BlazorApp
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- async public static Task checkLoginAndPassword(string login, string password)
|
|
|
+ async public static Task<bool> checkLoginAndPassword(string login, string password)
|
|
|
{
|
|
|
using (var client = new HttpClient())
|
|
|
{
|
|
@@ -59,14 +65,77 @@ namespace BlazorApp
|
|
|
HttpResponseMessage response = await client.GetAsync(fullUri);
|
|
|
if (response.IsSuccessStatusCode)
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
+ userautorisate = true;
|
|
|
+ return true;
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+
|
|
|
passwordtrue = "Вы ввели неверные данные для входа";
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ async public static Task AddRegion(string region)
|
|
|
+ {
|
|
|
+
|
|
|
+ using (var client = new HttpClient())
|
|
|
+ {
|
|
|
+ var requestParams = new Dictionary<string, string>
|
|
|
+ {
|
|
|
+ {"region",region}
|
|
|
+
|
|
|
+ };
|
|
|
+ var requestUri = new Uri("https://localhost:7152/WeatherForecast/RegionUpdate");
|
|
|
+ var queryString = string.Join("&", requestParams.Select(param => $"{WebUtility.UrlEncode(param.Key)}={WebUtility.UrlEncode(param.Value)}"));
|
|
|
+ var fullUri = $"{requestUri}?{queryString}";
|
|
|
+ HttpResponseMessage response = await client.GetAsync(fullUri);
|
|
|
+ if (response.IsSuccessStatusCode)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
+ async public static Task AddResiple(string resiple)
|
|
|
+ {
|
|
|
+ using (var client = new HttpClient())
|
|
|
+ {
|
|
|
+ var requestParams = new Dictionary<string, string>
|
|
|
+ {
|
|
|
+ {"RecipientMessage",resiple}
|
|
|
+
|
|
|
+ };
|
|
|
+ var requestUri = new Uri("https://localhost:7152/WeatherForecast/resipleUpdate");
|
|
|
+ var queryString = string.Join("&", requestParams.Select(param => $"{WebUtility.UrlEncode(param.Key)}={WebUtility.UrlEncode(param.Value)}"));
|
|
|
+ var fullUri = $"{requestUri}?{queryString}";
|
|
|
+ HttpResponseMessage response = await client.GetAsync(fullUri);
|
|
|
+ if (response.IsSuccessStatusCode)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|