From fc176b907a62c0a359d39fb9b61b4ff2975ebc8e Mon Sep 17 00:00:00 2001 From: Artyom_Yashin Date: Sun, 26 May 2024 19:33:04 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=82=D1=87=D0=B5=D1=82=D1=8B=20=D0=BD?= =?UTF-8?q?=D0=B0=D1=87=D0=B0=D0=BB=D0=B8=20=D1=81=D0=BE=D1=85=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D1=8F=D1=82=D1=8C=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bank/BankClientApp/Controllers/HomeController.cs | 5 +++++ Bank/BankDatabaseImplement/Implements/CardStorage.cs | 5 +++-- Bank/BankDatabaseImplement/Implements/OperationStorage.cs | 6 +++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Bank/BankClientApp/Controllers/HomeController.cs b/Bank/BankClientApp/Controllers/HomeController.cs index 38711f5..3e8fc3a 100644 --- a/Bank/BankClientApp/Controllers/HomeController.cs +++ b/Bank/BankClientApp/Controllers/HomeController.cs @@ -4,6 +4,7 @@ using BankContracts.SearchModels; using BankContracts.ViewModels; using BankDatabaseImplement.Models; using BankDataModels.Models; +using DocumentFormat.OpenXml.Spreadsheet; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore.Metadata.Internal; using System.Diagnostics; @@ -523,14 +524,18 @@ namespace BankClientApp.Controllers case "word": APIClient.PostRequest($"api/report/savetransferstoword", new ReportBindingModel { + FileName = "C:\\Users\\123\\Desktop\\wordfile.docx", SelectedCardIds = cards, }); + Response.Redirect("TransferListReport"); break; case "excel": APIClient.PostRequest($"api/report/savetransferstoword", new ReportBindingModel { + FileName = "C:\\Users\\123\\Desktop\\wordfile.docx", SelectedCardIds = cards, }); + Response.Redirect("TransferListReport"); break; default: break; } diff --git a/Bank/BankDatabaseImplement/Implements/CardStorage.cs b/Bank/BankDatabaseImplement/Implements/CardStorage.cs index f32a1f3..1f5770a 100644 --- a/Bank/BankDatabaseImplement/Implements/CardStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/CardStorage.cs @@ -4,6 +4,7 @@ using BankContracts.StoragesContracts; using BankContracts.ViewModels; using BankDatabaseImplement.Models; using Microsoft.EntityFrameworkCore; +using System.Linq; namespace BankDatabaseImplement.Implements { @@ -50,8 +51,8 @@ namespace BankDatabaseImplement.Implements { CardNumber = t.Number, Transfers = context.Transfers - .Include(c => c.Operation) - .Where(x => x.Operation == null || x.Operation.SenderCardId == model.Id || x.Operation.RecipientCardId == model.Id) + .Include(c => c.Operation).Include(c => c.RecipientAccount).Include(c => c.SenderAccount) + .Where(x => x.Operation == null || model.SelectedCardIds == null || model.SelectedCardIds.Contains((int)x.Operation.SenderCardId) || model.SelectedCardIds.Contains((int)x.Operation.RecipientCardId)) .Select(t => t.GetViewModel) .ToList() }).ToList(); diff --git a/Bank/BankDatabaseImplement/Implements/OperationStorage.cs b/Bank/BankDatabaseImplement/Implements/OperationStorage.cs index 619a6a1..ad611fc 100644 --- a/Bank/BankDatabaseImplement/Implements/OperationStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/OperationStorage.cs @@ -85,10 +85,14 @@ namespace BankDatabaseImplement.Implements { using var context = new BankDatabase(); var transfer = context.Transfers.Include(x => x.SenderAccount).Include(x => x.RecipientAccount).Include(x => x.Operation).FirstOrDefault(rec => rec.Id == transferId); - if (transfer == null || operationId <= 0) + if (transfer == null || operationId <= 0 ) { return false; } + if (transfer.OperationId != null || context.Transfers.Where(x => x.OperationId == operationId).Count() > 0 ) + { + throw new Exception("Невозможно связать выбранные сущности"); + } var newTransfer = new TransferBindingModel { Sum = transfer.Sum,