This commit is contained in:
Zakharov_Rostislav 2024-05-26 23:49:48 +04:00
commit 610aae94b1
2 changed files with 19 additions and 1 deletions

View File

@ -55,6 +55,11 @@ namespace BankDatabaseImplement.Implements
{
using var context = new BankDatabase();
var operation = context.Operations.Include(x => x.SenderCard).Include(x => x.RecipientCard).Include(x => x.Transfer).FirstOrDefault(x => x.Id == model.Id);
var transfer = context.Transfers.FirstOrDefault(x => x.OperationId == model.Id);
if (transfer != null)
{
return null;
}
if (operation == null)
{
return null;
@ -67,6 +72,11 @@ namespace BankDatabaseImplement.Implements
{
using var context = new BankDatabase();
var operation = context.Operations.Include(x => x.SenderCard).Include(x => x.RecipientCard).Include(x => x.Transfer).FirstOrDefault(rec => rec.Id == model.Id);
var transfer = context.Transfers.FirstOrDefault(x => x.OperationId == model.Id);
if (transfer != null)
{
return null;
}
if (operation != null)
{
context.Operations.Remove(operation);

View File

@ -73,7 +73,11 @@ namespace BankDatabaseImplement.Implements
var Request = context.Requests.FirstOrDefault(rec => rec.Id == model.Id);
if (Request == null)
{
return null;
throw new Exception("Заявка не найдена");
}
if (Request.Status != RequestStatus.Принята)
{
throw new InvalidOperationException("Заявка уже выполнена");
}
Request.Update(model);
context.SaveChanges();
@ -93,6 +97,10 @@ namespace BankDatabaseImplement.Implements
var element = context.Requests
.Include(x => x.Cards)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element?.Status != RequestStatus.Принята)
{
return null;
}
if (element != null)
{
context.Requests.Remove(element);