123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using Newtonsoft.Json;
- using System.Net;
- namespace BlazorApp
- {
- public class Classasync
- {
- 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;
- async public static Task valera()
- {
- using (var client = new HttpClient())
- {
- client.BaseAddress = new Uri("https://localhost:7152/");
-
- HttpResponseMessage response = await client.GetAsync("WeatherForecast");
- if (response.IsSuccessStatusCode)
- {
- responseBody = await response.Content.ReadAsStringAsync();
- regions = JsonConvert.DeserializeObject<List<BlazorApp.region>>(responseBody);
- }
- }
- }
- async public static Task valera1()
- {
- using (var client = new HttpClient())
- {
- client.BaseAddress = new Uri("https://localhost:7152/");
- HttpResponseMessage response = await client.GetAsync("WeatherForecast/GetReciplentMessage");
- if (response.IsSuccessStatusCode)
- {
- responseBody1 = await response.Content.ReadAsStringAsync();
- message = JsonConvert.DeserializeObject<List<BlazorApp.ReciplentMessage>>(responseBody1);
- }
- }
- }
- async public static Task checkLoginAndPassword(string login, string password)
- {
- using (var client = new HttpClient())
- {
- var requestParams = new Dictionary<string, string>
- {
- {"login",login},
- {"password",password}
- };
- var requestUri = new Uri("https://localhost:7152/WeatherForecast/GetUserRole");
- 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
- {
- passwordtrue = "Вы ввели неверные данные для входа";
- }
- }
- }
- }
- }
|