Настроен вход и вывод счётов.

This commit is contained in:
Programmist73 2023-05-17 00:06:05 +04:00
parent 48abf8eb93
commit 27f513107f
7 changed files with 82 additions and 31 deletions

View File

@ -49,7 +49,7 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
public List<AccountViewModel>? ReadList(AccountSearchModel? model) public List<AccountViewModel>? ReadList(AccountSearchModel? model)
{ {
_logger.LogInformation("ReadList. AccountNumber:{Name}. Id:{Id}", model.AccountNumber, model?.Id); //_logger.LogInformation("ReadList. AccountNumber:{AccountNumber}. Id:{Id}", model.AccountNumber, model?.Id);
//list хранит весь список в случае, если model пришло со значением null на вход метода //list хранит весь список в случае, если model пришло со значением null на вход метода
var list = model == null ? _accountStorage.GetFullList() : _accountStorage.GetFilteredList(model); var list = model == null ? _accountStorage.GetFullList() : _accountStorage.GetFilteredList(model);

View File

@ -25,14 +25,14 @@ namespace BankYouBankruptCashierApp
var response = _client.GetAsync(requestUrl); var response = _client.GetAsync(requestUrl);
var result = response.Result.Content.ReadAsStringAsync().Result; var result = response.Result.Content.ReadAsStringAsync().Result;
//if (response.Result.IsSuccessStatusCode) if (response.Result.IsSuccessStatusCode)
//{ {
// return JsonConvert.DeserializeObject<T>(result); return JsonConvert.DeserializeObject<T>(result);
//} }
//else else
//{ {
// throw new Exception(result); throw new Exception(result);
//} }
return JsonConvert.DeserializeObject<T>(""); return JsonConvert.DeserializeObject<T>("");
} }

View File

@ -17,16 +17,15 @@ namespace BankYouBankruptCashierApp.Controllers
} }
//вытаскивает через API клиента Get-запросом список его собственных заказов //вытаскивает через API клиента Get-запросом список его собственных заказов
[HttpGet]
public IActionResult Index() public IActionResult Index()
{ {
if (APICashier.Cashier == null) if (APICashier.Cashier == null)
{ {
//return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
//return View(APICashier.GetRequest<List<AccountViewModel>>($"api/main/getaccounts?cashierId={APICashier.Cashier.Id}")); return View(APICashier.GetRequest<List<AccountViewModel>>($"/api/Account/GetAllAccounts"));
return View();
} }
//изменемение ланных Get-ом //изменемение ланных Get-ом
@ -35,7 +34,7 @@ namespace BankYouBankruptCashierApp.Controllers
{ {
if (APICashier.Cashier == null) if (APICashier.Cashier == null)
{ {
//return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
return View(APICashier.Cashier); return View(APICashier.Cashier);
@ -102,7 +101,7 @@ namespace BankYouBankruptCashierApp.Controllers
throw new Exception("Введите логин и пароль"); throw new Exception("Введите логин и пароль");
} }
APICashier.Cashier = APICashier.GetRequest<CashierViewModel>($"api/cashier/login?login={login}&password={password}"); APICashier.Cashier = APICashier.GetRequest<CashierViewModel>($"/api/Cashier/Login?login={login}&password={password}");
if (APICashier.Cashier == null) if (APICashier.Cashier == null)
{ {
@ -146,13 +145,13 @@ namespace BankYouBankruptCashierApp.Controllers
} }
//открытие счёта. Получаем и передаём список изделий во вьюху? //открытие счёта. Получаем и передаём список изделий во вьюху?
[HttpGet] /*[HttpGet]
public IActionResult Create() public IActionResult Create()
{ {
//ViewBag.Accountes = APICashier.GetRequest<List<AccountViewModel>>("api/main/getaccountlist"); ViewBag.Accountes = APICashier.GetRequest<List<AccountViewModel>>("/api/Cashier/GetAllAccounts");
return View(); return View();
} }*/
//создание заказа Post-запросом //создание заказа Post-запросом
[HttpPost] [HttpPost]
@ -181,7 +180,7 @@ namespace BankYouBankruptCashierApp.Controllers
[HttpGet] [HttpGet]
public IActionResult CreateReport() public IActionResult CreateReport()
{ {
//ViewBag.Accountes = APICashier.GetRequest<List<AccountViewModel>>("api/main/getaccountlist"); ViewBag.Accountes = APICashier.GetRequest<List<AccountViewModel>>("api/main/getaccountlist");
return View(); return View();
} }
@ -192,7 +191,7 @@ namespace BankYouBankruptCashierApp.Controllers
{ {
if (APICashier.Cashier == null) if (APICashier.Cashier == null)
{ {
//throw new Exception("Вы как сюда попали? Суда вход только авторизованным"); throw new Exception("Вы как сюда попали? Суда вход только авторизованным");
} }
if (DateFrom > DateTo) if (DateFrom > DateTo)

View File

@ -12,12 +12,11 @@
<div class="text-center"> <div class="text-center">
@{ @{
//if (Model == null) if (Model == null)
//{ {
// <h3 class="display-4">Сначала авторизируйтесь</h3> <h3 class="display-4">Сначала авторизируйтесь</h3>
// return; return;
//} }
<p> <p>
<a asp-action="Create">Открыть счёт</a> <a asp-action="Create">Открыть счёт</a>
</p> </p>
@ -42,6 +41,26 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.AccountNumber)
</td>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Patronymic)
</td>
<td>
@Html.DisplayFor(modelItem => item.Balance)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateOpen)
</td>
</tr>
}
</tbody> </tbody>
</table> </table>
} }

View File

@ -7,5 +7,5 @@
}, },
"AllowedHosts": "*", "AllowedHosts": "*",
"IPAddress": "http://localhost:5169/" "IPAddress": "http://localhost:5179/"
} }

View File

@ -56,6 +56,21 @@ namespace BankYouBankruptRestApi.Controllers
} }
} }
//получаем все имеющиеся счета
[HttpGet]
public List<AccountViewModel>? GetAllAccounts()
{
try
{
return _accountLogic.ReadList(null);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка входа в систему");
throw;
}
}
[HttpPost] [HttpPost]
public void Register(AccountBindingModel model) public void Register(AccountBindingModel model)
{ {

View File

@ -40,6 +40,24 @@ namespace BankYouBankruptRestApi.Controllers
} }
} }
[HttpGet]
public CashierViewModel? GetCashier(int id)
{
try
{
//попытка найти запись по переданным логину и паролю
return _cashierLogic.ReadElement(new CashierSearchModel
{
Id = id
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка входа в систему");
throw;
}
}
[HttpPost] [HttpPost]
public void Register(CashierBindingModel model) public void Register(CashierBindingModel model)
{ {