diff --git a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 81bc993..6726751 100644 --- a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -101,7 +101,7 @@ namespace BankBusinessLogic.OfficePackage StyleInfo = ExcelStyleInfoType.Text }); rowIndex++; - foreach (var transfer in transfer.Transfers) + foreach (var transfer1 in transfer.Transfers) { InsertCellInWorksheet(new ExcelCellParameters { diff --git a/Bank/BankDatabaseImplement/Implements/TransferStorage.cs b/Bank/BankDatabaseImplement/Implements/TransferStorage.cs index fa0803f..d75250f 100644 --- a/Bank/BankDatabaseImplement/Implements/TransferStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/TransferStorage.cs @@ -33,8 +33,7 @@ namespace BankDatabaseImplement.Implements .Include(x => x.Operation) .Where(x => (!model.Id.HasValue || x.Id == model.Id) && - (!model.ManagerId.HasValue || (x.SenderAccount != null && x.SenderAccount.ManagerId == model.ManagerId) || - (x.RecipientAccount != null && x.RecipientAccount.ManagerId == model.ManagerId)) && + (!model.ManagerId.HasValue || (x.SenderAccount != null && x.SenderAccount.ManagerId == model.ManagerId)) && (!model.SenderAccountId.HasValue || x.SenderAccountId == model.SenderAccountId) && (!model.RecipientAccountId.HasValue || x.RecipientAccountId == model.RecipientAccountId) && (!model.OperationId.HasValue || x.OperationId == model.OperationId) && diff --git a/Bank/BankDatabaseImplement/Implements/WithdrawalStorage.cs b/Bank/BankDatabaseImplement/Implements/WithdrawalStorage.cs index 3bd8ebb..5840d50 100644 --- a/Bank/BankDatabaseImplement/Implements/WithdrawalStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/WithdrawalStorage.cs @@ -29,18 +29,32 @@ namespace BankDatabaseImplement.Implements public List GetFilteredList(WithdrawalSearchModel model) { using var context = new BankDatabase(); - return context.Withdrawals - .Include(x => x.Request) - .Include(x => x.Accounts) - .ThenInclude(x => x.Account) - .Where(x => - (!model.Id.HasValue || x.Id == model.Id) && - (!model.RequestId.HasValue || x.RequestId == model.RequestId) && - (!model.DateFrom.HasValue || x.WithdrawalTime >= model.DateFrom) && - (!model.DateTo.HasValue || x.WithdrawalTime <= model.DateTo)) - .Select(x => x.GetViewModel) - .ToList(); - } + if (model.ManagerId == null) + return context.Withdrawals + .Include(x => x.Request) + .Include(x => x.Accounts) + .ThenInclude(x => x.Account) + .Where(x => + (!model.Id.HasValue || x.Id == model.Id) && + (!model.RequestId.HasValue || x.RequestId == model.RequestId) && + (!model.DateFrom.HasValue || x.WithdrawalTime >= model.DateFrom) && + (!model.DateTo.HasValue || x.WithdrawalTime <= model.DateTo)) + .Select(x => x.GetViewModel) + .ToList(); + return context.AccountWithdrawals + .Include(x => x.Account) + .Include (x => x.Withdrawal) + .Where(x => x.Account.ManagerId == model.ManagerId) + .Select(x => x.Withdrawal) + .Distinct() + .Where(x => + (!model.Id.HasValue || x.Id == model.Id) && + (!model.RequestId.HasValue || x.RequestId == model.RequestId) && + (!model.DateFrom.HasValue || x.WithdrawalTime >= model.DateFrom) && + (!model.DateTo.HasValue || x.WithdrawalTime <= model.DateTo)) + .Select(x => x.GetViewModel) + .ToList(); + } public WithdrawalViewModel? GetElement(WithdrawalSearchModel model) {