Compare commits

..

No commits in common. "fc620df38bef7f5ce4fd761d5ddc468b3223741e" and "07171efc76714001161df5ff757ab2907b693172" have entirely different histories.

5 changed files with 8 additions and 69 deletions

View File

@ -111,7 +111,7 @@ namespace BankDatabaseImplement.Models
public void UpdateCurrencies(BankDatabase context, PaymentBindingModel model) public void UpdateCurrencies(BankDatabase context, PaymentBindingModel model)
{ {
var currencyPayments = context.CurrencyPayments.Where(rec => rec.PaymentId == model.Id).ToList(); var currencyPayments = context.CurrencyPayments.Where(rec => rec.PaymentId == model.Id).ToList();
if (currencyPayments != null) if (currencyPayments != null && currencyPayments.Count > 0)
{ {
context.CurrencyPayments.RemoveRange(currencyPayments.Where(rec => !model.CurrencyPayments.ContainsKey(rec.CurrencyId))); context.CurrencyPayments.RemoveRange(currencyPayments.Where(rec => !model.CurrencyPayments.ContainsKey(rec.CurrencyId)));
context.SaveChanges(); context.SaveChanges();

View File

@ -21,10 +21,9 @@ namespace OperatorApp.Controllers
private readonly ITransferLogic _transferLogic; private readonly ITransferLogic _transferLogic;
private readonly IOperatorLogic _operatorLogic; private readonly IOperatorLogic _operatorLogic;
private readonly IReportLogic _reportLogic; private readonly IReportLogic _reportLogic;
private readonly ICurrencyLogic _currencyLogic;
private readonly AbstractMailWorker _mailWorker; private readonly AbstractMailWorker _mailWorker;
public HomeController(ILogger<HomeController> logger, IDealLogic dealLogic, IPaymentLogic paymentLogic, ITransferLogic transferLogic, IOperatorLogic operatorLogic, IReportLogic reportLogic, ICurrencyLogic currencyLogic, AbstractMailWorker mailWorker) public HomeController(ILogger<HomeController> logger, IDealLogic dealLogic, IPaymentLogic paymentLogic, ITransferLogic transferLogic, IOperatorLogic operatorLogic, IReportLogic reportLogic, AbstractMailWorker mailWorker)
{ {
_logger = logger; _logger = logger;
_dealLogic = dealLogic; _dealLogic = dealLogic;
@ -32,7 +31,6 @@ namespace OperatorApp.Controllers
_transferLogic = transferLogic; _transferLogic = transferLogic;
_operatorLogic = operatorLogic; _operatorLogic = operatorLogic;
_reportLogic = reportLogic; _reportLogic = reportLogic;
_currencyLogic = currencyLogic;
_mailWorker = mailWorker; _mailWorker = mailWorker;
} }
@ -346,36 +344,5 @@ namespace OperatorApp.Controllers
return Redirect("/"); 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("/");
}
} }
} }

View File

@ -31,7 +31,6 @@ builder.Services.AddTransient<IPaymentLogic, PaymentLogic>();
builder.Services.AddTransient<ITransferLogic, TransferLogic>(); builder.Services.AddTransient<ITransferLogic, TransferLogic>();
builder.Services.AddTransient<IOperatorLogic, OperatorLogic>(); builder.Services.AddTransient<IOperatorLogic, OperatorLogic>();
builder.Services.AddTransient<IReportLogic, ReportLogic>(); builder.Services.AddTransient<IReportLogic, ReportLogic>();
builder.Services.AddTransient<ICurrencyLogic, CurrencyLogic>();
var app = builder.Build(); var app = builder.Build();

View File

@ -1,24 +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="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>

View File

@ -31,15 +31,6 @@
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Transfers">Зачисления</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Transfers">Зачисления</a>
</li> </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"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
</li> </li>
@ -49,6 +40,12 @@
<li class="nav-item"> <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="Register">Регистрация</a>
</li> </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> </ul>
</div> </div>
</div> </div>