CourseWork_Bank/Bank/BankBusinessLogic/BusinessLogic/Reports/ReportClientLogic.cs

164 lines
4.7 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.Cashier.ViewModels;
using BankContracts.ViewModels.Client.ViewModels;
using BankContracts.ViewModels.Reports;
using BankContracts.ViewModels.Reports.Client;
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 ReportClientLogic : IReportClientLogic
{
private readonly IMoneyTransferStorage _moneyTransferStorage;
private readonly ICreditingStorage _creditingStorage;
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 ReportClientLogic(IMoneyTransferStorage moneyTransferStorage,ICreditingStorage creditingStorage,
IDebitingStorage debitingStorage, IClientStorage clientStorage, ICardStorage cardStorage,
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
{
_moneyTransferStorage = moneyTransferStorage;
_creditingStorage = creditingStorage;
_debitingStorage = debitingStorage;
_clientStorage = clientStorage;
_cardStorage = cardStorage;
_saveToExcel = saveToExcel;
_saveToWord = saveToWord;
_saveToPdf = saveToPdf;
}
public List<ReportClientViewModel>? GetCrediting(ReportBindingModel model)
{
return _creditingStorage.GetFilteredList(new CreditingSearchModel
{
DateCrediting = model.DateFrom,
}).Select(x => new ReportClientViewModel
{
OperationId = x.Id,
CardNumber = x.CardNumber,
SumOperation = x.Sum,
DateComplite = x.DateCredit
}).ToList();
}
public List<ReportClientViewModel>? GetDebiting(ReportBindingModel model)
{
return _debitingStorage.GetFilteredList(new DebitingSearchModel
{
DateDebit = model.DateFrom,
}).Select(x => new ReportClientViewModel
{
OperationId = x.Id,
CardNumber = x.CardNumber,
SumOperation = x.Sum,
DateComplite = x.DateDebit
}).ToList();
}
// Для Excel отчёта по переводам между счетов
public List<MoneyTransferViewModel>? GetMoneyTransfer(ReportBindingModel model)
{
// Список счетов по выбранным картам
List<int> accountId = new();
foreach (var index in model.CardList)
{
accountId.Add(_cardStorage.GetElement(new CardSearchModel { Id = index }).AccountId);
}
var list = accountId.ToHashSet().ToList();
List<MoneyTransferViewModel> totalList = new();
foreach (var index in list)
{
var result = _moneyTransferStorage.GetFilteredList(new MoneyTransferSearchModel
{
AccountSenderId = index,
AccountPayeeId = index
}).OrderBy(x => x.AccountSenderId).ToList();
totalList.AddRange(result);
}
return totalList;
}
// Для Excel отчёта по пополнениям карты
public List<CreditingViewModel> GetExcelCrediting(ReportBindingModel model)
{
List<CreditingViewModel> totalList = new();
foreach (var index in model.CardList)
{
var result = _creditingStorage.GetFilteredList(new CreditingSearchModel
{
CardId = index
});
totalList.AddRange(result);
}
return totalList;
}
// Для Excel отчёта по снятиям с карты
public List<DebitingViewModel> GetExcelDebiting(ReportBindingModel model)
{
List<DebitingViewModel> totalList = new();
foreach (var index in model.CardList)
{
var result = _debitingStorage.GetFilteredList(new DebitingSearchModel
{
CardId = index
});
totalList.AddRange(result);
}
return totalList;
}
// Сохранение в файл-Excel для клиентов
public void SaveToExcelFile(ReportBindingModel model, OfficeOperationEnum operationEnum)
{
throw new NotImplementedException();
}
// Сохранение в файл-Word для клиентов
public void SaveToWordFile(ReportBindingModel model, OfficeOperationEnum operationEnum)
{
throw new NotImplementedException();
}
// Сохранение в файл-Pdf для клиента
public ReportClientViewModelForHTML SaveClientReportToPdfFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
}
}