Правки по части доступа и начало создания отчётов.
This commit is contained in:
parent
a1742e2ec0
commit
06bbe74214
@ -41,7 +41,7 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
DateTo = model.DateTo,
|
||||
}).Select(x => new ReportClientViewModel
|
||||
{
|
||||
CardId = x.CardId,
|
||||
CardNumber = x.CardNumber,
|
||||
SumOperation = x.Sum,
|
||||
DateComplite = x.DateOpen
|
||||
}).ToList();
|
||||
@ -55,7 +55,7 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
DateFrom = model.DateTo,
|
||||
}).Select(x => new ReportClientViewModel
|
||||
{
|
||||
CardId = x.CardId,
|
||||
CardNumber = x.CardNumber,
|
||||
SumOperation = x.Sum,
|
||||
DateComplite = x.DateClose
|
||||
}).ToList();
|
||||
@ -66,11 +66,6 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SaveCreditingToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SaveCreditingToWordFile(ReportBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
@ -81,14 +76,23 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SaveDebitingToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SaveDebitingToWordFile(ReportBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
//отчёт в формате PDF для клиента
|
||||
public void SaveClientReportToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToPdf.CreateDoc(new PdfInfoClient
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Отчёт по операциям с картой",
|
||||
DateFrom = model.DateFrom!.Value,
|
||||
DateTo = model.DateTo!.Value,
|
||||
ReportCrediting = GetCrediting(model),
|
||||
ReportDebiting = GetDebiting(model)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace BankYouBankruptBusinessLogic.OfficePackage
|
||||
public abstract class AbstractSaveToPdfCashier
|
||||
{
|
||||
//публичный метод создания документа. Описание методов ниже
|
||||
public void CreateDoc(PdfInfo info)
|
||||
public void CreateDoc(PdfInfoClient info)
|
||||
{
|
||||
CreatePdf(info);
|
||||
|
||||
@ -29,13 +29,32 @@ namespace BankYouBankruptBusinessLogic.OfficePackage
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
|
||||
//TODO
|
||||
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
|
||||
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Статус заказа", "Сумма" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
|
||||
foreach (var report in info.ReportAccounts)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { report.AccountSenderId.ToString(), report.AccountPayeeId.ToString(), report.DateComplite.ToShortDateString(), report.SumOperation.ToString() },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
}
|
||||
|
||||
//CreateParagraph(new PdfParagraph { Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Right });
|
||||
|
||||
SavePdf(info);
|
||||
}
|
||||
|
||||
/// Создание pdf-файла
|
||||
protected abstract void CreatePdf(PdfInfo info);
|
||||
protected abstract void CreatePdf(PdfInfoClient info);
|
||||
|
||||
/// Создание параграфа с текстом
|
||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||
@ -47,6 +66,6 @@ namespace BankYouBankruptBusinessLogic.OfficePackage
|
||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||
|
||||
/// Сохранение файла
|
||||
protected abstract void SavePdf(PdfInfo info);
|
||||
protected abstract void SavePdf(PdfInfoClient info);
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace BankYouBankruptBusinessLogic.OfficePackage
|
||||
public abstract class AbstractSaveToPdfClient
|
||||
{
|
||||
//публичный метод создания документа. Описание методов ниже
|
||||
public void CreateDoc(PdfInfo info)
|
||||
public void CreateDoc(PdfInfoClient info)
|
||||
{
|
||||
CreatePdf(info);
|
||||
|
||||
@ -29,13 +29,44 @@ namespace BankYouBankruptBusinessLogic.OfficePackage
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
|
||||
//TODO
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Номер карты", "Сумма операции", "Дата операции" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
|
||||
CreateParagraph(new PdfParagraph { Text = "Отчёт по пополнениям", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||
|
||||
foreach (var report in info.ReportCrediting)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { report.CardNumber, report.SumOperation.ToString(), report.DateComplite.ToString() },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
}
|
||||
|
||||
CreateParagraph(new PdfParagraph { Text = "Отчёт по снятиям", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||
|
||||
foreach (var report in info.ReportDebiting)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { report.CardNumber, report.SumOperation.ToString(), report.DateComplite.ToString() },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
}
|
||||
|
||||
//CreateParagraph(new PdfParagraph { Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Right });
|
||||
|
||||
SavePdf(info);
|
||||
}
|
||||
|
||||
/// Создание pdf-файла
|
||||
protected abstract void CreatePdf(PdfInfo info);
|
||||
protected abstract void CreatePdf(PdfInfoClient info);
|
||||
|
||||
/// Создание параграфа с текстом
|
||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||
@ -47,6 +78,6 @@ namespace BankYouBankruptBusinessLogic.OfficePackage
|
||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||
|
||||
/// Сохранение файла
|
||||
protected abstract void SavePdf(PdfInfo info);
|
||||
protected abstract void SavePdf(PdfInfoClient info);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
||||
namespace BankYouBankruptBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
//общая информация по pdf файлу
|
||||
public class PdfInfo
|
||||
public class PdfInfoClient
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
||||
@ -19,6 +19,9 @@ namespace BankYouBankruptBusinessLogic.OfficePackage.HelperModels
|
||||
public DateTime DateTo { get; set; }
|
||||
|
||||
//перечень заказов за указанный период для вывода/сохранения
|
||||
public List<ReportCashierViewModel> ReportAccounts { get; set; } = new();
|
||||
public List<ReportClientViewModel> ReportCrediting { get; set; } = new();
|
||||
|
||||
//перечень заказов за указанный период для вывода/сохранения
|
||||
public List<ReportClientViewModel> ReportDebiting { get; set; } = new();
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ using System.Threading.Tasks;
|
||||
namespace BankYouBankruptBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
//реализация астрактного класса создания pdf документа
|
||||
public class SaveToPdf : AbstractSaveToPdfCashier
|
||||
public class SaveToPdf : AbstractSaveToPdfClient
|
||||
{
|
||||
private Document? _document;
|
||||
|
||||
@ -44,7 +44,7 @@ namespace BankYouBankruptBusinessLogic.OfficePackage.Implements
|
||||
style.Font.Bold = true;
|
||||
}
|
||||
|
||||
protected override void CreatePdf(PdfInfo info)
|
||||
protected override void CreatePdf(PdfInfoClient info)
|
||||
{
|
||||
//создаём документ
|
||||
_document = new Document();
|
||||
@ -117,7 +117,7 @@ namespace BankYouBankruptBusinessLogic.OfficePackage.Implements
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SavePdf(PdfInfo info)
|
||||
protected override void SavePdf(PdfInfoClient info)
|
||||
{
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
|
@ -150,6 +150,11 @@ namespace BankYouBankruptCashierApp.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult CreateAccount()
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
//запрашиваем список в формате вспомогательной вьюшки из-за работы select в asp net
|
||||
ViewBag.Clients = APICashier.GetRequest<List<ClientViewModel>>($"/api/Client/GetAllClients").Select(x => new ClientSelectViewModel
|
||||
{
|
||||
@ -201,6 +206,11 @@ namespace BankYouBankruptCashierApp.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult CreateReport()
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Accountes = APICashier.GetRequest<List<AccountViewModel>>("api/main/getaccountlist");
|
||||
|
||||
return View();
|
||||
@ -258,6 +268,11 @@ namespace BankYouBankruptCashierApp.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult CloseCrediting()
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Creditings = APICashier.GetRequest<List<CreditingViewModel>>("/api/Account/FindOpenCrediting");
|
||||
|
||||
ViewBag.Accounts = APICashier.GetRequest<List<AccountViewModel>>("/api/Account/GetAllAccounts");
|
||||
@ -308,6 +323,11 @@ namespace BankYouBankruptCashierApp.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult CloseDebiting()
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Debitings = APICashier.GetRequest<List<DebitingViewModel>>("/api/Account/FindOpenDebiting");
|
||||
|
||||
ViewBag.Accounts = APICashier.GetRequest<List<AccountViewModel>>("/api/Account/GetAllAccounts");
|
||||
@ -357,6 +377,11 @@ namespace BankYouBankruptCashierApp.Controllers
|
||||
[HttpPost]
|
||||
public string GetAccountNumber(int id)
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Суда вход только авторизованным");
|
||||
}
|
||||
|
||||
APICashier.Debiting = APICashier.GetRequest<DebitingViewModel>($"/api/Account/FindDebiting?id={id}");
|
||||
|
||||
APICashier.Crediting = APICashier.GetRequest<CreditingViewModel>($"/api/Account/FindDebiting?id={id}");
|
||||
@ -384,6 +409,11 @@ namespace BankYouBankruptCashierApp.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult MoneyTransfers()
|
||||
{
|
||||
if (APICashier.Cashier == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Accounts = APICashier.GetRequest<List<AccountViewModel>>("/api/Account/GetAllAccounts");
|
||||
|
||||
return View();
|
||||
|
@ -239,5 +239,21 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Получение отчёта
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CreateReport()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateReport(DateTime DateFrom, DateTime DateTo)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
}
|
@ -34,8 +34,10 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="CreditingList">Пополнить средства</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="CreateReport">Отчёт по картам</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
@ -22,8 +22,8 @@ namespace BankYouBankruptContracts.BusinessLogicsContracts
|
||||
//Сохранение отчёта по картам в файл-Excel
|
||||
void SaveCreditingToExcelFile(ReportBindingModel model);
|
||||
void SaveDebitingToExcelFile(ReportBindingModel model);
|
||||
|
||||
//Сохранение отчёта по картам в файл-Pdf
|
||||
void SaveCreditingToPdfFile(ReportBindingModel model);
|
||||
void SaveDebitingToPdfFile(ReportBindingModel model);
|
||||
void SaveClientReportToPdfFile(ReportBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ namespace BankYouBankruptContracts.ViewModels
|
||||
{
|
||||
public class ReportClientViewModel
|
||||
{
|
||||
public int CardId { get; set; }
|
||||
public string CardNumber { get; set; }
|
||||
|
||||
public double SumOperation { get; set; }
|
||||
|
||||
|
@ -0,0 +1,49 @@
|
||||
using BankYouBankruptBusinessLogic.BusinessLogics;
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.BusinessLogicsContracts;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptRestApi.Controllers;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BankYouBankruptRestAPI.Controllers
|
||||
{
|
||||
//указание у контроллера, что Route будет строиться не только по наванию контроллера, но и по названию метода (так как у нас два Post-метода)
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ReportController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IReportCashierLogic _reportCashierLogic;
|
||||
|
||||
private readonly IReportClientLogic _reportClientLogic;
|
||||
|
||||
public ReportController(ILogger<AccountController> logger, IReportClientLogic reportClientLogic, IReportCashierLogic reportCashierLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_reportClientLogic = reportClientLogic;
|
||||
_reportCashierLogic = reportCashierLogic;
|
||||
}
|
||||
|
||||
//метод генерации отчёта за период по картам клиента
|
||||
[HttpGet]
|
||||
public void CreateClientReport(DateTime DateFrom, DateTime DateTo)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportClientLogic.SaveClientReportToPdfFile(new ReportBindingModel
|
||||
{
|
||||
FileName = "Отчёт по картам от " + DateTime.Now.ToShortDateString(),
|
||||
DateFrom = DateFrom,
|
||||
DateTo = DateTo
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка входа в систему");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
using BankYouBankruptBusinessLogic.BusinessLogics;
|
||||
using BankYouBankruptBusinessLogic.OfficePackage;
|
||||
using BankYouBankruptBusinessLogic.OfficePackage.Implements;
|
||||
using BankYouBankruptContracts.BusinessLogicsContracts;
|
||||
using BankYouBankruptContracts.StoragesContracts;
|
||||
using BankYouBankruptDatabaseImplement.Implements;
|
||||
@ -29,6 +31,9 @@ builder.Services.AddTransient<IMoneyTransferLogic, MoneyTransferLogic>();
|
||||
builder.Services.AddTransient<IDebitingLogic, DebitingLogic>();
|
||||
builder.Services.AddTransient<ICashWithdrawalLogic, CashWithdrawalLogic>();
|
||||
|
||||
builder.Services.AddTransient<AbstractSaveToPdfClient, SaveToPdf>();
|
||||
//builder.Services.AddTransient<AbstractSaveToPdfCashier, SaveToPdf>();
|
||||
|
||||
builder.Services.AddControllers();
|
||||
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
|
Loading…
Reference in New Issue
Block a user