Merge branch 'main' of https://git.is.ulstu.ru/Artyom_Yashin/PIbd-23_Yashin_A_Zakharov_R_CourseWork_Bank
This commit is contained in:
commit
c0a5e57791
@ -2,11 +2,11 @@
|
||||
ViewData["Title"] = "RequestDelete";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Удаление запрос</h2>
|
||||
<h2 class="display-4">Удаление заявки</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Запрос:</div>
|
||||
<div class="col-4">Заявка:</div>
|
||||
<div class="col-8">
|
||||
<select id="request" name="request" class="form-control" asp-items="@(new SelectList(@ViewBag.Requests, "Id", "Id"))"></select>
|
||||
</div>
|
||||
|
@ -11,7 +11,8 @@ namespace BankContracts.SearchModels
|
||||
public int? Id { get; set; }
|
||||
public string? Number { get; set; }
|
||||
public int? ClientId { get; set; }
|
||||
public DateTime? ReleaseDate { get; set; }
|
||||
public DateTime? ExpirationDate { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public List<int>? SelectedCardIds { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,5 @@ namespace BankContracts.SearchModels
|
||||
public int? OperationId { get; set; }
|
||||
public int? SenderAccountId { get; set; }
|
||||
public int? RecipientAccountId { get; set; }
|
||||
public int? CardId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankContracts.ViewModels
|
||||
{
|
||||
public class ReportOperationsRequestsViewModel
|
||||
{
|
||||
public string CardNumber { get; set; } = string.Empty;
|
||||
public List<OperationViewModel> SenderOperations { get; set; } = new();
|
||||
public List<OperationViewModel> RecipientOperations { get; set; } = new();
|
||||
public List<RequestViewModel> Requests { get; set; } = new();
|
||||
}
|
||||
}
|
14
Bank/BankContracts/ViewModels/ReportTransfersViewModel.cs
Normal file
14
Bank/BankContracts/ViewModels/ReportTransfersViewModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankContracts.ViewModels
|
||||
{
|
||||
public class ReportTransfersViewModel
|
||||
{
|
||||
public string CardNumber { get; set; } = string.Empty;
|
||||
public List<TransferViewModel> Transfers { get; set; } = new();
|
||||
}
|
||||
}
|
@ -29,6 +29,48 @@ namespace BankDatabaseImplement.Implements
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ReportTransfersViewModel> GetReportTransfersList(CardSearchModel model)
|
||||
{
|
||||
using var context = new BankDatabase();
|
||||
return context.Cards
|
||||
.Where(c => model.SelectedCardIds == null || model.SelectedCardIds.Contains(c.Id))
|
||||
.Include(c => c.RecipientOperations).ThenInclude(x => x.Transfer)
|
||||
.Include(c => c.SenderOperations).ThenInclude(x => x.Transfer)
|
||||
.Select(t => new ReportTransfersViewModel()
|
||||
{
|
||||
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)
|
||||
.Select(t => t.GetViewModel)
|
||||
.ToList()
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public List<ReportOperationsRequestsViewModel> GetReportOperationsREquestsList(CardSearchModel model)
|
||||
{
|
||||
using var context = new BankDatabase();
|
||||
return context.Cards
|
||||
.Select(c => new ReportOperationsRequestsViewModel()
|
||||
{
|
||||
CardNumber = c.Number,
|
||||
SenderOperations = context.Operations
|
||||
.Where(x => x.OperationTime >= model.DateFrom && x.OperationTime <= model.DateTo && x.SenderCardId == model.Id)
|
||||
.Select(t => t.GetViewModel)
|
||||
.ToList(),
|
||||
RecipientOperations = context.Operations
|
||||
.Where(x => x.OperationTime >= model.DateFrom && x.OperationTime <= model.DateTo && x.RecipientCardId == model.Id)
|
||||
.Select(t => t.GetViewModel)
|
||||
.ToList(),
|
||||
Requests = context.Requests
|
||||
.Include(x => x.CardRequests)
|
||||
.Where(x => x.Cards.Select(x => x.CardId).ToList().Contains(c.Id) && x.RequestTime >= model.DateFrom && x.RequestTime <= model.DateTo)
|
||||
.Select(r => r.GetViewModel)
|
||||
.ToList(),
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public CardViewModel? GetElement(CardSearchModel model)
|
||||
{
|
||||
using var context = new BankDatabase();
|
||||
|
@ -31,8 +31,7 @@ namespace BankDatabaseImplement.Implements
|
||||
return context.Requests.Include(x => x.Cards).ThenInclude(x => x.Card)
|
||||
.Where(x => (model.Id.HasValue && x.Id == model.Id) &&
|
||||
(!model.DateFrom.HasValue || x.RequestTime >= model.DateFrom) &&
|
||||
(!model.DateTo.HasValue || x.RequestTime <= model.DateTo) &&
|
||||
(!model.CardId.HasValue || x.Cards.Select(x => x.CardId).ToList().Contains(model.CardId.Value))
|
||||
(!model.DateTo.HasValue || x.RequestTime <= model.DateTo)
|
||||
).ToList()
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
@ -37,8 +37,7 @@ namespace BankDatabaseImplement.Implements
|
||||
(!model.RecipientAccountId.HasValue || x.RecipientAccountId == model.RecipientAccountId) &&
|
||||
(!model.OperationId.HasValue || x.OperationId == model.OperationId) &&
|
||||
(!model.DateFrom.HasValue || x.TransferTime >= model.DateFrom) &&
|
||||
(!model.DateTo.HasValue || x.TransferTime <= model.DateTo) &&
|
||||
(!model.CardId.HasValue || x.Operation.RecipientCardId == model.CardId || x.Operation.SenderCardId == model.CardId)
|
||||
(!model.DateTo.HasValue || x.TransferTime <= model.DateTo)
|
||||
).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ using BankDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -23,7 +24,9 @@ namespace BankDatabaseImplement.Models
|
||||
public virtual Card? SenderCard { get; private set; }
|
||||
[Required]
|
||||
public int RecipientCardId { get; set; }
|
||||
public virtual Card? RecipientCard { get; private set; }
|
||||
public virtual Card? RecipientCard { get; private set; }
|
||||
[ForeignKey("OperationId")]
|
||||
public virtual Transfer? Transfer { get; private set; }
|
||||
|
||||
public static Operation? Create(OperationBindingModel model)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user