?
This commit is contained in:
parent
f38284dab8
commit
f3cc5965a7
@ -48,7 +48,7 @@ namespace JewelryStoreBusinessLogic.BusinessLogics
|
|||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SendOrderMessage(result.ClientId, $"Установка ПО, Заказ №{result.Id}", $"Заказ №{result.Id} от {result.DateCreate} на сумму {result.Sum:0.00} принят");
|
SendOrderMessage(result.ClientId, $"Магазин драгоценностей, Заказ №{result.Id}", $"Заказ №{result.Id} от {result.DateCreate} на сумму {result.Sum:0.00} принят");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ namespace JewelryStoreBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SendOrderMessage(result.ClientId, $"Установка ПО, Заказ №{result.Id}", $"Заказ №{model.Id} изменен статус на {result.Status}");
|
SendOrderMessage(result.ClientId, $"Магазин драгоценностей, Заказ №{result.Id}", $"Заказ №{model.Id} изменен статус на {result.Status}");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,14 +8,16 @@ namespace JewelryStoreClientApp
|
|||||||
public class APIClient
|
public class APIClient
|
||||||
{
|
{
|
||||||
private static readonly HttpClient _client = new();
|
private static readonly HttpClient _client = new();
|
||||||
|
|
||||||
public static ClientViewModel? Client { get; set; } = null;
|
public static ClientViewModel? Client { get; set; } = null;
|
||||||
|
|
||||||
public static void Connect(IConfiguration configuration)
|
public static void Connect(IConfiguration configuration)
|
||||||
{
|
{
|
||||||
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||||
_client.DefaultRequestHeaders.Accept.Clear();
|
_client.DefaultRequestHeaders.Accept.Clear();
|
||||||
_client.DefaultRequestHeaders.Accept.Add(new
|
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||||
MediaTypeWithQualityHeaderValue("application/json"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T? GetRequest<T>(string requestUrl)
|
public static T? GetRequest<T>(string requestUrl)
|
||||||
{
|
{
|
||||||
var response = _client.GetAsync(requestUrl);
|
var response = _client.GetAsync(requestUrl);
|
||||||
@ -29,17 +31,21 @@ namespace JewelryStoreClientApp
|
|||||||
throw new Exception(result);
|
throw new Exception(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void PostRequest<T>(string requestUrl, T model)
|
public static void PostRequest<T>(string requestUrl, T model)
|
||||||
{
|
{
|
||||||
var json = JsonConvert.SerializeObject(model);
|
var json = JsonConvert.SerializeObject(model);
|
||||||
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
var response = _client.PostAsync(requestUrl, data);
|
var response = _client.PostAsync(requestUrl, data);
|
||||||
|
|
||||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||||
if (!response.Result.IsSuccessStatusCode)
|
if (!response.Result.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
throw new Exception(result);
|
throw new Exception(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user