Снова продвижение.
This commit is contained in:
parent
0d96bd546e
commit
a3dee70b4b
@ -3,6 +3,7 @@ using BankYouBankruptContracts.BusinessLogicsContracts;
|
|||||||
using BankYouBankruptContracts.SearchModels;
|
using BankYouBankruptContracts.SearchModels;
|
||||||
using BankYouBankruptContracts.StoragesContracts;
|
using BankYouBankruptContracts.StoragesContracts;
|
||||||
using BankYouBankruptContracts.ViewModels;
|
using BankYouBankruptContracts.ViewModels;
|
||||||
|
using BankYouBankruptDataModels.Enums;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -18,10 +19,13 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
private readonly ICashWithdrawalStorage _cashWithdrawalStorage;
|
private readonly ICashWithdrawalStorage _cashWithdrawalStorage;
|
||||||
|
|
||||||
public CashWithdrawalLogic(ILogger<CashWithdrawalLogic> logger, ICashWithdrawalStorage cashWithdrawalStorage)
|
private readonly IDebitingStorage _debitingStorage;
|
||||||
|
|
||||||
|
public CashWithdrawalLogic(ILogger<CashWithdrawalLogic> logger, ICashWithdrawalStorage cashWithdrawalStorage, IDebitingStorage debitingStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_cashWithdrawalStorage = cashWithdrawalStorage;
|
_cashWithdrawalStorage = cashWithdrawalStorage;
|
||||||
|
_debitingStorage = debitingStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CashWithdrawalViewModel? ReadElement(CashWithdrawalSearchModel model)
|
public CashWithdrawalViewModel? ReadElement(CashWithdrawalSearchModel model)
|
||||||
@ -78,6 +82,13 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_debitingStorage.Update(new DebitingBindingModel
|
||||||
|
{
|
||||||
|
Id = model.DebitingId,
|
||||||
|
DateClose = DateTime.Now,
|
||||||
|
Status = StatusEnum.Закрыта
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +137,7 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
|
|
||||||
//проверка на корректность Id счёта
|
//проверка на корректность Id счёта
|
||||||
if (model.AccountId > 0)
|
if (model.AccountId < 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Некорректный Id счёта", nameof(model.AccountId));
|
throw new ArgumentNullException("Некорректный Id счёта", nameof(model.AccountId));
|
||||||
}
|
}
|
||||||
|
@ -78,11 +78,14 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
|
|||||||
public bool Update(DebitingBindingModel model)
|
public bool Update(DebitingBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
|
|
||||||
if (_debitingStorage.Update(model) == null)
|
if (_debitingStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ namespace BankYouBankruptContracts.ViewModels
|
|||||||
public int AccountId { get; set; }
|
public int AccountId { get; set; }
|
||||||
|
|
||||||
[DisplayName("Номер счёта")]
|
[DisplayName("Номер счёта")]
|
||||||
public int AccountNumber { get; set; }
|
public string AccountNumber { get; set; } = string.Empty;
|
||||||
|
|
||||||
public int CashierId { get; set; }
|
public int CashierId { get; set; }
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ namespace BankYouBankruptDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
var debiting = context.Debitings.FirstOrDefault(rec => rec.Id == model.Id);
|
var debiting = context.Debitings.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
|
||||||
if (debiting == null)
|
if (debiting == null && debiting.Status == StatusEnum.Закрыта)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -97,7 +97,10 @@ namespace BankYouBankruptDatabaseImplement.Implements
|
|||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
|
|
||||||
return debiting.GetViewModel;
|
return context.Debitings
|
||||||
|
.Include(x => x.Card)
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id)
|
||||||
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -45,6 +45,11 @@ namespace BankYouBankruptDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
AccountId = model.AccountId,
|
AccountId = model.AccountId,
|
||||||
|
Account = context.Accounts.First(x => x.Id == model.AccountId),
|
||||||
|
DebitingId = model.DebitingId,
|
||||||
|
Debiting = context.Debitings.First(x => x.Id == model.DebitingId),
|
||||||
|
CashierId = model.CashierId,
|
||||||
|
Cashier = context.Cashiers.First(x => x.Id == model.CashierId),
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
DateOperation = model.DateOperation
|
DateOperation = model.DateOperation
|
||||||
};
|
};
|
||||||
@ -59,6 +64,11 @@ namespace BankYouBankruptDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
AccountId = AccountId,
|
AccountId = AccountId,
|
||||||
|
CashierId = CashierId,
|
||||||
|
DebitingId = DebitingId,
|
||||||
|
AccountNumber = Account.AccountNumber,
|
||||||
|
SurmaneCashier = Cashier.Surname,
|
||||||
|
DebbitingNumber = Debiting.Id,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
DateOperation = DateOperation
|
DateOperation = DateOperation
|
||||||
};
|
};
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using BankYouBankruptContracts.BusinessLogicsContracts;
|
using BankYouBankruptContracts.BusinessLogicsContracts;
|
||||||
using BankYouBankruptContracts.SearchModels;
|
using BankYouBankruptContracts.SearchModels;
|
||||||
using BankYouBankruptContracts.ViewModels;
|
using BankYouBankruptContracts.ViewModels;
|
||||||
|
using BankYouBankruptDatabaseImplement.Models;
|
||||||
using BankYouBankruptDataModels.Enums;
|
using BankYouBankruptDataModels.Enums;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
@ -18,11 +19,14 @@ namespace BankYouBankruptRestApi.Controllers
|
|||||||
|
|
||||||
private readonly IDebitingLogic _debitingLogic;
|
private readonly IDebitingLogic _debitingLogic;
|
||||||
|
|
||||||
public AccountController(IAccountLogic accountLogic, IDebitingLogic debitingLogic, ILogger<AccountController> logger)
|
private readonly ICashWithdrawalLogic _cashLogic;
|
||||||
|
|
||||||
|
public AccountController(IAccountLogic accountLogic, IDebitingLogic debitingLogic, ICashWithdrawalLogic cashLogic, ILogger<AccountController> logger)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_accountLogic = accountLogic;
|
_accountLogic = accountLogic;
|
||||||
_debitingLogic = debitingLogic;
|
_debitingLogic = debitingLogic;
|
||||||
|
_cashLogic = cashLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -128,5 +132,20 @@ namespace BankYouBankruptRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//подтверждение заявки на снятие средств со счёта
|
||||||
|
[HttpPost]
|
||||||
|
public void CloseApplication(CashWithdrawalBindingModel CashWithdrawal)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_cashLogic.Create(CashWithdrawal);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка входа в систему");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user