Compare commits
2 Commits
07171efc76
...
fc620df38b
Author | SHA1 | Date | |
---|---|---|---|
|
fc620df38b | ||
|
59f7017528 |
@ -111,7 +111,7 @@ namespace BankDatabaseImplement.Models
|
||||
public void UpdateCurrencies(BankDatabase context, PaymentBindingModel model)
|
||||
{
|
||||
var currencyPayments = context.CurrencyPayments.Where(rec => rec.PaymentId == model.Id).ToList();
|
||||
if (currencyPayments != null && currencyPayments.Count > 0)
|
||||
if (currencyPayments != null)
|
||||
{
|
||||
context.CurrencyPayments.RemoveRange(currencyPayments.Where(rec => !model.CurrencyPayments.ContainsKey(rec.CurrencyId)));
|
||||
context.SaveChanges();
|
||||
|
@ -21,9 +21,10 @@ namespace OperatorApp.Controllers
|
||||
private readonly ITransferLogic _transferLogic;
|
||||
private readonly IOperatorLogic _operatorLogic;
|
||||
private readonly IReportLogic _reportLogic;
|
||||
private readonly ICurrencyLogic _currencyLogic;
|
||||
private readonly AbstractMailWorker _mailWorker;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger, IDealLogic dealLogic, IPaymentLogic paymentLogic, ITransferLogic transferLogic, IOperatorLogic operatorLogic, IReportLogic reportLogic, AbstractMailWorker mailWorker)
|
||||
public HomeController(ILogger<HomeController> logger, IDealLogic dealLogic, IPaymentLogic paymentLogic, ITransferLogic transferLogic, IOperatorLogic operatorLogic, IReportLogic reportLogic, ICurrencyLogic currencyLogic, AbstractMailWorker mailWorker)
|
||||
{
|
||||
_logger = logger;
|
||||
_dealLogic = dealLogic;
|
||||
@ -31,6 +32,7 @@ namespace OperatorApp.Controllers
|
||||
_transferLogic = transferLogic;
|
||||
_operatorLogic = operatorLogic;
|
||||
_reportLogic = reportLogic;
|
||||
_currencyLogic = currencyLogic;
|
||||
_mailWorker = mailWorker;
|
||||
}
|
||||
|
||||
@ -344,5 +346,36 @@ namespace OperatorApp.Controllers
|
||||
return Redirect("/");
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult AddCurrenciesToPayment()
|
||||
{
|
||||
if (APIClient.Operator == null)
|
||||
{
|
||||
Response.WriteAsync($"<script language=\"javascript\">alert('You need to login!');window.location.replace('/Home/Enter');</script>");
|
||||
return Redirect("/Home/Enter");
|
||||
}
|
||||
ViewBag.Currencies = _currencyLogic.ReadList(null);
|
||||
ViewBag.Payments = _paymentLogic.ReadList(null);
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void AddCurrenciesToPayment(int payment, List<int> currencies)
|
||||
{
|
||||
if (APIClient.Operator == null)
|
||||
{
|
||||
Response.WriteAsync($"<script language=\"javascript\">alert('You need to login!');window.location.replace('/Home/Enter');</script>");
|
||||
Redirect("/Home/Enter");
|
||||
}
|
||||
var paymentModel = _paymentLogic.ReadElement(new PaymentSearchModel { Id = payment });
|
||||
Dictionary<int, ICurrencyModel> updCurrencies = new Dictionary<int, ICurrencyModel>();
|
||||
foreach (var currencyId in currencies)
|
||||
{
|
||||
var currency = _currencyLogic.ReadElement(new CurrencySearchModel { Id = currencyId });
|
||||
if (currency != null) updCurrencies.Add(currencyId, currency);
|
||||
}
|
||||
_paymentLogic.Update(new PaymentBindingModel { Id = paymentModel.Id, PaymentDate = paymentModel.PaymentDate, CurrencyPayments = updCurrencies });
|
||||
Response.WriteAsync($"<script language=\"javascript\">alert('Success!');window.location.replace('/Home/Enter');</script>");
|
||||
Redirect("/");
|
||||
}
|
||||
}
|
||||
}
|
@ -31,6 +31,7 @@ builder.Services.AddTransient<IPaymentLogic, PaymentLogic>();
|
||||
builder.Services.AddTransient<ITransferLogic, TransferLogic>();
|
||||
builder.Services.AddTransient<IOperatorLogic, OperatorLogic>();
|
||||
builder.Services.AddTransient<IReportLogic, ReportLogic>();
|
||||
builder.Services.AddTransient<ICurrencyLogic, CurrencyLogic>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
24
Bank/OperatorApp/Views/Home/AddCurrenciesToPayment.cshtml
Normal file
24
Bank/OperatorApp/Views/Home/AddCurrenciesToPayment.cshtml
Normal file
@ -0,0 +1,24 @@
|
||||
@{
|
||||
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="payment" name="payment" class="form-control" required asp-items="@(new SelectList(@ViewBag.Payments,"Id", "Id"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Валюты:</div>
|
||||
<div class="col-8">
|
||||
<select id="currencies" name="currencies" class="form-control" required multiple asp-items="@(new SelectList(@ViewBag.Currencies,"Id", "Name"))"></select>
|
||||
</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>
|
@ -31,6 +31,15 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Transfers">Зачисления</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="AddCurrenciesToPayment">Привязка валют</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="PaymentsReport">Списки по выплатам</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="TransfersReport">Отчёт по зачислениям</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||
</li>
|
||||
@ -40,12 +49,6 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="PaymentsReport">Списки по выплатам</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="TransfersReport">Отчёт по зачислениям</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user