Косметика
This commit is contained in:
parent
2ddc277226
commit
3cc984e5da
@ -21,15 +21,12 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
|
||||
private readonly IDebitingStorage _debitingStorage;
|
||||
|
||||
private readonly ICardStorage _cardStorage;
|
||||
|
||||
public CashWithdrawalLogic(ILogger<CashWithdrawalLogic> logger, ICashWithdrawalStorage cashWithdrawalStorage,
|
||||
IDebitingStorage debitingStorage, ICardStorage cardStorage)
|
||||
IDebitingStorage debitingStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_cashWithdrawalStorage = cashWithdrawalStorage;
|
||||
_debitingStorage = debitingStorage;
|
||||
_cardStorage = cardStorage;
|
||||
}
|
||||
|
||||
public CashWithdrawalViewModel? ReadElement(CashWithdrawalSearchModel model)
|
||||
@ -80,9 +77,6 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
CheckModel(model);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
//проверка на то, что карта не просрочилась
|
||||
if (CheckCardPeriod(model))
|
||||
{
|
||||
if (_cashWithdrawalStorage.Insert(model) == null)
|
||||
{
|
||||
@ -99,16 +93,6 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
_debitingStorage.Update(new DebitingBindingModel
|
||||
{
|
||||
Id = model.DebitingId,
|
||||
DateClose = DateTime.Now,
|
||||
Status = StatusEnum.Карта_просрочена
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_debitingStorage.Update(new DebitingBindingModel
|
||||
{
|
||||
@ -186,26 +170,5 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
_logger.LogInformation("CashWithdrawal: AccountId:{AccountId}. Sum:{Sum}. DateOperation:{DateOperation}. Id:{Id}",
|
||||
model.AccountId, model.Sum, model.DateOperation, model?.Id);
|
||||
}
|
||||
|
||||
bool CheckCardPeriod(CashWithdrawalBindingModel model)
|
||||
{
|
||||
var debiting = _debitingStorage.GetElement(new DebitingSearchModel
|
||||
{
|
||||
Id = model.DebitingId
|
||||
});
|
||||
|
||||
var card = _cardStorage.GetElement(new CardSearchModel
|
||||
{
|
||||
Id = debiting.CardId
|
||||
});
|
||||
|
||||
//если карта просрочена
|
||||
if(card.Period < DateTime.Now)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using BankYouBankruptDataModels.Enums;
|
||||
|
||||
namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
{
|
||||
@ -16,16 +17,27 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICreditingStorage _creditingStorage;
|
||||
private readonly ICardStorage _cardStorage;
|
||||
|
||||
public CreditingLogic(ILogger<CreditingLogic> logger, ICreditingStorage creditingStorage) {
|
||||
public CreditingLogic(ILogger<CreditingLogic> logger, ICreditingStorage creditingStorage, ICardStorage cardStorage) {
|
||||
_logger = logger;
|
||||
_creditingStorage = creditingStorage;
|
||||
_cardStorage = cardStorage;
|
||||
}
|
||||
|
||||
public bool Create(CreditingBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (!CheckCardPeriod(model))
|
||||
{
|
||||
model.Status = StatusEnum.Карта_просрочена;
|
||||
}
|
||||
else
|
||||
{
|
||||
model.Status = StatusEnum.Открыта;
|
||||
}
|
||||
|
||||
if (_creditingStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
@ -111,5 +123,22 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
_logger.LogInformation("Crediting. Sum:{Sum}.CardId:{CardId}.Date:{date}.Id:{Id}",
|
||||
model.Sum, model.CardId, model.DateOpen.ToString(), model.Id);
|
||||
}
|
||||
|
||||
//проверка карты на просроченность
|
||||
bool CheckCardPeriod(CreditingBindingModel model)
|
||||
{
|
||||
var card = _cardStorage.GetElement(new CardSearchModel
|
||||
{
|
||||
Id = model.CardId
|
||||
});
|
||||
|
||||
//если карта просрочена
|
||||
if (card.Period < DateTime.Now)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,27 +9,43 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using BankYouBankruptDataModels.Enums;
|
||||
|
||||
namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class DebitingLogic : IDebitingLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IDebitingStorage _debitingStorage;
|
||||
|
||||
public DebitingLogic(ILogger<DebitingLogic> logger, IDebitingStorage debitingStorage) {
|
||||
private readonly ICardStorage _cardStorage;
|
||||
|
||||
public DebitingLogic(ILogger<DebitingLogic> logger, IDebitingStorage debitingStorage, ICardStorage cardStorage) {
|
||||
_logger = logger;
|
||||
_debitingStorage = debitingStorage;
|
||||
_cardStorage = cardStorage;
|
||||
}
|
||||
|
||||
public bool Create(DebitingBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (!CheckCardPeriod(model))
|
||||
{
|
||||
model.Status = StatusEnum.Карта_просрочена;
|
||||
}
|
||||
else
|
||||
{
|
||||
model.Status = StatusEnum.Открыта;
|
||||
}
|
||||
|
||||
if (_debitingStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -111,5 +127,22 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
_logger.LogInformation("Debiting. Sum:{Sum}.CardId:{CardId}.DateOpen:{DateOpen}.DateOpen:{DateOpen}.Id:{Id}",
|
||||
model.Sum, model.CardId, model.DateOpen.ToString(), model.DateClose.ToString(), model.Id);
|
||||
}
|
||||
|
||||
//проверка карты на просроченность
|
||||
bool CheckCardPeriod(DebitingBindingModel model)
|
||||
{
|
||||
var card = _cardStorage.GetElement(new CardSearchModel
|
||||
{
|
||||
Id = model.CardId
|
||||
});
|
||||
|
||||
//если карта просрочена
|
||||
if (card.Period < DateTime.Now)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
@using BankYouBankruptContracts.ViewModels.Client.Default
|
||||
@using BankYouBankruptDataModels.Enums;
|
||||
|
||||
@model List<CreditingViewModel>
|
||||
|
||||
@ -51,7 +52,7 @@
|
||||
@Html.DisplayFor(modelItem => item.Sum)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Status)
|
||||
@item.Status.ToString().Replace("_", " ")
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateOpen)
|
||||
|
@ -51,7 +51,7 @@
|
||||
@Html.DisplayFor(modelItem => item.Sum)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Status)
|
||||
@item.Status.ToString().Replace("_", " ")
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateOpen)
|
||||
|
@ -56,7 +56,8 @@ namespace BankYouBankruptDatabaseImplement.Models
|
||||
CardId = model.CardId,
|
||||
Card = context.Cards.First(x => x.Id == model.CardId),
|
||||
Sum = model.Sum,
|
||||
DateOpen = model.DateOpen
|
||||
DateOpen = model.DateOpen,
|
||||
Status = model.Status
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ namespace BankYouBankruptDatabaseImplement.Models
|
||||
Card = context.Cards.First(x => x.Id == model.CardId),
|
||||
Sum = model.Sum,
|
||||
DateOpen = model.DateOpen,
|
||||
Status = StatusEnum.Открыта
|
||||
Status = model.Status
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,6 @@ namespace BankYouBankruptRestApi.Controllers
|
||||
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public List<CardViewModel>? GetUsersCardsList(int id)
|
||||
{
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user