Compare commits

..

No commits in common. "af59eea06b859bb18806e712ef05e02956c694e1" and "22090fb93d017dcae6b12cc8b1f1f96464c499da" have entirely different histories.

14 changed files with 29 additions and 358 deletions

View File

@ -10,7 +10,5 @@ namespace BankContracts.SearchModels
{
public int? Id { get; set; }
public string? Login { get; set; }
public string? Password { get; set; }
}
}

View File

@ -23,25 +23,15 @@ namespace BankDatabaseImplement.Implements
}
public List<OperatorViewModel> GetFilteredList(OperatorSearchModel model)
{
if (!model.Id.HasValue && string.IsNullOrEmpty(model.Login) && string.IsNullOrEmpty(model.Password))
if (!model.Id.HasValue)
{
return new();
}
using var context = new BankDatabase();
if (!string.IsNullOrEmpty(model.Login) && !string.IsNullOrEmpty(model.Password))
{
return context.Operators
.Where(x => x.Login == model.Login || x.Password == model.Password)
.Select(x => x.GetViewModel)
.ToList();
}
else
{
return context.Operators
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
return context.Operators
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
public OperatorViewModel? GetElement(OperatorSearchModel model)
{

View File

@ -62,9 +62,7 @@ namespace BankDatabaseImplement.Models
Deals = model.DealPayments.Select(x => new DealPayment
{
Deal = context.Deals.First(y => y.Id == x.Key)
}).ToList(),
OperatorId = model.OperatorId,
Operator = context.Operators.First(x => x.Id == model.OperatorId)
}).ToList()
};
}
public void Update(PaymentBindingModel? model)

View File

@ -34,9 +34,7 @@ namespace BankDatabaseImplement.Models
Amount = model.Amount,
TransferDateTime = model.TransferDateTime,
PaymentId = model.PaymentId,
Payment = context.Payments.First(x => x.Id == model.PaymentId),
OperatorId = model.OperatorId,
Operator = context.Operators.First(x => x.Id == model.OperatorId)
Payment = context.Payments.First(x => x.Id == model.PaymentId)
};
}
public static Transfer? Create(BankDatabase context, TransferViewModel model)

View File

@ -19,24 +19,6 @@ namespace BankRestApi.Controllers
_operator = operatorC;
}
[HttpGet]
public OperatorViewModel? Login(string login, string password)
{
try
{
return _operator.ReadElement(new OperatorSearchModel
{
Login = login,
Password = password
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка входа в систему");
throw;
}
}
[HttpPost]
public void CreateOperator(OperatorBindingModel model)
{

View File

@ -5,7 +5,7 @@ using Newtonsoft.Json;
namespace OperatorApp
{
public class APIClient
public class APIClientcs
{
private static readonly HttpClient _client = new();

View File

@ -1,6 +1,4 @@
using BankContracts.BindingModels;
using BankContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using OperatorApp.Models;
using System.Diagnostics;
@ -17,50 +15,12 @@ namespace OperatorApp.Controllers
public IActionResult Index()
{
if (APIClient.Operator == null)
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<DealViewModel>>($"api/deal/getdeals?operatorId={APIClient.Operator.Id}"));
return View();
}
[HttpGet]
public IActionResult Privacy()
{
if (APIClient.Operator == null)
{
return Redirect("~/Home/Enter");
}
return View(APIClient.Operator);
}
[HttpPost]
public void Privacy(string login, string password, string lastname, string firstname, string middleName)
{
if (APIClient.Operator == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(lastname) || string.IsNullOrEmpty(firstname) || string.IsNullOrEmpty(middleName))
{
throw new Exception("Введите логин, пароль и ФИО");
}
APIClient.PostRequest("api/operator/updateoperator", new OperatorBindingModel
{
Id = APIClient.Operator.Id,
LastName = lastname,
FirstName = firstname,
MiddleName = middleName,
Login = login,
Password = password
});
APIClient.Operator.LastName = lastname;
APIClient.Operator.FirstName = firstname;
APIClient.Operator.MiddleName = middleName;
APIClient.Operator.Login = login;
APIClient.Operator.Password = password;
Response.Redirect("Index");
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
@ -68,71 +28,5 @@ namespace OperatorApp.Controllers
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
[HttpGet]
public IActionResult Enter()
{
return View();
}
[HttpPost]
public void Enter(string login, string password)
{
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
{
throw new Exception("Введите логин и пароль");
}
APIClient.Operator = APIClient.GetRequest<OperatorViewModel>($"api/operator/login?login={login}&password={password}");
if (APIClient.Operator == null)
{
throw new Exception("Неверный логин/пароль");
}
Response.Redirect("Index");
}
[HttpGet]
public IActionResult Register()
{
return View();
}
[HttpPost]
public void Register(string login, string password, string lastname, string firstname, string middleName)
{
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(lastname) || string.IsNullOrEmpty(firstname) || string.IsNullOrEmpty(middleName))
{
throw new Exception("Введите логин, пароль и ФИО");
}
APIClient.PostRequest("api/operator/createOperator", new OperatorBindingModel
{
LastName = lastname,
FirstName = firstname,
MiddleName = middleName,
Login = login,
Password = password
});
Response.Redirect("Enter");
return;
}
[HttpGet]
public IActionResult CreateDeal()
{
return View();
}
[HttpPost]
public void CreateDeal(int clientid)
{
if (APIClient.Operator == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIClient.PostRequest("api/main/createorder", new DealBindingModel
{
ClientId = clientid,
OperatorId = APIClient.Operator.Id,
});
Response.Redirect("Index");
}
}
}

View File

@ -1,16 +0,0 @@
@{
ViewData["Title"] = "CreateDeal";
}
<div class="text-center">
<h2 class="display-4">Создание сделки</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">ID клиента:</div>
<div class="col-8"><input type="text" name="clientid" id="clientid" /></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

@ -1,22 +0,0 @@
@{
ViewData["Title"] = "CreatePayment";
}
<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">
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.Pastrys,"Id", "PastryName"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">ID клиента:</div>
<div class="col-8"><input type="text" name="clientid" id="clientid" /></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

@ -1,21 +0,0 @@
@{
ViewData["Title"] = "Enter";
}
<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="login" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></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

@ -1,63 +1,8 @@
@using BankContracts.ViewModels
@model List<DealViewModel>
@{
ViewData["Title"] = "Home Page";
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Сделки</h1>
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-action="CreateDeal">Создать сделку</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер сделки
</th>
<th>
ID клиента
</th>
<th>
ФИО оператора
</th>
<th>
Дата
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.ClientId)
</td>
<td>
@Html.DisplayFor(modelItem => item.OperatorName)
</td>
<td>
@Html.DisplayFor(modelItem => item.DealDate)
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -1,36 +1,6 @@
@using BankContracts.ViewModels
@model OperatorViewModel
@{
ViewData["Title"] = "Privacy Policy";
@{
ViewData["Title"] = "Privacy Policy";
}
<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="login" value="@Model.Login"/></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" value="@Model.Password"/></div>
</div>
<div class="row">
<div class="col-4">Фамилия:</div>
<div class="col-8"><input type="text" name="lastname" value="@Model.LastName"/></div>
</div>
<div class="row">
<div class="col-4">Имя:</div>
<div class="col-8"><input type="text" name="firstlename" value="@Model.FirstName"/></div>
</div>
<div class="row">
<div class="col-4">Отчество:</div>
<div class="col-8"><input type="text" name="middlename" value="@Model.MiddleName"/></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>
<h1>@ViewData["Title"]</h1>
<p>Use this page to detail your site's privacy policy.</p>

View File

@ -1,33 +0,0 @@
@{
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="login" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-4">Фамилия:</div>
<div class="col-8"><input type="text" name="lastname" /></div>
</div>
<div class="row">
<div class="col-4">Имя:</div>
<div class="col-8"><input type="text" name="firstname" /></div>
</div>
<div class="row">
<div class="col-4">Отчество (необязательно):</div>
<div class="col-8"><input type="text" name="middlename" /></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

@ -6,37 +6,24 @@
<title>@ViewData["Title"] - OperatorApp</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/AbstractShowClientApp.styles.css" asp-append-version="true" />
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<link rel="stylesheet" href="~/OperatorApp.styles.css" asp-append-version="true" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Оператор</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">OperatorApp</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="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-sm-row-reverse">
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Сделки</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Выплаты</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">З</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Вход</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</li>
</ul>
</div>
@ -51,11 +38,12 @@
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2023 - ConfectioneryClientApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
&copy; 2023 - OperatorApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>
</html>