Merge branch 'main' of http://student.git.athene.tech/Andrey_Abazov/CourseWork_Bank
This commit is contained in:
commit
fc620df38b
@ -211,18 +211,44 @@ namespace BankBusinessLogic.BusinessLogics
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveCurrencyTransfersToExcel(List<CurrencyBindingModel> currencies)
|
public MemoryStream SaveCurrencyTransferToPDF(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
var report = GetCurrencyTransfers(currencies);
|
if (!model.DateFrom.HasValue || !model.DateTo.HasValue)
|
||||||
throw new NotImplementedException();
|
{
|
||||||
|
throw new InvalidOperationException("Отсутствуют даты для отчёта!");
|
||||||
|
}
|
||||||
|
var result = GetTransferPurchase(model);
|
||||||
|
return _saveToPdf.CreateBankOperatorDoc(new PdfInfo
|
||||||
|
{
|
||||||
|
Title = "Отчёт по закупкам",
|
||||||
|
DateFrom = model.DateFrom.Value,
|
||||||
|
DateTo = model.DateTo.Value,
|
||||||
|
Transfers = result
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveCurrencyTransfersToWord(List<CurrencyBindingModel> currencies)
|
public MemoryStream SaveCurrencyTransfersToExcel(ReportBindingModel model, List<CurrencyBindingModel> currencies)
|
||||||
{
|
{
|
||||||
var report = GetCurrencyTransfers(currencies);
|
var report = GetCurrencyTransfers(currencies);
|
||||||
throw new NotImplementedException();
|
return _saveToExcel.CreateBankOperatorReport(new ExcelInfo
|
||||||
|
{
|
||||||
|
Title = "Отчёт по валютам",
|
||||||
|
FileName = model.FileName,
|
||||||
|
Currencies = report
|
||||||
|
});
|
||||||
}
|
}
|
||||||
public void SavePurchasePaymentToPDF(ReportBindingModel model)
|
|
||||||
|
public MemoryStream SaveCurrencyTransfersToWord(ReportBindingModel model, List<CurrencyBindingModel> currencies)
|
||||||
|
{
|
||||||
|
var report = GetCurrencyTransfers(currencies);
|
||||||
|
return _saveToWord.CreateBankOperatorDoc(new WordInfo
|
||||||
|
{
|
||||||
|
Title = "Отчёт по валютам",
|
||||||
|
FileName = model.FileName,
|
||||||
|
Currencies = report
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public MemoryStream SavePurchasePaymentToPDF(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
var report = GetPurchasePayment(model);
|
var report = GetPurchasePayment(model);
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
@ -18,8 +18,8 @@ namespace BankContracts.BusinessLogicsContracts
|
|||||||
|
|
||||||
List<ReportCurrencyTransferViewModel> GetCurrencyTransfers(List<CurrencyBindingModel> currencies);
|
List<ReportCurrencyTransferViewModel> GetCurrencyTransfers(List<CurrencyBindingModel> currencies);
|
||||||
List<ReportCurrencyPurchasePaymentViewModel> GetPurchasePayment(ReportBindingModel model);
|
List<ReportCurrencyPurchasePaymentViewModel> GetPurchasePayment(ReportBindingModel model);
|
||||||
void SaveCurrencyTransfersToWord(List<CurrencyBindingModel> currencies);
|
MemoryStream SaveCurrencyTransfersToWord(ReportBindingModel model, List<CurrencyBindingModel> currencies);
|
||||||
void SaveCurrencyTransfersToExcel(List<CurrencyBindingModel> currencies);
|
MemoryStream SaveCurrencyTransfersToExcel(ReportBindingModel model, List<CurrencyBindingModel> currencies);
|
||||||
void SavePurchasePaymentToPDF(ReportBindingModel model);
|
MemoryStream SavePurchasePaymentToPDF(ReportBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,17 +16,19 @@ namespace BankOperatorApp.Controllers
|
|||||||
private readonly IBankOperatorLogic _bankOperatorLogic;
|
private readonly IBankOperatorLogic _bankOperatorLogic;
|
||||||
private readonly ICreditProgramLogic _creditProgramLogic;
|
private readonly ICreditProgramLogic _creditProgramLogic;
|
||||||
private readonly ICurrencyLogic _currencyLogic;
|
private readonly ICurrencyLogic _currencyLogic;
|
||||||
private ICurrencyPurchaseLogic _currencyPurchaseLogic;
|
private readonly ICurrencyPurchaseLogic _currencyPurchaseLogic;
|
||||||
|
private readonly IReportLogic _reportLogic;
|
||||||
|
|
||||||
public HomeController(ILogger<HomeController> logger, IBankOperatorLogic bankOperatorLogic,
|
public HomeController(ILogger<HomeController> logger, IBankOperatorLogic bankOperatorLogic,
|
||||||
ICreditProgramLogic creditProgramLogic, ICurrencyLogic currencyLogic,
|
ICreditProgramLogic creditProgramLogic, ICurrencyLogic currencyLogic,
|
||||||
ICurrencyPurchaseLogic currencyPurchaseLogic)
|
ICurrencyPurchaseLogic currencyPurchaseLogic, IReportLogic reportLogic)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_bankOperatorLogic = bankOperatorLogic;
|
_bankOperatorLogic = bankOperatorLogic;
|
||||||
_creditProgramLogic = creditProgramLogic;
|
_creditProgramLogic = creditProgramLogic;
|
||||||
_currencyLogic = currencyLogic;
|
_currencyLogic = currencyLogic;
|
||||||
_currencyPurchaseLogic = currencyPurchaseLogic;
|
_currencyPurchaseLogic = currencyPurchaseLogic;
|
||||||
|
_reportLogic = reportLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
@ -239,5 +241,50 @@ namespace BankOperatorApp.Controllers
|
|||||||
return View(_currencyPurchaseLogic.ReadList(new CurrencyPurchaseSearchModel
|
return View(_currencyPurchaseLogic.ReadList(new CurrencyPurchaseSearchModel
|
||||||
{ BankOperatorId = APIClient.BankOperator.Id }));
|
{ BankOperatorId = APIClient.BankOperator.Id }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult CurrencyReport()
|
||||||
|
{
|
||||||
|
if (APIClient.BankOperator == 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);
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult CurrencyReport(List<int> currencies, string doctype)
|
||||||
|
{
|
||||||
|
List<CurrencyBindingModel> currencyBindings = new List<CurrencyBindingModel>();
|
||||||
|
foreach (int currencyId in currencies)
|
||||||
|
{
|
||||||
|
var currencyView = _currencyLogic.ReadElement
|
||||||
|
(new CurrencySearchModel { Id = currencyId });
|
||||||
|
if (currencyView != null) currencyBindings.Add(new CurrencyBindingModel
|
||||||
|
{
|
||||||
|
Id = currencyView.Id,
|
||||||
|
BankOperatorId = currencyView.BankOperatorId,
|
||||||
|
Name = currencyView.Name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (doctype.Equals("word"))
|
||||||
|
{
|
||||||
|
MemoryStream list = _reportLogic.SaveCurrencyTransfersToWord
|
||||||
|
(new ReportBindingModel { FileName = "test" }, currencyBindings);
|
||||||
|
return File(list, "application/vnd.openxmlformats-officedocument." +
|
||||||
|
"wordprocessingml.document", "testDoc.docx");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MemoryStream list = _reportLogic.SaveCurrencyTransfersToExcel
|
||||||
|
(new ReportBindingModel { FileName = "test" }, currencyBindings);
|
||||||
|
return File(list, "application/vnd.openxmlformats-officedocument." +
|
||||||
|
"spreadsheetml.sheet", "testExcel.xlsx");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,6 +4,8 @@ using BankContracts.StoragesContracts;
|
|||||||
using BankDatabaseImplement.Implements;
|
using BankDatabaseImplement.Implements;
|
||||||
using BankContracts.BindingModels;
|
using BankContracts.BindingModels;
|
||||||
using BankOperatorApp;
|
using BankOperatorApp;
|
||||||
|
using BankBusinessLogic.OfficePackage.Implements;
|
||||||
|
using BankBusinessLogic.OfficePackage;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
@ -19,11 +21,16 @@ builder.Services.AddTransient<IDealStorage, DealStorage>();
|
|||||||
builder.Services.AddTransient<ITransferStorage, TransferStorage>();
|
builder.Services.AddTransient<ITransferStorage, TransferStorage>();
|
||||||
builder.Services.AddTransient<IPaymentStorage, PaymentStorage>();
|
builder.Services.AddTransient<IPaymentStorage, PaymentStorage>();
|
||||||
|
|
||||||
|
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||||
|
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||||
|
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||||
|
|
||||||
|
|
||||||
builder.Services.AddTransient<ICurrencyPurchaseLogic, CurrencyPurchaseLogic>();
|
builder.Services.AddTransient<ICurrencyPurchaseLogic, CurrencyPurchaseLogic>();
|
||||||
builder.Services.AddTransient<ICurrencyLogic, CurrencyLogic>();
|
builder.Services.AddTransient<ICurrencyLogic, CurrencyLogic>();
|
||||||
builder.Services.AddTransient<ICreditProgramLogic, CreditProgramLogic>();
|
builder.Services.AddTransient<ICreditProgramLogic, CreditProgramLogic>();
|
||||||
builder.Services.AddTransient<IBankOperatorLogic, BankOperatorLogic>();
|
builder.Services.AddTransient<IBankOperatorLogic, BankOperatorLogic>();
|
||||||
|
builder.Services.AddTransient<IReportLogic, ReportLogic>();
|
||||||
|
|
||||||
builder.Services.AddControllersWithViews();
|
builder.Services.AddControllersWithViews();
|
||||||
|
|
||||||
|
28
Bank/BankOperatorApp/Views/Home/CurrencyReport.cshtml
Normal file
28
Bank/BankOperatorApp/Views/Home/CurrencyReport.cshtml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "CurrencyReport";
|
||||||
|
}
|
||||||
|
<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="currencies" name="currencies" class="form-control"
|
||||||
|
multiple asp-items="@(new SelectList(@ViewBag.Currencies,"Id", "Name"))"></select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Word</div>
|
||||||
|
@Html.RadioButton("doctype", "word", true)
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Excel</div>
|
||||||
|
@Html.RadioButton("doctype", "excel")
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
@ -27,6 +27,8 @@
|
|||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="CurrencyPurchases">Покупки валют</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="CurrencyPurchases">Покупки валют</a>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="CurrencyReport">Отчет по валютам</a>
|
||||||
</li>
|
</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>
|
||||||
|
Loading…
Reference in New Issue
Block a user