Разрешение конфликта.

This commit is contained in:
Programmist73 2023-05-17 17:14:40 +04:00
commit 013b06ae68
10 changed files with 176 additions and 39 deletions

View File

@ -53,7 +53,7 @@
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2023 - BankYouBankruptCashierApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Личный кабинет</a>
&copy; 2023 - BankYouBankruptClientApp
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>

View File

@ -18,7 +18,6 @@ namespace BankYouBankruptClientApp.Controllers
_logger = logger;
}
//вытаскивает через API клиента Get-запросом список его собственных заказов
[HttpGet]
public IActionResult Index()
{
@ -27,6 +26,18 @@ namespace BankYouBankruptClientApp.Controllers
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<CardViewModel>>($"api/Card/GetUsersCardsList?id={APIClient.Client.Id}"));
}
[HttpGet]
public IActionResult Profile()
{
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<ClientViewModel>($"api/Client/GetClient?clientId={APIClient.Client.Id}"));
}
@ -41,14 +52,13 @@ namespace BankYouBankruptClientApp.Controllers
});
}
//просто открытие вьюхи
[HttpGet]
public IActionResult Enter()
{
return View();
}
//отсылаем указанные данные на проверку
[HttpPost]
public void Enter(string login, string password)
{
@ -64,17 +74,17 @@ namespace BankYouBankruptClientApp.Controllers
throw new Exception("Неверный логин/пароль");
}
Response.Redirect("Index");
Response.Redirect("Profile");
}
//просто открытие вьюхи
[HttpGet]
public IActionResult Register()
{
return View();
}
//Post-запрос по созданию нового пользователя
[HttpPost]
public void Register(string login, string password, string name, string surname, string patronymic, string telephone)
{
@ -94,10 +104,37 @@ namespace BankYouBankruptClientApp.Controllers
Telephone = telephone
});
//переход на вкладку "Enter", чтобы пользователь сразу смог зайти
Response.Redirect("Enter");
return;
}
}
[HttpGet]
public IActionResult CreateCard() {
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
return View();
}
[HttpPost]
public IActionResult CreateCard(string account, string number, string cvc, string period) {
if (APIClient.Client == null)
{
throw new Exception("Не авторизованы");
}
APIClient.PostRequest("api/Card/CreateCard", new CardBindingModel {
ClientID = APIClient.Client.Id,
AccountId = int.Parse(account),
Number = number,
CVC = cvc,
Period = DateTime.Parse(period)
});
return Redirect("~/Home/Index");
}
}
}

View File

@ -26,6 +26,6 @@ app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
pattern: "{controller=Home}/{action=Profile}/{id?}");
app.Run();

View File

@ -0,0 +1,39 @@
@{
ViewData["Title"] = "Register";
}
<div class="text-center">
<h2 class="display-4">Создание карты</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Номер счета:</div>
<div class="col-8">
<input type="text" name="account" />
</div>
</div>
<div class="row">
<div class="col-4">Номер карты:</div>
<div class="col-8">
<input type="text" name="number" />
</div>
</div>
<div class="row">
<div class="col-4">CVC:</div>
<div class="col-8">
<input type="text" name="cvc" />
</div>
</div>
<div class="row">
<div class="col-4">Срок действия:</div>
<div class="col-8">
<input type="date" name="period" />
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Создание" class="btn btn-primary" />
</div>
</div>
</form>

View File

@ -9,7 +9,7 @@
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8">
<input type="text" name="login" /
<input type="text" name="login" />
</div>
</div>
<div class="row">
@ -24,4 +24,10 @@
<input type="submit" value="Вход" class="btn btn-primary" />
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="">Создать аккаунт</a>
</div>
</div>
</form>

View File

@ -1,13 +1,13 @@
@using BankYouBankruptContracts.ViewModels
@model ClientViewModel
@model List<CardViewModel>
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Страница пользователя</h1>
<h1 class="display-4">Карты</h1>
</div>
<div class="text-center">
@ -17,10 +17,45 @@
<h3 class="display-4">Сначала авторизируйтесь</h3>
return;
}
<p>Здравствуйтe, @Model.Name @Model.Patronymic</p>
<p>
<a asp-action="Create">Открыть счёт</a>
<a asp-action="CreateCard">Создать карту</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер счёта
</th>
<th>
CVC
</th>
<th>
Фамилия владельца
</th>
<th>
Срок действия
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Number)
</td>
<td>
@Html.DisplayFor(modelItem => item.CVC)
</td>
<td>
@Html.DisplayFor(modelItem => item.ClientSurname)
</td>
<td>
@Html.DisplayFor(modelItem => item.Period)
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -0,0 +1,23 @@
@using BankYouBankruptContracts.ViewModels
@model ClientViewModel
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Страница пользователя</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Сначала авторизируйтесь</h3>
return;
}
<p>Здравствуйтe, @Model.Name @Model.Patronymic</p>
}
</div>

View File

@ -48,4 +48,10 @@
<input type="submit" value="Регистрация" class="btn btn-primary" />
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Enter">Уже есть аккаунт?</a>
</div>
</div>
</form>

View File

@ -1,4 +1,5 @@
<!DOCTYPE html>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
@ -13,29 +14,13 @@
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container">
<a class="navbar-brand" asp-area="" asp-controller="Home" aspaction="Index">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Profile">
Банк "Вы банкрот"
</a>
<button class="navbar-toggler" type="button" datatoggle="collapse" data-target=".navbar-collapse" ariacontrols="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex flex-smrow-reverse">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Index">Счета</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="CreateReport">Отчёт</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Enter">Вход</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Register">Регистрация</a>
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Index">Карты</a>
</li>
</ul>
</div>
@ -50,7 +35,7 @@
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2023 - BankYouBankruptCashierApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
&copy; 2023 - BankYouBankruptClientApp
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>

View File

@ -15,9 +15,15 @@ namespace BankYouBankruptDatabaseImplement
{
if (!optionsBuilder.IsConfigured)
{
//optionsBuilder.UseSqlServer(@"Data Source=SHADOWIK\SHADOWIK;Initial Catalog=BankYouBankrupt;Integrated Security=True;TrustServerCertificate=True");
optionsBuilder.UseSqlServer(@"Data Source=LAPTOP-CFLH20EE\SQLEXPRESS;Initial Catalog=BankYouBankrupt;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
if (System.Environment.MachineName == "SHADOWIK")
{
optionsBuilder.UseSqlServer(@"Data Source=SHADOWIK\SHADOWIK;Initial Catalog=BankYouBankrupt;Integrated Security=True;TrustServerCertificate=True");
}
else
{
optionsBuilder.UseSqlServer(@"Data Source=LAPTOP-CFLH20EE\SQLEXPRESS;Initial Catalog=BankYouBankrupt;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
}
base.OnConfiguring(optionsBuilder);
}
public virtual DbSet<Account> Accounts { set; get; }