Merge branch 'ManagersApp' of https://git.is.ulstu.ru/Artyom_Yashin/PIbd-23_Yashin_A_Zakharov_R_CourseWork_Bank into ManagersApp
This commit is contained in:
commit
610aae94b1
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user