diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/MessageInfoLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/MessageInfoLogic.cs new file mode 100644 index 0000000..b98f5f0 --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/MessageInfoLogic.cs @@ -0,0 +1,33 @@ +using BankYouBankruptContracts.BindingModels; +using BankYouBankruptContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankYouBankruptBusinessLogic.BusinessLogics +{ + public class MessageInfoLogic : IMessageInfoLogic + { + private readonly ILogger _logger; + + //private readonly IMessageInfoStorage _messageInfoStorage; + + public MessageInfoLogic(ILogger logger) + { + _logger = logger; + } + + public bool Create(MessageInfoBindingModel model) + { + throw new NotImplementedException(); + } + + public bool Update(MessageInfoBindingModel model) + { + throw new NotImplementedException(); + } + } +} diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs index 373ad7a..c083ea1 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs @@ -19,7 +19,7 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics private readonly ICashWithdrawalStorage _cashWithdrawalStorage; - private readonly IAccountStorage _accountStorage; + private readonly IClientStorage _clientStorage; private readonly AbstractSaveToExcelCashier _saveToExcel; @@ -29,22 +29,22 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics //инициализируем поля класса через контейнер public ReportCashierLogic(IMoneyTransferStorage moneyTransferStorage, ICashWithdrawalStorage cashWithdrawalStorage, - IAccountStorage accountStorage, AbstractSaveToExcelCashier saveToExcel, AbstractSaveToWordCashier saveToWord, - AbstractSaveToPdfClient saveToPdf) + IClientStorage clientStorage, AbstractSaveToExcelCashier saveToExcel, + AbstractSaveToWordCashier saveToWord, AbstractSaveToPdfClient saveToPdf) { _moneyTransferStorage = moneyTransferStorage; _cashWithdrawalStorage = cashWithdrawalStorage; - _accountStorage = accountStorage; _saveToExcel = saveToExcel; _saveToWord = saveToWord; _saveToPdf = saveToPdf; + _clientStorage = clientStorage; } //формирование списка переводов между счетами за период public List? GetMoneyTransfers(ReportBindingModel model) { - return _moneyTransferStorage.GetFilteredList(new MoneyTransferSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo}) + return _moneyTransferStorage.GetFilteredList(new MoneyTransferSearchModel { ClientId = model.ClientId, DateFrom = model.DateFrom, DateTo = model.DateTo}) .Select(x => new ReportCashierViewModel { OperationId = x.Id, @@ -59,7 +59,7 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics //формирование списка выдаци наличных со счёта за период public List? GetCashWithrawals(ReportBindingModel model) { - return _cashWithdrawalStorage.GetFilteredList(new CashWithdrawalSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo }) + return _cashWithdrawalStorage.GetFilteredList(new CashWithdrawalSearchModel { ClientId = model.ClientId, DateFrom = model.DateFrom, DateTo = model.DateTo }) .Select(x => new ReportCashierViewModel { OperationId = x.Id, @@ -71,6 +71,17 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics .ToList(); } + //формирование полного имени клиента для отчёта + public string GetFullName(ReportBindingModel model) + { + var client = _clientStorage.GetElement(new ClientSearchModel + { + Id = model.ClientId + }); + + return client.Surname + " " + client.Name + " " + client.Patronymic; + } + //Сохранение мороженных в файл-Word public void SaveAccountsToWordFile(ReportBindingModel model) { @@ -90,6 +101,7 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics { ForClient = false, FileName = model.FileName, + FullClientName = GetFullName(model), Title = "Отчёт по операциям начислений и переводов между счетами", DateFrom = model.DateFrom!.Value, DateTo = model.DateTo!.Value, diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/MailWorker/MailKitWorker.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/MailWorker/MailKitWorker.cs index b946d3e..4786eaa 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/MailWorker/MailKitWorker.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/MailWorker/MailKitWorker.cs @@ -1,11 +1,11 @@ using BankYouBankruptContracts.BusinessLogicsContracts; +using BankYouBankruptContracts.BindingModels; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Linq; using System.Net.Mail; using System.Net; -using System.Security.Authentication; using System.Text; using System.Threading.Tasks; using MailKit.Net.Pop3; diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfClient.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfClient.cs index 0a7c32d..602a30f 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfClient.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfClient.cs @@ -108,7 +108,7 @@ namespace BankYouBankruptBusinessLogic.OfficePackage CreateParagraph(new PdfParagraph { - Text = info.Title + $"\nот {DateTime.Now.ToShortDateString()}", + Text = info.Title + $"\nот {DateTime.Now.ToShortDateString()}\nФИО клиента: {info.FullClientName}", Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs index 38fb1cc..97e0e82 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs @@ -21,6 +21,9 @@ namespace BankYouBankruptBusinessLogic.OfficePackage.HelperModels //по умолчанию отчёт делается для клиента public bool ForClient { get; set; } = true; + //для передачи полного имени клиента в отчёт + public string FullClientName { get; set; } = string.Empty; + //перечень заказов за указанный период для вывода/сохранения public List ReportCrediting { get; set; } = new(); diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs b/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs index 9b62e5f..b216411 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Controllers/HomeController.cs @@ -433,11 +433,18 @@ namespace BankYouBankruptCashierApp.Controllers return Redirect("~/Home/Enter"); } + //запрашиваем список в формате вспомогательной вьюшки из-за работы select в asp net + ViewBag.Clients = APICashier.GetRequest>($"/api/Client/GetAllClients").Select(x => new ClientSelectViewModel + { + Id = x.Id, + FullName = x.Surname + " " + x.Name + " " + x.Patronymic + }).ToList(); + return View(); } [HttpPost] - public void CreateReport(DateTime dateFrom, DateTime dateTo) + public void CreateReport(int clientId, DateTime dateFrom, DateTime dateTo) { if (APICashier.Cashier == null) { @@ -446,6 +453,7 @@ namespace BankYouBankruptCashierApp.Controllers APICashier.PostRequest("api/Report/CreateCashierReport", new ReportSupportBindingModel() { + ClientId = clientId, DateFrom = dateFrom, DateTo = dateTo }); diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CreateReport.cshtml b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CreateReport.cshtml index 59638ae..e2c4290 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CreateReport.cshtml +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Home/CreateReport.cshtml @@ -6,6 +6,12 @@

Отчёт по счетам за выбранный период

+
+
Клиент:
+
+ +
+
Дата начала периода:
diff --git a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/MailSendInfoBindingModel.cs b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/MailSendInfoBindingModel.cs new file mode 100644 index 0000000..94139b5 --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/MailSendInfoBindingModel.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankYouBankruptContracts.BindingModels +{ + //один из двух классов для обмена информацией по почте + public class MailSendInfoBindingModel + { + public string MailAddress { get; set; } = string.Empty; + + public string Subject { get; set; } = string.Empty; + + public string Text { get; set; } = string.Empty; + } +} diff --git a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/MessageInfoBindingModel.cs b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/MessageInfoBindingModel.cs new file mode 100644 index 0000000..2109885 --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/MessageInfoBindingModel.cs @@ -0,0 +1,30 @@ +using BankYouBankruptDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankYouBankruptContracts.BindingModels +{ + public class MessageInfoBindingModel : IMessageInfoModel + { + public int Id { get; set; } + + public string MessageId { get; set; } = string.Empty; + + public int? ClientId { get; set; } + + public string SenderName { get; set; } = string.Empty; + + public DateTime DateDelivery { get; set; } = DateTime.Now; + + public string Subject { get; set; } = string.Empty; + + public string Body { get; set; } = string.Empty; + + public bool IsRead { get; set; } = false; + + public string? Answer { get; set; } = string.Empty; + } +} diff --git a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/ReportBindingModel.cs b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/ReportBindingModel.cs index 8dbfd4b..3ec609b 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/ReportBindingModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/ReportBindingModel.cs @@ -10,6 +10,10 @@ namespace BankYouBankruptContracts.BindingModels { public string FileName { get; set; } = string.Empty; + public int? ClientId { get; set; } + + public string? ClientFullName { get; set; } = string.Empty; + public DateTime? DateFrom { get; set; } public DateTime? DateTo { get; set; } diff --git a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/ReportSupportBindingModel.cs b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/ReportSupportBindingModel.cs index e013c81..ffc875c 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/ReportSupportBindingModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/ReportSupportBindingModel.cs @@ -9,6 +9,8 @@ namespace BankYouBankruptContracts.BindingModels //вспомогательная модель для передачи DateTime при формировании отчёта public class ReportSupportBindingModel { + public int ClientId { get; set; } + public DateTime DateFrom { get; set; } public DateTime DateTo { get; set; } diff --git a/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IMessageInfoLogic.cs b/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IMessageInfoLogic.cs new file mode 100644 index 0000000..8d26b7d --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IMessageInfoLogic.cs @@ -0,0 +1,20 @@ +using BankYouBankruptContracts.BindingModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankYouBankruptContracts.BusinessLogicsContracts +{ + public interface IMessageInfoLogic + { + //List? ReadList(MessageInfoSearchModel? model); + + //MessageInfoViewModel? ReadElement(MessageInfoSearchModel model); + + bool Create(MessageInfoBindingModel model); + + bool Update(MessageInfoBindingModel model); + } +} diff --git a/BankYouBankrupt/BankYouBankruptContracts/SearchModels/CashWithdrawalSearchModel.cs b/BankYouBankrupt/BankYouBankruptContracts/SearchModels/CashWithdrawalSearchModel.cs index 5c5aeec..555084c 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/SearchModels/CashWithdrawalSearchModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/SearchModels/CashWithdrawalSearchModel.cs @@ -16,6 +16,8 @@ namespace BankYouBankruptContracts.SearchModels public int? CashierId { get; set; } + public int? ClientId { get; set; } + public int? Sum { get; set; } public DateTime? DateFrom { get; set; } diff --git a/BankYouBankrupt/BankYouBankruptContracts/SearchModels/MoneyTransferSearchModel.cs b/BankYouBankrupt/BankYouBankruptContracts/SearchModels/MoneyTransferSearchModel.cs index 84a1109..c51e1c3 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/SearchModels/MoneyTransferSearchModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/SearchModels/MoneyTransferSearchModel.cs @@ -12,6 +12,8 @@ namespace BankYouBankruptContracts.SearchModels public int? Sum { get; set; } + public int? ClientId { get; set; } + public int? AccountSenderId { get; set; } public int? AccountPayeeId { get; set; } diff --git a/BankYouBankrupt/BankYouBankruptDataModels/Models/IMessageInfoModel.cs b/BankYouBankrupt/BankYouBankruptDataModels/Models/IMessageInfoModel.cs new file mode 100644 index 0000000..fe8b081 --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptDataModels/Models/IMessageInfoModel.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankYouBankruptDataModels.Models +{ + public interface IMessageInfoModel : IId + { + string MessageId { get; } + + int? ClientId { get; } + + string SenderName { get; } + + DateTime DateDelivery { get; } + + string Subject { get; } + + string Body { get; } + + public bool IsRead { get; } + + public string Answer { get; } + } +} diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/CashWithdrawalStorage.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/CashWithdrawalStorage.cs index 99f0e9c..f8553d4 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/CashWithdrawalStorage.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/CashWithdrawalStorage.cs @@ -46,13 +46,14 @@ namespace BankYouBankruptDatabaseImplement.Implements .ToList(); } + //выборка для заполнения отчёта if(model.DateFrom.HasValue && model.DateTo.HasValue) { return context.CashWithdrawals .Include(x => x.Cashier) .Include(x => x.Debiting) .Include(x => x.Account) - .Where(x => x.DateOperation >= model.DateFrom && x.DateOperation <= model.DateTo) + .Where(x => x.DateOperation >= model.DateFrom && x.DateOperation <= model.DateTo && x.Account.ClientId == model.ClientId) .Select(x => x.GetViewModel) .ToList(); } diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/MoneyTransferStorage.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/MoneyTransferStorage.cs index e9940ce..9bc49fe 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/MoneyTransferStorage.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/MoneyTransferStorage.cs @@ -41,7 +41,8 @@ namespace BankYouBankruptDatabaseImplement.Implements .Include(x => x.AccountPayeer) .Include(x => x.AccountSender) .Include(x => x.Cashier) - .Where(x => x.DateOperation >= model.DateFrom && x.DateOperation <= model.DateTo && x.AccountSenderId != null) + .Where(x => x.DateOperation >= model.DateFrom && x.DateOperation <= model.DateTo && x.AccountSenderId != null + && (x.AccountPayeer.ClientId == model.ClientId || x.AccountSender.Id == model.ClientId)) .Select(x => x.GetViewModel) .ToList(); } diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs index 0c80b16..bc04c92 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs @@ -21,6 +21,7 @@ namespace BankYouBankruptRestAPI.Controllers private readonly IReportCashierLogic _reportCashierLogic; + public ReportController(ILogger logger, IReportClientLogic reportClientLogic, IReportCashierLogic reportCashierLogic) { _logger = logger; @@ -57,6 +58,7 @@ namespace BankYouBankruptRestAPI.Controllers _reportCashierLogic.SaveAccountsToPdfFile(new ReportBindingModel { FileName = "Отчёт по счетам за " + DateTime.Now.ToShortDateString() + ".pdf", + ClientId = model.ClientId, DateFrom = model.DateFrom, DateTo = model.DateTo }); diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs index 1582a28..415ce0f 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs @@ -35,6 +35,9 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); + +builder.Services.AddSingleton(); //теперь общий builder.Services.AddTransient();