:(
This commit is contained in:
parent
79fe2b3214
commit
dec1ccfe91
60
Bank/BankClientApp/Controllers/AuthorizationController.cs
Normal file
60
Bank/BankClientApp/Controllers/AuthorizationController.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.BusinessLogicContracts;
|
||||
using BankContracts.SearchModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BankClientApp.Controllers
|
||||
{
|
||||
public class AuthorizationController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
private readonly IClientLogic _clientLogic;
|
||||
|
||||
public AuthorizationController(ILogger<HomeController> logger, IClientLogic clientLogic)
|
||||
{
|
||||
_clientLogic = clientLogic;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Register()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Register(ClientBindingModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.PhoneNumber) ||
|
||||
string.IsNullOrEmpty(model.FirstName) ||
|
||||
string.IsNullOrEmpty(model.MiddleName) ||
|
||||
string.IsNullOrEmpty(model.LastName) ||
|
||||
string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
throw new Exception("Все поля должны быть заполнены");
|
||||
}
|
||||
_clientLogic.Create(model);
|
||||
_logger.LogInformation("Зарегистрирован клиент");
|
||||
Response.Redirect("Enter");
|
||||
}
|
||||
|
||||
public IActionResult Enter()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Enter(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.PhoneNumber) || string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
throw new Exception("Все поля должны быть заполнены");
|
||||
}
|
||||
var result = _clientLogic.ReadElement(model);
|
||||
HttpContext.Session.SetString(SessionKeys.ClientPhoneNumber, model.PhoneNumber);
|
||||
HttpContext.Session.SetString(SessionKeys.ClientPassword, model.Password);
|
||||
_logger.LogInformation("Был осуществел вход за клиента {@client} и добавлены его данные в сессию", result);
|
||||
Response.Redirect("../../Home/Index");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,26 +1,70 @@
|
||||
using BankClientApp.Models;
|
||||
using BankContracts.ViewModels;
|
||||
using BankClientApp.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using Newtonsoft.Json;
|
||||
using BankContracts.BusinessLogicContracts;
|
||||
using BankClientApp.Filter;
|
||||
using BankContracts.BindingModels;
|
||||
using BankDataModels.ProxyModels;
|
||||
|
||||
namespace BankClientApp.Controllers
|
||||
{
|
||||
[AuthorizationFilter]
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
private readonly IClientLogic _clientLogic;
|
||||
private readonly IPurchaseLogic _purchaseLogic;
|
||||
private readonly IOperationLogic _operationLogic;
|
||||
private readonly IReportLogic _reportLogic;
|
||||
private readonly IPaymentLogic _paymentLogic;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
private ClientViewModel? _client;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger,
|
||||
IClientLogic clientLogic, IPurchaseLogic purchaseLogic, IOperationLogic operationLogic,
|
||||
IReportLogic reportLogic, IPaymentLogic paymentLogic)
|
||||
{
|
||||
_reportLogic = reportLogic;
|
||||
_clientLogic = clientLogic;
|
||||
_logger = logger;
|
||||
_purchaseLogic = purchaseLogic;
|
||||
_operationLogic = operationLogic;
|
||||
_paymentLogic = paymentLogic;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
private ClientViewModel Client
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_client == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
_client = _clientLogic.ReadElement(new()
|
||||
{
|
||||
PhoneNumber = HttpContext.Session.GetString(SessionKeys.ClientPhoneNumber),
|
||||
Password = HttpContext.Session.GetString(SessionKeys.ClientPassword),
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Не удалось получить пользователя, хотя был пройден фильтр авторизации");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
return _client;
|
||||
}
|
||||
}
|
||||
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
return View();
|
||||
return View(Client);
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
@ -28,5 +72,144 @@ namespace BankClientApp.Controllers
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
|
||||
public IActionResult Purchases()
|
||||
{
|
||||
return View(_purchaseLogic.ReadList(new() { ClientId = Client.Id }));
|
||||
}
|
||||
public FileResult ReportOperationsInWord(int[] ids)
|
||||
{
|
||||
_logger.LogInformation("Запрошен отчет в формате word");
|
||||
_logger.LogInformation("Получено {count} обследований для отчета", ids.Length);
|
||||
|
||||
MemoryStream mstream = new();
|
||||
_reportLogic.SaveOperationsToWord(new()
|
||||
{
|
||||
Ids = ids,
|
||||
Stream = mstream,
|
||||
});
|
||||
return File(mstream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Octet, "reportWord.docx");
|
||||
}
|
||||
|
||||
public FileResult ReportOperationsInExcel(int[] ids)
|
||||
{
|
||||
_logger.LogInformation("Запрошен отчет в формате excel");
|
||||
_logger.LogInformation("Получено {count} операций для отчета", ids.Length);
|
||||
|
||||
MemoryStream mstream = new();
|
||||
_reportLogic.SaveOperationsToExcel(new()
|
||||
{
|
||||
Ids = ids,
|
||||
Stream = mstream
|
||||
});
|
||||
return File(mstream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Octet, "reportExcel.xlsx");
|
||||
}
|
||||
public IActionResult PurchasesReport()
|
||||
{
|
||||
return View(_purchaseLogic.ReadList(new() { ClientId = Client.Id }));
|
||||
}
|
||||
|
||||
public IActionResult Payment()
|
||||
{
|
||||
ViewBag.Purchases = _purchaseLogic.ReadList(new() { ClientId = Client.Id });
|
||||
return View();
|
||||
}
|
||||
|
||||
public List<OperationViewModel> GetOperations(int purchase)
|
||||
{
|
||||
return _operationLogic.ReadList(new() { PurchasesIds = new() { purchase } }); ;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Purchase(int? id)
|
||||
{
|
||||
return View(Tuple.Create(
|
||||
id.HasValue ? _purchaseLogic.ReadElement(new() { Id = id }) : null,
|
||||
_operationLogic.ReadList()));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Purchase(DateTime datePurchase, List<int> carsIds, List<int> countOperations)
|
||||
{
|
||||
var isOperationUpdate = Request.RouteValues.TryGetValue("id", out var identValue);
|
||||
isOperationUpdate &= int.TryParse((string?)identValue, out var id);
|
||||
|
||||
_logger.LogInformation("При изменении операции были получены данные:{idUpdated}, {datePurchase}", identValue, datePurchase);
|
||||
PurchaseBindingModel model = new()
|
||||
{
|
||||
DatePurchase = DateOnly.FromDateTime(datePurchase),
|
||||
OperationsModel = carsIds.Zip(countOperations).ToDictionary(
|
||||
x => x.First,
|
||||
x => new OperationByPurchaseModel() { OperationId = x.First, CountOperations = x.Second }
|
||||
),
|
||||
};
|
||||
if (isOperationUpdate)
|
||||
{
|
||||
model.Id = id;
|
||||
_purchaseLogic.Update(model);
|
||||
Response.Redirect("../Purchases");
|
||||
}
|
||||
else
|
||||
{
|
||||
model.ClientId = Client.Id;
|
||||
_purchaseLogic.Create(model);
|
||||
Response.Redirect("Purchases");
|
||||
}
|
||||
}
|
||||
|
||||
public IActionResult RemovePurchase(int id)
|
||||
{
|
||||
_purchaseLogic.Delete(new() { Id = id });
|
||||
return Redirect("~/Home/Purchases");
|
||||
}
|
||||
[HttpPost]
|
||||
public Tuple<double, double> CalcPrice(int purchase, int car)
|
||||
{
|
||||
_paymentLogic.GetPaymentInfo(new() { OperationId = car, PurchaseId = purchase },
|
||||
out var fullPrice, out var paidPrice);
|
||||
return Tuple.Create(paidPrice, fullPrice - paidPrice);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Payment(double resultSum, int purchase, int car)
|
||||
{
|
||||
_logger.LogInformation("Получены данные: {resultSum}; {purchase} {car}", resultSum, purchase, car);
|
||||
_paymentLogic.Create(new()
|
||||
{
|
||||
PaidPrice = resultSum,
|
||||
Date = DateOnly.FromDateTime(DateTime.Now),
|
||||
OperationByPurchaseId = _purchaseLogic.ReadElement(new() { Id = purchase }).OperationsModel[car].Id,
|
||||
});
|
||||
Response.Redirect("/Home/Payment");
|
||||
}
|
||||
|
||||
public IActionResult ReportFromPurchases(string? getReport, string? sendToMail, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
_logger.LogInformation("Попытка получить отчет: {@getReport}; {@sendToMail} Период: {0}---{1}", getReport, sendToMail, startDate, endDate);
|
||||
if (startDate > endDate)
|
||||
{
|
||||
throw new Exception("Дата начала больше даты конца периода");
|
||||
}
|
||||
if (getReport != null)
|
||||
{
|
||||
return View(_purchaseLogic.ReadList(new()
|
||||
{
|
||||
DateFrom = DateOnly.FromDateTime(startDate),
|
||||
DateTo = DateOnly.FromDateTime(endDate)
|
||||
}));
|
||||
}
|
||||
if (sendToMail != null)
|
||||
{
|
||||
_reportLogic.SendCostsToEmail(
|
||||
option: new()
|
||||
{
|
||||
DateFrom = DateOnly.FromDateTime(startDate),
|
||||
DateTo = DateOnly.FromDateTime(endDate)
|
||||
},
|
||||
email: Client.Email
|
||||
);
|
||||
}
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
8
Bank/BankClientApp/SessionKeys.cs
Normal file
8
Bank/BankClientApp/SessionKeys.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace BankClientApp
|
||||
{
|
||||
public static class SessionKeys
|
||||
{
|
||||
public const string ClientPhoneNumber = "AuthenticationClientPhoneNumber";
|
||||
public const string ClientPassword = "AuthenticationClientPassword";
|
||||
}
|
||||
}
|
26
Bank/BankClientApp/Views/Home/Enter.cshtml
Normal file
26
Bank/BankClientApp/Views/Home/Enter.cshtml
Normal file
@ -0,0 +1,26 @@
|
||||
@{
|
||||
ViewData["Title"] = "Клиент-вход";
|
||||
}
|
||||
<div>
|
||||
<h2 class="display-4">@ViewData["Title"]</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row mb-2">
|
||||
<div class="col-2">Номер телефона:</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" name="PhoneNumber" placeholder="Номер телефона">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-2">Пароль:</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="password" class="form-control" name="Password" placeholder="Пароль">
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center mb-2">
|
||||
<input type="submit" value="Войти" class="btn btn-primary" />
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<a class="align-content-center" asp-controller="Authorization" asp-action="Register">Зарегистрироваться.</a>
|
||||
</div>
|
||||
</form>
|
@ -3,6 +3,6 @@
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<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>
|
||||
<h1 class="display-4">Добро пожаловать в «Банк «Вы банкрот». Клиент»</h1>
|
||||
<img src="https://gas-kvas.com/grafic/uploads/posts/2024-01/gas-kvas-com-p-nadpis-bank-na-prozrachnom-fone-40.png" alt="Logo" />
|
||||
</div>
|
||||
|
77
Bank/BankClientApp/Views/Home/Payment.cshtml
Normal file
77
Bank/BankClientApp/Views/Home/Payment.cshtml
Normal file
@ -0,0 +1,77 @@
|
||||
@{
|
||||
ViewData["Title"] = "Оплата операции";
|
||||
}
|
||||
<div>
|
||||
<h2 class="display-4">@ViewData["Title"]</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row mb-2">
|
||||
<div class="col-2">Сделки:</div>
|
||||
<div class="col-sm-10">
|
||||
<select id="purchase" name="purchase" class="form-control" asp-items="@(new SelectList(@ViewBag.Purchases, "Id", "Id"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-2">Операции:</div>
|
||||
<div class="col-sm-10">
|
||||
<select id="car" name="car" class="form-control"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-2">Внесенная сумма:</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="number" class="form-control" name ="paidSum" id="paidSum" placeholder="Внесенная сумма" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-2">Сумма к оплате:</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="number" class="form-control" name="resultSum" id="resultSum" placeholder="Сумма к оплате">
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center mb-2">
|
||||
<input type="submit" value="Оплатить" class="btn btn-primary" id="submit" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
$('#purchase').on('change', updateInspections);
|
||||
$('#car').on('change', check);
|
||||
updateInspections();
|
||||
|
||||
function updateInspections() {
|
||||
$.get({
|
||||
url: "/Home/GetOperations",
|
||||
data: { purchase: $('#purchase').val() },
|
||||
success: function(data) {
|
||||
$('#car').empty();
|
||||
$.each(data, function(i, car)
|
||||
{
|
||||
$('#car').append( new Option(car.mark +" "+ car.model, car.id) );
|
||||
});
|
||||
$('#car').val(data[0].id).change();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function check() {
|
||||
var paidSum = $('#paidSum').val();
|
||||
var purchase = $('#purchase').val();
|
||||
var car = $('#car').val();
|
||||
if (true) {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "/Home/CalcPrice",
|
||||
data: { paidSum: paidSum, purchase: purchase, car: car },
|
||||
success: function (result) {
|
||||
console.log(result);
|
||||
$("#paidSum").val(result.item1);
|
||||
$("#resultSum").val(result.item2);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
</script>
|
||||
}
|
@ -1,6 +1,48 @@
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
@using BankContracts.ViewModels;
|
||||
|
||||
<p>Use this page to detail your site's privacy policy.</p>
|
||||
@model ClientViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Личные данные клиента";
|
||||
}
|
||||
<div>
|
||||
<h2 class="display-4">@ViewData["Title"]</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row mb-2">
|
||||
<div class="col-2">Номер телефона:</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="input_phoneNumber" placeholder="Номер телефона" value="@Model.PhoneNumber" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-2">почта:</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="input_email" placeholder="почта" value="@Model.Email" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-2">Фамилия:</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="input_first_name" placeholder="Фамилия" value="@Model.LastName" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-2">Имя:</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="input_middle_name" placeholder="Имя" value="@Model.FirstName" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-2">Отчество:</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="input_last_name" placeholder="Отчество" value="@Model.MiddleName" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-2">Пароль:</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="password" placeholder="Пароль" value="@Model.Password" readonly>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
110
Bank/BankClientApp/Views/Home/Purchase.cshtml
Normal file
110
Bank/BankClientApp/Views/Home/Purchase.cshtml
Normal file
@ -0,0 +1,110 @@
|
||||
@using BankContracts.ViewModels
|
||||
@using Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@model Tuple<BankContracts.ViewModels.PurchaseViewModel?, List<OperationViewModel>>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = Model.Item1 == null ? "Создание сделки" : "Изменение сделки";
|
||||
}
|
||||
|
||||
<div>
|
||||
<h2 class="display-4">@ViewData["Title"]</h2>
|
||||
</div>
|
||||
<form id="formId" name="formId">
|
||||
<div class="row mb-2">
|
||||
<div class="col-2">Дата сделки:</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="date" class="form-control" name="datePurchase" id="datePurchase" placeholder="Дата сделки">
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center mb-2">
|
||||
<input type="submit" value="Создать" class="btn btn-primary" id="submit"/>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Включить в сделку</th>
|
||||
<th>Кол-во операций</th>
|
||||
<th>Логин сотрудника</th>
|
||||
<th>Вид</th>
|
||||
<th>Тип</th>
|
||||
<th>Стоимость</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var car in Model.Item2)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" name="cars" id="@car.Id">
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" class="custom-control-input" name="countOperations" id="date-@car.Id">
|
||||
</td>
|
||||
<td>@Html.DisplayFor(modelItem => car.EmployeePhoneNumber)</td>
|
||||
<td>@Html.DisplayFor(modelItem => car.Mark)</td>
|
||||
<td>@Html.DisplayFor(modelItem => car.Model)</td>
|
||||
<td>@Html.DisplayFor(modelItem => car.Price)</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
@section Scripts
|
||||
{
|
||||
@if (Model.Item1 != null)
|
||||
{
|
||||
@foreach (var car in Model.Item1.OperationsModel)
|
||||
{
|
||||
<script>
|
||||
$("#@car.Key").attr('checked', true);
|
||||
$("#date-@car.Key").val("@car.Value.CountOperations");
|
||||
</script>
|
||||
}
|
||||
<script>
|
||||
$("#submit").val("Изменить");
|
||||
$("#name").attr('readonly', true);
|
||||
$("#datePurchase").attr('readonly', true);
|
||||
$("#datePurchase").val("@Html.Raw(Model.Item1.DatePurchase.ToString("yyyy-MM-dd"))");
|
||||
|
||||
</script>
|
||||
}
|
||||
<script>
|
||||
function getInputData() {
|
||||
const ids = [];
|
||||
const dates = [];
|
||||
var res = $("input[name=cars]");
|
||||
var resDates = $("input[name=countOperations]");
|
||||
|
||||
for (var i = 0; i < res.length; i++) {
|
||||
if (res[i].checked) {
|
||||
ids.push(res[i].id);
|
||||
dates.push(resDates[i].value);
|
||||
}
|
||||
}
|
||||
return [ids, dates];
|
||||
}
|
||||
const form = document.forms.namedItem("formId");
|
||||
|
||||
form.addEventListener("submit", function(event) {
|
||||
event.preventDefault();
|
||||
new FormData(form);
|
||||
});
|
||||
|
||||
form.addEventListener("formdata", event => {
|
||||
let result = getInputData();
|
||||
$.post({
|
||||
url: window.location,
|
||||
data: {
|
||||
datePurchase: $("#datePurchase").val(),
|
||||
carsIds: result[0],
|
||||
countOperations: result[1]
|
||||
},
|
||||
success: () => {
|
||||
window.location.replace("/Home/Purchases");
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
33
Bank/BankClientApp/Views/Home/Purchases.cshtml
Normal file
33
Bank/BankClientApp/Views/Home/Purchases.cshtml
Normal file
@ -0,0 +1,33 @@
|
||||
@using BankContracts.ViewModels;
|
||||
|
||||
@model List<PurchaseViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Сделки";
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
<div class="text-center">
|
||||
<a asp-action="Purchase">Создать сделку</a>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Номер телефона клиента</th>
|
||||
<th>Дата</th>
|
||||
<th>Изменить</th>
|
||||
<th>Удалить</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var purchase in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>@Html.DisplayFor(modelItem => purchase.ClientPhoneNumber)</td>
|
||||
<td>@Html.Raw(purchase.DatePurchase)</td>
|
||||
<td><a asp-action="Purchase" asp-route-id="@purchase.Id">Изменить</a></td>
|
||||
<td><a asp-action="RemovePurchase" asp-route-id="@purchase.Id">Удалить</a></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
88
Bank/BankClientApp/Views/Home/PurchasesReport.cshtml
Normal file
88
Bank/BankClientApp/Views/Home/PurchasesReport.cshtml
Normal file
@ -0,0 +1,88 @@
|
||||
@using BankContracts.ViewModels;
|
||||
|
||||
@model List<PurchaseViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Отчет по операциям";
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
<h5>Выбрать сделки, по которым будут включены в отчет операции</h5>
|
||||
<div class="text-center">
|
||||
<a id="reportToWord" href="javascript:void(0)" onclick="reportToWord();">Отчет в word</a>
|
||||
<a id="reportToExcel" href="javascript:void(0)" onclick="reportToExcel();">Отчет в excel</a>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Включить в отчет</th>
|
||||
<th>Сделка</th>
|
||||
<th>Номер телефона клиента</th>
|
||||
<th>Дата</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var purchase in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" name="isIncludeInReports" id="@purchase.Id" checked>
|
||||
</div>
|
||||
</td>
|
||||
<td>@purchase.Id</td>
|
||||
|
||||
<td>@purchase.ClientPhoneNumber</td>
|
||||
<td>@purchase.DatePurchase</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
jQuery.ajaxSettings.traditional = true;
|
||||
function getIds() {
|
||||
const ids = [];
|
||||
var res = $("input[name=isIncludeInReports]");
|
||||
|
||||
for (var i = 0; i < res.length; i++) {
|
||||
if (res[i].checked) {
|
||||
ids.push(res[i].id);
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
function downloadFile(data, textStatus, request) {
|
||||
var a = document.createElement('a');
|
||||
var url = window.URL.createObjectURL(data);
|
||||
a.href = url;
|
||||
a.download = request.getResponseHeader("content-disposition").split(";")[1].split("=")[1];
|
||||
document.body.append(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
window.URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
function reportToWord() {
|
||||
$.get({
|
||||
url: '/Home/ReportOperationsInWord',
|
||||
xhrFields: {
|
||||
responseType: 'blob'
|
||||
},
|
||||
data: { ids: getIds() },
|
||||
success: downloadFile
|
||||
});
|
||||
}
|
||||
function reportToExcel() {
|
||||
$.get({
|
||||
url: '/Home/ReportOperationsInExcel',
|
||||
xhrFields: {
|
||||
responseType: 'blob'
|
||||
},
|
||||
data: { ids: getIds() },
|
||||
success: downloadFile
|
||||
});
|
||||
}
|
||||
</script>
|
||||
}
|
50
Bank/BankClientApp/Views/Home/Register.cshtml
Normal file
50
Bank/BankClientApp/Views/Home/Register.cshtml
Normal file
@ -0,0 +1,50 @@
|
||||
@{
|
||||
ViewData["Title"] = "Регистрация";
|
||||
}
|
||||
<div>
|
||||
<h2 class="display-4">@ViewData["Title"]</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row mb-2">
|
||||
<div class="col-2">Номер телефона:</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" name="PhoneNumber" placeholder="Номер телефона">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-2">Почта:</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" name="Email" placeholder="Почта">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-2">Фамилия:</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" name="LastName" placeholder="Фамилия">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-2">Имя:</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" name="FirstName" placeholder="Имя">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-2">Отчество:</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" name="MiddleName" placeholder="Отчество">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-2">Пароль:</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" name="Password" placeholder="Пароль">
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center mb-2">
|
||||
<input type="submit" value="Зарегистрироваться" class="btn btn-primary" />
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<a class="align-content-center" asp-controller="Authorization" asp-action="Enter">Елси вы зарегестрированы-войдите.</a>
|
||||
</div>
|
||||
</form>
|
58
Bank/BankClientApp/Views/Home/ReportFromPurchases.cshtml
Normal file
58
Bank/BankClientApp/Views/Home/ReportFromPurchases.cshtml
Normal file
@ -0,0 +1,58 @@
|
||||
@model List<BankContracts.ViewModels.PurchaseViewModel>?
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Список сделок с затратами";
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
<form method="post">
|
||||
<div class="align-content-center row mb-3">
|
||||
<div class="col-sm-auto">
|
||||
<label for="startDate">С:</label>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<input name="startDate" id="startDate" class="form-control" type="date"/>
|
||||
</div>
|
||||
<div class="col-sm-auto">
|
||||
<label for="endDate">По:</label>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<input name="endDate" id="endDate" class="form-control" type="date" value="@DateTime.Today.ToString("yyyy-MM-dd")" />
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<input type="submit" name="getReport" class="btn btn-primary" value="Сформировать отчет"/>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<input type="submit" name="sendToMail" class="btn btn-primary" value="Отправить на почту" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="text-center">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Дата сделки</th>
|
||||
<th>Сделка</th>
|
||||
<th>Затрата</th>
|
||||
<th>Сумма затраты</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="fillReportPurchase">
|
||||
@if (Model != null) {
|
||||
foreach (var purchase in Model)
|
||||
{
|
||||
foreach (var cost in purchase.CostViewModels)
|
||||
{
|
||||
<tr>
|
||||
<td>@purchase.DatePurchase</td>
|
||||
<td>@purchase.Id</td>
|
||||
<td>@cost.NameOfCost</td>
|
||||
<td>@(cost.Price * cost.PurchaseModels[purchase.Id].Count)</td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - BankClientApp</title>
|
||||
<title>@ViewData["Title"] - Клиент Банк "Вы банкрот"</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="~/BankClientApp.styles.css" asp-append-version="true" />
|
||||
@ -12,7 +12,7 @@
|
||||
<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">BankClientApp</a>
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Банк клиент</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>
|
||||
@ -20,10 +20,25 @@
|
||||
<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">Home</a>
|
||||
<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="Privacy">Privacy</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Authorization" asp-action="Enter">Вход</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Authorization" asp-action="Register">Регистрация</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Purchases">Сделки</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="PurchasesReport">Получить список операций</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Payment">Оплата</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="ReportFromPurchases">Получить отчет по сделкам</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -38,7 +53,7 @@
|
||||
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2024 - BankClientApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
© 2024 - Клиент Банк "Вы банкрот" - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user