Merge branch 'LabWork05_Hard' into LabWork06_Hard

This commit is contained in:
Safgerd 2023-04-28 16:59:43 +04:00
commit 55054790d2
3 changed files with 12 additions and 8 deletions

View File

@ -90,7 +90,7 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
var car = _carStorage.GetElement(new CarSearchModel() { Id = model.CarId });
if (car == null)
{
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Document not found.");
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Car not found.");
return false;
}
if (CheckThenSupplyMany(car, model.Count) == false)

View File

@ -7,8 +7,17 @@ namespace AutomobilePlantShopApp
public static class APIClient
{
private static readonly HttpClient _client = new();
public static bool isAuth { get; set; } = false;
public static bool isAuth { get; private set; } = false;
public static string ConfigPassword { get; private set; } = string.Empty;
public static bool Login(string password)
{
if (string.IsNullOrEmpty(password))
{
throw new Exception("Введите пароль");
}
return isAuth = password.Equals(ConfigPassword);
}
public static void Connect(IConfiguration configuration)
{
ConfigPassword = configuration["Password"];

View File

@ -45,15 +45,10 @@ namespace AutomobilePlantShopApp.Controllers
[HttpPost]
public void Enter(string password)
{
if (string.IsNullOrEmpty(password))
{
throw new Exception("Введите пароль");
}
if (!password.Equals(APIClient.ConfigPassword))
if (!APIClient.Login(password))
{
throw new Exception("Неверный пароль");
}
APIClient.isAuth = true;
Response.Redirect("Index");
}
[HttpGet]