diff --git a/Bank/BankBusinessLogic/BankBusinessLogic.csproj b/Bank/BankBusinessLogic/BankBusinessLogic.csproj index a2ddd73..ec37ad9 100644 --- a/Bank/BankBusinessLogic/BankBusinessLogic.csproj +++ b/Bank/BankBusinessLogic/BankBusinessLogic.csproj @@ -7,8 +7,13 @@ - - + + + + + + + diff --git a/Bank/BankBusinessLogic/BusinessLogic/CashierLogic.cs b/Bank/BankBusinessLogic/BusinessLogic/CashierLogic.cs new file mode 100644 index 0000000..81c2e13 --- /dev/null +++ b/Bank/BankBusinessLogic/BusinessLogic/CashierLogic.cs @@ -0,0 +1,185 @@ +using BankContracts.BindingModels.Cashier; +using BankContracts.BindingModels.Client; +using BankContracts.BusinessLogicsContracts.Cashier; +using BankContracts.SearchModels.Cashier; +using BankContracts.StoragesModels.Cashier; +using BankContracts.ViewModels.Cashier.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.BusinessLogic +{ + // Класс, реализующий бизнес-логику для кассиров + public class CashierLogic : ICashierLogic + { + private readonly ILogger _logger; + + private readonly ICashierStorage _cashierStorage; + + // Конструктор + public CashierLogic(ILogger logger, ICashierStorage cashierStorage) + { + _logger = logger; + _cashierStorage = cashierStorage; + } + + // Вывод конкретного клиента + public CashierViewModel? ReadElement(CashierSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("ReadElement. CashierName:{Name}. CashierSurname:{Surname}. CashierPatronymic:{Patronymic}. Id:{Id}", + model.Name, model.Surname, model.Patronymic, model?.Id); + + var element = _cashierStorage.GetElement(model); + + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + + // Вывод отфильтрованного списка + public List? ReadList(CashierSearchModel? model) + { + _logger.LogInformation("ReadList. CashierName:{Name}. CashierSurname:{Surname}. CashierPatronymic:{Patronymic}. Id:{Id}", + model.Name, model.Surname, model.Patronymic, model?.Id); + + // list хранит весь список в случае, если model пришло со значением null на вход метода + var list = model == null ? _cashierStorage.GetFullList() : _cashierStorage.GetFilteredList(model); + + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + + return list; + } + + // Создание кассира + public bool Create(CashierBindingModel model) + { + CheckModel(model); + + if (_cashierStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + + return true; + } + + // Обновление кассира + public bool Update(CashierBindingModel model) + { + CheckModel(model); + + if (_cashierStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + + return true; + } + + // Удаление кассира + public bool Delete(CashierBindingModel model) + { + CheckModel(model, false); + + _logger.LogInformation("Delete. Id:{Id}", model.Id); + + if (_cashierStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + + return false; + } + + return true; + } + + // Проверка входного аргумента для методов Insert, Update и Delete + private void CheckModel(CashierBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + // Так как при удалении передаём как параметр false + if (!withParams) + { + return; + } + + // Проверка на наличие имени + if (string.IsNullOrEmpty(model.Name)) + { + throw new ArgumentNullException("Отсутствие имени в учётной записи", nameof(model.Name)); + } + + // Проверка на наличие фамилия + if (string.IsNullOrEmpty(model.Surname)) + { + throw new ArgumentNullException("Отсутствие фамилии в учётной записи", nameof(model.Surname)); + } + + // Проверка на наличие отчество + if (string.IsNullOrEmpty(model.Patronymic)) + { + throw new ArgumentNullException("Отсутствие отчества в учётной записи", nameof(model.Patronymic)); + } + + // Проверка на наличие почты + if (string.IsNullOrEmpty(model.Email)) + { + throw new ArgumentNullException("Отсутствие почты в учётной записи (логина)", nameof(model.Email)); + } + + // Проверка на наличие пароля + if (string.IsNullOrEmpty(model.Password)) + { + throw new ArgumentNullException("Отсутствие пароля в учётной записи", nameof(model.Password)); + } + + // Проверка на мобильный телефон + if (string.IsNullOrEmpty(model.MobilePhone)) + { + throw new ArgumentNullException("Отсутствие почты в учётной записи (логина)", nameof(model.MobilePhone)); + } + + _logger.LogInformation("Cashier. CashierName:{Name}. CashierSurname:{Surname}. CashierPatronymic:{Patronymic}. " + + "Email:{Email}. Password:{Password}. MobilePhone:{MobilePhone} Id:{Id}", + model.Name, model.Surname, model.Patronymic, model.Email, model.Password, model.MobilePhone, model.Id); + + // Для проверка на наличие такого же аккаунта + var element = _cashierStorage.GetElement(new CashierSearchModel + { + Email = model.Email, + }); + + //если элемент найден и его Id не совпадает с Id переданного объекта + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Аккаунт с таким логином уже есть"); + } + } + } +} diff --git a/Bank/BankBusinessLogic/BusinessLogic/ClientLogic.cs b/Bank/BankBusinessLogic/BusinessLogic/ClientLogic.cs new file mode 100644 index 0000000..294b91f --- /dev/null +++ b/Bank/BankBusinessLogic/BusinessLogic/ClientLogic.cs @@ -0,0 +1,173 @@ +using BankContracts.BindingModels.Client; +using BankContracts.BusinessLogicsContracts.Client; +using BankContracts.SearchModels.Client; +using BankContracts.StoragesModels.Client; +using BankContracts.ViewModels.Client.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.BusinessLogic +{ + // Класс, реализующий бизнес-логику для клиентов + public class ClientLogic : IClientLogic + { + private readonly ILogger _logger; + + private readonly IClientStorage _clientStorage; + + // Конструктор + public ClientLogic(ILogger logger, IClientStorage clientStorage) + { + _logger = logger; + _clientStorage = clientStorage; + } + + // Вывод конкретного клиента + public ClientViewModel? ReadElement(ClientSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("ReadElement. Name:{Name}.Surname:{Surname}.Patronymic:{Patronymic}.Id:{Id}", model.Name, model.Surname, model.Patronymic, model.Id); + var element = _clientStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("Read element not found"); + return null; + } + + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + + // Вывод отфильтрованного списка + public List? ReadList(ClientSearchModel model) + { + _logger.LogInformation("ReadList. ClientId:{Id}", model?.Id); + + // list хранит весь список в случае, если model пришло со значением null на вход метода + var list = model == null ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model); + + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + + // Создание клиента + public bool Create(ClientBindingModel model) + { + CheckModel(model); + if (_clientStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + + return true; + } + + // Обновление клиента + public bool Update(ClientBindingModel model) + { + CheckModel(model); + if (_clientStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + + return true; + } + + // Удаление клиента + public bool Delete(ClientBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_clientStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + + return true; + } + + // Проверка входного аргумента для методов Insert, Update и Delete + public void CheckModel(ClientBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + // При удалении параметру withParams передаём false + if (!withParams) + { + return; + } + + // Проверка на наличие имени клиента + if (string.IsNullOrEmpty(model.Name)) + { + throw new ArgumentNullException("Нет имени пользователя", nameof(model.Name)); + } + + // Проверка на наличие фамилии клиента + if (string.IsNullOrEmpty(model.Surname)) + { + throw new ArgumentNullException("Нет фамилии пользователя", nameof(model.Surname)); + } + + // Проверка на наличие отчества клиента + if (string.IsNullOrEmpty(model.Patronymic)) + { + throw new ArgumentNullException("Нет отчества пользователя", nameof(model.Patronymic)); + } + + // Проверка на наличие эл. почты + if (string.IsNullOrEmpty(model.Email)) + { + throw new ArgumentNullException("Нет почты пользователя", nameof(model.Email)); + } + + // Проверка на наличие пароля + if (string.IsNullOrEmpty(model.Password)) + { + throw new ArgumentNullException("Нет пароля пользователя", nameof(model.Password)); + } + + // Проверка на наличие мобильного телефона + if (string.IsNullOrEmpty(model.MobilePhone)) + { + throw new ArgumentNullException("Нет моб.телефона пользователя", nameof(model.MobilePhone)); + } + + _logger.LogInformation("Client. Name:{Name}.Surname:{Surname}.Patronymic:{Patronymic}.Email:{Email}.Password:{Password}.Mobeliphone:{MobilePhone}.Id:{Id}", + model.Name, model.Surname, model.Patronymic, model.Email, model.Password, model.MobilePhone, model.Id); + + // Для проверка на наличие такого же аккаунта + var element = _clientStorage.GetElement(new ClientSearchModel + { + Email = model.Email, + }); + + // Если элемент найден и его Id не совпадает с Id переданного объекта + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Клиент с такой почтой уже есть"); + } + } + } +} diff --git a/Bank/BankBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs b/Bank/BankBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs new file mode 100644 index 0000000..fbdadf4 --- /dev/null +++ b/Bank/BankBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage.HelperEnums +{ + // Вспомогательное перечисление для оформления Excel + public enum ExcelStyleInfoType + { + // Заголовок + Title, + + // Просто текст + Text, + + // Текст в рамке + TextWithBorder + } +} diff --git a/Bank/BankBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs b/Bank/BankBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs new file mode 100644 index 0000000..a52a139 --- /dev/null +++ b/Bank/BankBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage.HelperEnums +{ + // Вспомогательное перечисление для оформления pdf документа + public enum PdfParagraphAlignmentType + { + // Либо по центру + Center, + + // Либо с левого края + Left, + + // Либо с правого края + Right + } +} diff --git a/Bank/BankBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs b/Bank/BankBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs new file mode 100644 index 0000000..f9f60a4 --- /dev/null +++ b/Bank/BankBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage.HelperEnums +{ + // Вспомогательное перечисление для настройки формата word документа + public enum WordJustificationType + { + // Выравниваем либо по центру + Center, + + // Либо на всю ширину + Both + } +} diff --git a/Bank/BankBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs b/Bank/BankBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs new file mode 100644 index 0000000..97d80c5 --- /dev/null +++ b/Bank/BankBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs @@ -0,0 +1,28 @@ +using BankBusinessLogic.OfficePackage.HelperEnums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + // Информация по ячейке в таблице Excel + public class ExcelCellParameters + { + // Название колонки + public string ColumnName { get; set; } = string.Empty; + + // Строка + public uint RowIndex { get; set; } + + // текст в ячейке + public string Text { get; set; } = string.Empty; + + // Геттер для того, чтобы не искать каждый раз + public string CellReference => $"{ColumnName}{RowIndex}"; + + // В каком стиле выводить информацию + public ExcelStyleInfoType StyleInfo { get; set; } + } +} diff --git a/Bank/BankBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/Bank/BankBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs new file mode 100644 index 0000000..deca5bb --- /dev/null +++ b/Bank/BankBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs @@ -0,0 +1,29 @@ +using BankContracts.ViewModels.Cashier.ViewModels; +using BankContracts.ViewModels.Client.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + // Информация по excel файлу, который хотим создать + public class ExcelInfo + { + // Название файла + public string FileName { get; set; } = string.Empty; + + // Заголовок + public string Title { get; set; } = string.Empty; + + // Списки для отчёта клиента + public List MoneyTransfer { get; set; } = new(); + + public List Crediting { get; set; } = new(); + + // Список для отчёта кассира и клиента + public List Debiting { get; set; } = new(); + } +} +} diff --git a/Bank/BankBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs b/Bank/BankBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs new file mode 100644 index 0000000..b70c3cd --- /dev/null +++ b/Bank/BankBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + // Информация для объединения ячеек + public class ExcelMergeParameters + { + public string CellFromName { get; set; } = string.Empty; + + public string CellToName { get; set; } = string.Empty; + + // Геттер для указания диапазона для объединения, чтобы каждый раз его не вычислять + public string Merge => $"{CellFromName}:{CellToName}"; + } +} diff --git a/Bank/BankBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/Bank/BankBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs new file mode 100644 index 0000000..12bff67 --- /dev/null +++ b/Bank/BankBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + // Общая информация по pdf файлу + public class PdfInfo + { + public string FileName { get; set; } = string.Empty; + + public string Title { get; set; } = string.Empty; + + public DateTime DateFrom { get; set; } + + public DateTime DateTo { get; set; } + + // По умолчанию отчёт делается для клиента + public bool ForClient { get; set; } = true; + + // Для передачи полного имени клиента в отчёт + public string FullClientName { get; set; } = string.Empty; + + // Перечень заказов за указанный период для вывода/сохранения + public List ReportCrediting { get; set; } = new(); + + // Перечень заказов за указанный период для вывода/сохранения + public List ReportDebiting { get; set; } = new(); + + // Перечень переводов со счёта на счёт + public List ReportMoneyTransfer { get; set; } = new(); + + // Перечень зачислений денежных средств на карту (т. е. на её счёт) + public List ReportCashWithdrawal { get; set; } = new(); + } +} diff --git a/Bank/BankBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs b/Bank/BankBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs new file mode 100644 index 0000000..b74fbf7 --- /dev/null +++ b/Bank/BankBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs @@ -0,0 +1,20 @@ +using BankBusinessLogic.OfficePackage.HelperEnums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + // Информация по параграфу в pdf документе + public class PdfParagraph + { + public string Text { get; set; } = string.Empty; + + public string Style { get; set; } = string.Empty; + + // Информация по выравниванию текста в параграфе + public PdfParagraphAlignmentType ParagraphAlignment { get; set; } + } +} diff --git a/Bank/BankBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs b/Bank/BankBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs new file mode 100644 index 0000000..d386b15 --- /dev/null +++ b/Bank/BankBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs @@ -0,0 +1,22 @@ +using BankBusinessLogic.OfficePackage.HelperEnums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + // Информация по параметрам строк таблицы + public class PdfRowParameters + { + // Набор текстов + public List Texts { get; set; } = new(); + + // Стиль к текстам + public string Style { get; set; } = string.Empty; + + // Как выравниваем + public PdfParagraphAlignmentType ParagraphAlignment { get; set; } + } +} diff --git a/Bank/BankBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/Bank/BankBusinessLogic/OfficePackage/HelperModels/WordInfo.cs new file mode 100644 index 0000000..ca267da --- /dev/null +++ b/Bank/BankBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -0,0 +1,26 @@ +using BankContracts.ViewModels.Cashier.ViewModels; +using BankContracts.ViewModels.Client.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + // Общая информация по документу + internal class WordInfo + { + public string FileName { get; set; } = string.Empty; + + public string Title { get; set; } = string.Empty; + + // Списки для отчёта клиента + public List MoneyTransfer { get; set; } = new(); + + public List Crediting { get; set; } = new(); + + // Список для отчёта кассира и клиента + public List Debiting { get; set; } = new(); + } +} diff --git a/Bank/BankBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs b/Bank/BankBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs new file mode 100644 index 0000000..3352a75 --- /dev/null +++ b/Bank/BankBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + // Модель параграфов, которые есть в тексте + public class WordParagraph + { + // Набор текстов в абзаце (для случая, если в абзаце текст разных стилей) + public List<(string, WordTextProperties)> Texts { get; set; } = new(); + + // Свойства параграфа, если они есть + public WordTextProperties? TextProperties { get; set; } + + public List> RowTexts { get; set; } = new(); + } +} diff --git a/Bank/BankBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs b/Bank/BankBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs new file mode 100644 index 0000000..8fb655a --- /dev/null +++ b/Bank/BankBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs @@ -0,0 +1,22 @@ +using BankBusinessLogic.OfficePackage.HelperEnums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankBusinessLogic.OfficePackage.HelperModels +{ + // Модель свойств текста, которые нам нужны в word документе + public class WordTextProperties + { + // Размере текста + public string Size { get; set; } = string.Empty; + + // Надо ли делать его жирным + public bool Bold { get; set; } + + // Выравнивание + public WordJustificationType JustificationType { get; set; } + } +} diff --git a/Bank/BankContracts/BankContracts.csproj b/Bank/BankContracts/BankContracts.csproj index e6bb86f..3454933 100644 --- a/Bank/BankContracts/BankContracts.csproj +++ b/Bank/BankContracts/BankContracts.csproj @@ -15,6 +15,7 @@ + diff --git a/Bank/BankContracts/BindingModels/Cashier/MoneyTransferBindingModel.cs b/Bank/BankContracts/BindingModels/Cashier/MoneyTransferBindingModel.cs index 743bf60..d0d253e 100644 --- a/Bank/BankContracts/BindingModels/Cashier/MoneyTransferBindingModel.cs +++ b/Bank/BankContracts/BindingModels/Cashier/MoneyTransferBindingModel.cs @@ -10,7 +10,7 @@ namespace BankContracts.BindingModels.Cashier public class MoneyTransferBindingModel : IMoneyTransferModel { public int Id { get; set; } - //сменили int на double + public double Sum { get; set; } public int CashierId { get; set; } @@ -19,8 +19,8 @@ namespace BankContracts.BindingModels.Cashier public int? CreditingId { get; set; } - // для реализации между двумя клиента, аккаунтами - public int? AccountSenderId { get; set; } + // Для реализации между двумя аккаунтами, (клиента?) + public int? AccountSenderId { get; set; } public int AccountPayeeId { get; set; } diff --git a/Bank/BankContracts/BindingModels/Client/CreditingBindingModel.cs b/Bank/BankContracts/BindingModels/Client/CreditingBindingModel.cs index aab1694..cf8120c 100644 --- a/Bank/BankContracts/BindingModels/Client/CreditingBindingModel.cs +++ b/Bank/BankContracts/BindingModels/Client/CreditingBindingModel.cs @@ -7,14 +7,17 @@ using System.Threading.Tasks; namespace BankContracts.BindingModels.Client { - public class CreditingBindingModel : ICreditingModel + // Реализация сущности "Пополнение карты" + public class CreditingBindingModel : ICreditingModel { public int Id { get; set; } - public double Sum { get; set; } + public int ClientId { get; set; } + + public int CardId { get; set; } + + public double Sum { get; set; } public DateTime DateCredit { get; set; } - - public int ClientId { get; set; } } } diff --git a/Bank/BankContracts/BindingModels/Client/DebitingBindingModel.cs b/Bank/BankContracts/BindingModels/Client/DebitingBindingModel.cs index dc7fcb8..cfac8dd 100644 --- a/Bank/BankContracts/BindingModels/Client/DebitingBindingModel.cs +++ b/Bank/BankContracts/BindingModels/Client/DebitingBindingModel.cs @@ -7,12 +7,14 @@ using System.Threading.Tasks; namespace BankContracts.BindingModels.Client { - public class DebitingBindingModel : IDebitingModel + // Реализация сущности "Клиент" + public class DebitingBindingModel : IDebitingModel { public int Id { get; set; } public int CardId { get; set; } - // и тут я понял почему ты задавался вопросом про id, надо подумать + + // И тут я понял почему ты задавался вопросом про id, надо подумать public int ClientId { get; set; } public double Sum { get; set; } diff --git a/Bank/BankContracts/BindingModels/Reports/ReportBindingModel.cs b/Bank/BankContracts/BindingModels/Reports/ReportBindingModel.cs new file mode 100644 index 0000000..cc091d9 --- /dev/null +++ b/Bank/BankContracts/BindingModels/Reports/ReportBindingModel.cs @@ -0,0 +1,30 @@ +using BankDataModels.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankContracts.BindingModels.Reports +{ + public class ReportBindingModel + { + public string FileName { get; set; } = string.Empty; + + public int? ClientId { get; set; } + + public int? AccountId { get; set; } + + public List? CardList { get; set; } + + public string? ClientFullName { get; set; } = string.Empty; + + public DateTime? DateFrom { get; set; } + + public DateTime? DateTo { get; set; } + + public MailsEnum Role { get; set; } + + public string? Email { get; set; } + } +} diff --git a/Bank/BankContracts/BindingModels/Reports/ReportSupportBindingModel.cs b/Bank/BankContracts/BindingModels/Reports/ReportSupportBindingModel.cs new file mode 100644 index 0000000..3196d82 --- /dev/null +++ b/Bank/BankContracts/BindingModels/Reports/ReportSupportBindingModel.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankContracts.BindingModels.Reports +{ + // Вспомогательная модель для передачи DateTime при формировании отчёта + public class ReportSupportBindingModel + { + public int? ClientId { get; set; } + + public int? AccountId { get; set; } + + public DateTime? DateFrom { get; set; } + + public DateTime? DateTo { get; set; } + + // Для Excel отчёта клиента + public List? CardList { get; set; } + + public string? Email { get; set; } + } +} diff --git a/Bank/BankContracts/BusinessLogicsContracts/Cashier/IAccountLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/Cashier/IAccountLogic.cs index d465b2a..e6983b9 100644 --- a/Bank/BankContracts/BusinessLogicsContracts/Cashier/IAccountLogic.cs +++ b/Bank/BankContracts/BusinessLogicsContracts/Cashier/IAccountLogic.cs @@ -9,7 +9,8 @@ using System.Threading.Tasks; namespace BankContracts.BusinessLogicsContracts.Cashier { - public interface IAccountLogic + // Интерфейс бизнес-логики для счёта + public interface IAccountLogic { List? ReadList(AccountSearchModel? model); diff --git a/Bank/BankContracts/BusinessLogicsContracts/Cashier/ICashWithdrawalLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/Cashier/ICashWithdrawalLogic.cs index d1c0d80..8fe80bd 100644 --- a/Bank/BankContracts/BusinessLogicsContracts/Cashier/ICashWithdrawalLogic.cs +++ b/Bank/BankContracts/BusinessLogicsContracts/Cashier/ICashWithdrawalLogic.cs @@ -9,7 +9,8 @@ using System.Threading.Tasks; namespace BankContracts.BusinessLogicsContracts.Cashier { - public interface ICashWithdrawalLogic + // Интерфейс бизнес-логики для выдачи наличных + public interface ICashWithdrawalLogic { List? ReadList(CashWithdrawalSearchModel? model); diff --git a/Bank/BankContracts/BusinessLogicsContracts/Cashier/ICashierLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/Cashier/ICashierLogic.cs index db442ca..eb6cc17 100644 --- a/Bank/BankContracts/BusinessLogicsContracts/Cashier/ICashierLogic.cs +++ b/Bank/BankContracts/BusinessLogicsContracts/Cashier/ICashierLogic.cs @@ -9,7 +9,8 @@ using System.Threading.Tasks; namespace BankContracts.BusinessLogicsContracts.Cashier { - public interface ICashierLogic + // Интерфейс бизнес-логики для кассира + public interface ICashierLogic { List? ReadList(CashierSearchModel? model); diff --git a/Bank/BankContracts/BusinessLogicsContracts/Cashier/IMoneyTransferLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/Cashier/IMoneyTransferLogic.cs index be098a6..e83e43b 100644 --- a/Bank/BankContracts/BusinessLogicsContracts/Cashier/IMoneyTransferLogic.cs +++ b/Bank/BankContracts/BusinessLogicsContracts/Cashier/IMoneyTransferLogic.cs @@ -9,7 +9,8 @@ using System.Threading.Tasks; namespace BankContracts.BusinessLogicsContracts.Cashier { - public interface IMoneyTransferLogic + // Интерфейс бизнес-логики для перевода денег + public interface IMoneyTransferLogic { List? ReadList(MoneyTransferSearchModel? model); diff --git a/Bank/BankContracts/BusinessLogicsContracts/Client/ICardLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/Client/ICardLogic.cs index 07dc9a2..674083e 100644 --- a/Bank/BankContracts/BusinessLogicsContracts/Client/ICardLogic.cs +++ b/Bank/BankContracts/BusinessLogicsContracts/Client/ICardLogic.cs @@ -9,7 +9,8 @@ using System.Threading.Tasks; namespace BankContracts.BusinessLogicsContracts.Client { - public interface ICardLogic + // Интерфейс бизнес-логики для банковской карты + public interface ICardLogic { List? ReadList(CardSearchModel? model); diff --git a/Bank/BankContracts/BusinessLogicsContracts/Client/IClientLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/Client/IClientLogic.cs index 60c7def..5750a40 100644 --- a/Bank/BankContracts/BusinessLogicsContracts/Client/IClientLogic.cs +++ b/Bank/BankContracts/BusinessLogicsContracts/Client/IClientLogic.cs @@ -9,7 +9,8 @@ using System.Threading.Tasks; namespace BankContracts.BusinessLogicsContracts.Client { - public interface IClientLogic + // Интерфейс бизнес-логики для клиента + public interface IClientLogic { List? ReadList(ClientSearchModel? model); diff --git a/Bank/BankContracts/BusinessLogicsContracts/Client/ICreditingLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/Client/ICreditingLogic.cs index 7653ca9..b7cf676 100644 --- a/Bank/BankContracts/BusinessLogicsContracts/Client/ICreditingLogic.cs +++ b/Bank/BankContracts/BusinessLogicsContracts/Client/ICreditingLogic.cs @@ -9,7 +9,8 @@ using System.Threading.Tasks; namespace BankContracts.BusinessLogicsContracts.Client { - public interface ICreditingLogic + // Интерфейс бизнес-логики для пополнения карты + public interface ICreditingLogic { List? ReadList(CreditingSearchModel? model); diff --git a/Bank/BankContracts/BusinessLogicsContracts/Client/IDebitingLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/Client/IDebitingLogic.cs index 3c4d18f..1bc63be 100644 --- a/Bank/BankContracts/BusinessLogicsContracts/Client/IDebitingLogic.cs +++ b/Bank/BankContracts/BusinessLogicsContracts/Client/IDebitingLogic.cs @@ -9,7 +9,8 @@ using System.Threading.Tasks; namespace BankContracts.BusinessLogicsContracts.Client { - public interface IDebitingLogic + // Интерфейс бизнес-логики для получение наличных по карте + public interface IDebitingLogic { List? ReadList(DebitingSearchModel? model); diff --git a/Bank/BankContracts/BusinessLogicsContracts/Reports/IReportCashierLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/Reports/IReportCashierLogic.cs new file mode 100644 index 0000000..7787750 --- /dev/null +++ b/Bank/BankContracts/BusinessLogicsContracts/Reports/IReportCashierLogic.cs @@ -0,0 +1,26 @@ +using BankContracts.BindingModels.Reports; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankContracts.BusinessLogicsContracts.Reports +{ + // Интерфейс бизнес-логики для отчёта (Кассир) + public interface IReportCashierLogic + { + List? GetMoneyTransfers(ReportBindingModel model); + + List? GetCashWithrawals(ReportBindingModel model); + + // Сохранение отчёта по счетам в файл-Word + void SaveAccountsToWordFile(ReportBindingModel model); + + // Сохранение отчёта по счетам в файл-Excel + void SaveAccountsToExcelFile(ReportBindingModel model); + + // Сохранение отчёта по счетам в файл-Pdf + ReportCashierViewModelForHTML SaveAccountsToPdfFile(ReportBindingModel model); + } +} diff --git a/Bank/BankContracts/BusinessLogicsContracts/Reports/IReportClientLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/Reports/IReportClientLogic.cs new file mode 100644 index 0000000..4ccf768 --- /dev/null +++ b/Bank/BankContracts/BusinessLogicsContracts/Reports/IReportClientLogic.cs @@ -0,0 +1,27 @@ +using BankContracts.BindingModels.Reports; +using BankDataModels.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankContracts.BusinessLogicsContracts.Reports +{ + // Интерфейс бизнес-логики для отчёта (Клиент) + public interface IReportClientLogic + { + List? GetCrediting(ReportBindingModel model); + + List? GetDebiting(ReportBindingModel model); + + //Сохранение отчёта по картам в файл-Word + void SaveToWordFile(ReportBindingModel model, OfficeOperationEnum operationEnum); + + //Сохранение отчёта по картам в файл-Excel + void SaveToExcelFile(ReportBindingModel model, OfficeOperationEnum operationEnum); + + //Сохранение отчёта по картам в файл-Pdf + ReportClientViewModelForHTML SaveClientReportToPdfFile(ReportBindingModel model); + } +} diff --git a/Bank/BankContracts/SearchModels/Client/CreditingSearchModel.cs b/Bank/BankContracts/SearchModels/Client/CreditingSearchModel.cs index 338d584..8fc12c5 100644 --- a/Bank/BankContracts/SearchModels/Client/CreditingSearchModel.cs +++ b/Bank/BankContracts/SearchModels/Client/CreditingSearchModel.cs @@ -17,6 +17,6 @@ namespace BankContracts.SearchModels.Client public DateTime? DateCrediting { get; set; } - public int? UserId { get; set; } // ИЛИ лучше CLientId, правильнее будет юзер + public int? ClientId { get; set; } // ИЛИ лучше CLientId, ClientId будет лучше :) } } diff --git a/Bank/BankContracts/SearchModels/Client/DebitingSearchModel.cs b/Bank/BankContracts/SearchModels/Client/DebitingSearchModel.cs index 9229551..51359fc 100644 --- a/Bank/BankContracts/SearchModels/Client/DebitingSearchModel.cs +++ b/Bank/BankContracts/SearchModels/Client/DebitingSearchModel.cs @@ -13,7 +13,7 @@ namespace BankContracts.SearchModels.Client public int? CardId { get; set; } - public int? UserId { get; set; } // Возможно лишнюю фигню делаю и лучше ClientId , по нашей бд именно к пользователю относятся операции по пополнению + public int? ClientId { get; set; } // ClientId будет лучше :) Возможно лишнюю фигню делаю и лучше ClientId public int? Sum { get; set; } diff --git a/Bank/BankContracts/ViewModels/Cashier/ViewModels/AccountViewModel.cs b/Bank/BankContracts/ViewModels/Cashier/ViewModels/AccountViewModel.cs index 59aa9e1..f46c249 100644 --- a/Bank/BankContracts/ViewModels/Cashier/ViewModels/AccountViewModel.cs +++ b/Bank/BankContracts/ViewModels/Cashier/ViewModels/AccountViewModel.cs @@ -9,7 +9,8 @@ using System.Threading.Tasks; namespace BankContracts.ViewModels { - public class AccountViewModel : IAccountModel + // Класс для отображения информации о счетах + public class AccountViewModel : IAccountModel { public int Id { get; set; } @@ -29,13 +30,12 @@ namespace BankContracts.ViewModels [DisplayName("Статус счёта")] public StatusAccount StatusAccount { get; set; } = StatusAccount.Закрыт; - // ВОЗМОЖНО ПОНАДОБИТЬСЯ ДЛЯ ОТЧЁТОВ - //[DisplayName("Имя")] - //public string Name { get; set; } = string.Empty; + [DisplayName("Имя")] + public string Name { get; set; } = string.Empty; - //[DisplayName("Отчество")] - //public string Patronymic { get; set; } = string.Empty; + [DisplayName("Отчество")] + public string Patronymic { get; set; } = string.Empty; - //public string PasswordAccount { get; set; } = string.Empty; + public string PasswordAccount { get; set; } = string.Empty; } } diff --git a/Bank/BankContracts/ViewModels/Cashier/ViewModels/CashWithdrawalViewModel.cs b/Bank/BankContracts/ViewModels/Cashier/ViewModels/CashWithdrawalViewModel.cs index 711b650..891c035 100644 --- a/Bank/BankContracts/ViewModels/Cashier/ViewModels/CashWithdrawalViewModel.cs +++ b/Bank/BankContracts/ViewModels/Cashier/ViewModels/CashWithdrawalViewModel.cs @@ -8,24 +8,30 @@ using System.Threading.Tasks; namespace BankContracts.ViewModels.Cashier.ViewModels { - public class CashWithdrawalViewModel : ICashWithdrawalModel + // Класс для отображения информации о выдаче наличных + public class CashWithdrawalViewModel : ICashWithdrawalModel { //вот тут вопрос, смотри можно сделать номер операции айдишником //то есть просто сделать так , думаю это будет правильно - //[DisplayName("Номер операции")] + + [DisplayName("Номер операции")] public int Id { get; set; } + public int DebitingId { get; set; } - //public int AccountId { get; set; } + public int AccountId { get; set; } - // тут тоже вопрос, у нас операции не связаны ни со счетом ни с картами, поэтому это стоит обсудить - //[DisplayName("Номер счёта")] - //public string AccountNumber { get; set; } = string.Empty; + // тут тоже вопрос, у нас операции не связаны ни со счетом ни с картами, поэтому это стоит обсудить - //для более правильной логики наверное надо - //[DisplayName("Кассир")] - //public string SurmaneCashier { get; set; } = string.Empty; - public int CashierId { get; set; } + // Хмм, ну свяжем, хотя бы со счётом, потому как это сущность твоего варианта, уже как минимум стоит + + //[DisplayName("Номер счёта")] + //public string AccountNumber { get; set; } = string.Empty; + + //для более правильной логики наверное надо + //[DisplayName("Кассир")] + //public string SurmaneCashier { get; set; } = string.Empty; + public int CashierId { get; set; } [DisplayName("Сумма выданных наличных")] public double Sum { get; set; } diff --git a/Bank/BankContracts/ViewModels/Cashier/ViewModels/CashierViewModel.cs b/Bank/BankContracts/ViewModels/Cashier/ViewModels/CashierViewModel.cs index 370223c..b09d06c 100644 --- a/Bank/BankContracts/ViewModels/Cashier/ViewModels/CashierViewModel.cs +++ b/Bank/BankContracts/ViewModels/Cashier/ViewModels/CashierViewModel.cs @@ -8,7 +8,8 @@ using System.Threading.Tasks; namespace BankContracts.ViewModels.Cashier.ViewModels { - public class CashierViewModel : ICashierModel + // Класс для отображения информации о кассирах + public class CashierViewModel : ICashierModel { public int Id { get; set; } diff --git a/Bank/BankContracts/ViewModels/Cashier/ViewModels/MoneyTransferViewModel.cs b/Bank/BankContracts/ViewModels/Cashier/ViewModels/MoneyTransferViewModel.cs index b23613e..2a3670a 100644 --- a/Bank/BankContracts/ViewModels/Cashier/ViewModels/MoneyTransferViewModel.cs +++ b/Bank/BankContracts/ViewModels/Cashier/ViewModels/MoneyTransferViewModel.cs @@ -8,20 +8,31 @@ using System.Threading.Tasks; namespace BankContracts.ViewModels.Cashier.ViewModels { - public class MoneyTransferViewModel : IMoneyTransferModel + // Класс для отображения информации о переводах денег + public class MoneyTransferViewModel : IMoneyTransferModel { //как будет выглядеть перевод //я понял, что надо модель доработать скорее всего, потому что мы же переводим не в пустоту , поэтому надо добавить кому и куда переводим //хотя если судить по нашей бд, которую принял у нас Эгов не должно быть отправителя и получателя , да еще и номеров счета + + // Однако по-хорошему лучше сделать, логично, что переводы могут быть, надо тз поизучать, пока что я добавил + public int Id { get; set; } [DisplayName("Сумма перевода")] public double Sum { get; set; } - [DisplayName("Дата операции")] + // Для перевода между счетами + public int? AccountSenderId { get; set; } + + public int AccountPayeeId { get; set; } + + [DisplayName("Дата операции")] public DateTime DateTransfer { get; set; } = DateTime.Now; - public int CashierId { get; set; } + public int? CreditingId { get; } + + public int CashierId { get; set; } [DisplayName("Фамилия кассира")] public string CashierSurname { get; set; } = string.Empty; diff --git a/Bank/BankContracts/ViewModels/Client/ViewModels/CardViewModel.cs b/Bank/BankContracts/ViewModels/Client/ViewModels/CardViewModel.cs index 22f23c9..e81a05a 100644 --- a/Bank/BankContracts/ViewModels/Client/ViewModels/CardViewModel.cs +++ b/Bank/BankContracts/ViewModels/Client/ViewModels/CardViewModel.cs @@ -9,7 +9,8 @@ using System.Threading.Tasks; namespace BankContracts.ViewModels.Client.ViewModels { - public class CardViewModel : ICardModel + // Класс для отображения информации о банковских картах + public class CardViewModel : ICardModel { public int Id { get; set; } diff --git a/Bank/BankContracts/ViewModels/Client/ViewModels/ClientViewModel.cs b/Bank/BankContracts/ViewModels/Client/ViewModels/ClientViewModel.cs index 641e7e4..23ac782 100644 --- a/Bank/BankContracts/ViewModels/Client/ViewModels/ClientViewModel.cs +++ b/Bank/BankContracts/ViewModels/Client/ViewModels/ClientViewModel.cs @@ -8,7 +8,8 @@ using System.Threading.Tasks; namespace BankContracts.ViewModels.Client.ViewModels { - public class ClientViewModel : IClientModel + // Класс для отображения информации о клиентах + public class ClientViewModel : IClientModel { public int Id { get; set; } diff --git a/Bank/BankContracts/ViewModels/Client/ViewModels/CreditingViewModel.cs b/Bank/BankContracts/ViewModels/Client/ViewModels/CreditingViewModel.cs index 2e4e17e..1b5db57 100644 --- a/Bank/BankContracts/ViewModels/Client/ViewModels/CreditingViewModel.cs +++ b/Bank/BankContracts/ViewModels/Client/ViewModels/CreditingViewModel.cs @@ -8,17 +8,19 @@ using System.Threading.Tasks; namespace BankContracts.ViewModels.Client.ViewModels { - public class CreditingViewModel : ICreditingModel + // Класс для отображения информации о пополнении карты + public class CreditingViewModel : ICreditingModel { public int Id { get; set; } public int ClientId { get; set; } + public int CardId { get; set; } + [DisplayName("Сумма операции")] public double Sum { get; set; } [DisplayName("Дата заявки")] public DateTime DateCredit { get; set; } = DateTime.Now; - } } diff --git a/Bank/BankContracts/ViewModels/Client/ViewModels/DebitingViewModel.cs b/Bank/BankContracts/ViewModels/Client/ViewModels/DebitingViewModel.cs index a904cc3..c00bda6 100644 --- a/Bank/BankContracts/ViewModels/Client/ViewModels/DebitingViewModel.cs +++ b/Bank/BankContracts/ViewModels/Client/ViewModels/DebitingViewModel.cs @@ -8,11 +8,15 @@ using System.Threading.Tasks; namespace BankContracts.ViewModels.Client.ViewModels { - public class DebitingViewModel : IDebitingModel + // Класс для отображения информации о получении наличных по карте + public class DebitingViewModel : IDebitingModel { public int Id { get; set; } + public int ClientId { get; set; } + public int CardId { get; set; } + [DisplayName("Сумма операции")] public double Sum { get; set; } diff --git a/Bank/BankDataModels/Enums/MailsEnum.cs b/Bank/BankDataModels/Enums/MailsEnum.cs new file mode 100644 index 0000000..fb2698a --- /dev/null +++ b/Bank/BankDataModels/Enums/MailsEnum.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankDataModels.Enums +{ + public enum MailsEnum + { + Клиент = 0, + + Кассир = 1 + } +} diff --git a/Bank/BankDataModels/Enums/OfficeOperationEnum.cs b/Bank/BankDataModels/Enums/OfficeOperationEnum.cs new file mode 100644 index 0000000..afa50b6 --- /dev/null +++ b/Bank/BankDataModels/Enums/OfficeOperationEnum.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankDataModels.Enums +{ + public enum OfficeOperationEnum + { + Между_cчетами = 0, + + Пополнение_карт = 1, + + Cнятие_с_карты = 2, + + Для_кассира = 3 + } +} diff --git a/Bank/BankDataModels/Enums/TypeDocEnum.cs b/Bank/BankDataModels/Enums/TypeDocEnum.cs new file mode 100644 index 0000000..e909dce --- /dev/null +++ b/Bank/BankDataModels/Enums/TypeDocEnum.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankDataModels.Enums +{ + public enum TypeDocEnum + { + PDF = 0, + + EXCEL = 1, + + WORD = 2 + } +} diff --git a/Bank/BankDataModels/Models/Cashier/ICashWithdrawalModel.cs b/Bank/BankDataModels/Models/Cashier/ICashWithdrawalModel.cs index 0562f6c..4d418f4 100644 --- a/Bank/BankDataModels/Models/Cashier/ICashWithdrawalModel.cs +++ b/Bank/BankDataModels/Models/Cashier/ICashWithdrawalModel.cs @@ -10,8 +10,11 @@ namespace BankDataModels.Models.Cashier public interface ICashWithdrawalModel : IId { int DebitingId { get; } + int AccountId { get; } + int CashierId { get; } + // Сумма наличисления наличных double Sum { get; } //?? все суммы глянуть !