CourseWork_Bank/Bank/BankBusinessLogic/BusinessLogic/Reports/ReportCashierLogic.cs
2024-05-01 03:18:08 +04:00

142 lines
4.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using BankBusinessLogic.OfficePackage;
using BankBusinessLogic.OfficePackage.HelperModels;
using BankContracts.BindingModels.Reports;
using BankContracts.BusinessLogicsContracts.Reports;
using BankContracts.SearchModels.Cashier;
using BankContracts.SearchModels.Client;
using BankContracts.StoragesModels.Cashier;
using BankContracts.StoragesModels.Client;
using BankContracts.ViewModels.Client.ViewModels;
using BankContracts.ViewModels.Reports.Cashier;
using BankContracts.ViewModels.Reports;
using BankDatabaseImplement.Implements.ClientImplements;
using BankDataModels.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankBusinessLogic.BusinessLogic.Reports
{
public class ReportCashierLogic : IReportCashierLogic
{
private readonly IMoneyTransferStorage _moneyTransferStorage;
private readonly ICashWithdrawalStorage _cashWithdrawalStorage;
private readonly IDebitingStorage _debitingStorage;
private readonly IClientStorage _clientStorage;
private readonly ICardStorage _cardStorage;
private readonly AbstractSaveToExcel _saveToExcel;
private readonly AbstractSaveToWord _saveToWord;
private readonly AbstractSaveToPdf _saveToPdf;
// Конструктор
public ReportCashierLogic(IMoneyTransferStorage moneyTransferStorage, ICashWithdrawalStorage cashWithdrawalStorage,
IDebitingStorage debitingStorage, IClientStorage clientStorage, ICardStorage cardStorage,
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
{
_moneyTransferStorage = moneyTransferStorage;
_cashWithdrawalStorage = cashWithdrawalStorage;
_debitingStorage = debitingStorage;
_clientStorage = clientStorage;
_cardStorage = cardStorage;
_saveToExcel = saveToExcel;
_saveToWord = saveToWord;
_saveToPdf = saveToPdf;
}
// Формирование списка переводов между счетами
public List<ReportCashierViewModel>? GetMoneyTransfers(ReportBindingModel model)
{
return _moneyTransferStorage.GetFilteredList(new MoneyTransferSearchModel { ClientId = model.ClientId, DateTransfer = model.DateTo })
.Select(x => new ReportCashierViewModel
{
OperationId = x.Id,
DateComplite = x.DateTransfer,
AccountSenderNumber = x.AccountPayeeNumber,
AccountPayeeNumber = x.AccountSenderNumber,
SumOperation = x.Sum
})
.ToList();
}
// Формирование списка выдачи наличных со счёта
public List<ReportCashierViewModel>? GetCashWithrawals(ReportBindingModel model)
{
return _cashWithdrawalStorage.GetFilteredList(new CashWithdrawalSearchModel { ClientId = model.ClientId, DateWithdrawal = model.DateTo })
.Select(x => new ReportCashierViewModel
{
OperationId = x.Id,
DebitingId = x.DebitingId,
AccountPayeeNumber = x.AccountNumber,
DateComplite = x.DateWithdrawal,
SumOperation = x.Sum
})
.ToList();
}
// Формирование списка выдачи наличных со счёта за период
public List<DebitingViewModel>? GetDebitings(ReportBindingModel model)
{
List<int> CardIdList = new();
var list = _cardStorage.GetFilteredList(new CardSearchModel
{
AccountId = model.AccountId
});
foreach (var index in list)
{
CardIdList.Add(index.Id);
}
List<DebitingViewModel> totalList = new();
foreach (var index in CardIdList)
{
var result = _debitingStorage.GetFilteredList(new DebitingSearchModel
{
CardId = index
});
totalList.AddRange(result);
}
return totalList;
}
// Формирование полного имени клиента для отчёта
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)
{
throw new NotImplementedException();
}
// Сохранение счетов в файл-Excel
public void SaveAccountsToExcelFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
// Сохранение счетов в файл-Pdf
public ReportCashierViewModelForHTML SaveAccountsToPdfFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
}
}