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,