Отчеты начали сохраняться

This commit is contained in:
Artyom_Yashin 2024-05-26 19:33:04 +04:00
parent ca859d9bc5
commit fc176b907a
3 changed files with 13 additions and 3 deletions

View File

@ -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;
}

View File

@ -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();

View File

@ -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,