feat: подготовка моделей к для связи многие ко многи
This commit is contained in:
@@ -12,7 +12,10 @@ namespace BankContracts.DataModels;
|
||||
/// <param name="surname">фамилия клиента</param>
|
||||
/// <param name="balance">баланс клиента</param>
|
||||
/// <param name="clerkId">уникальный Guid индентификатор клерка</param>
|
||||
public class ClientDataModel(string id, string name, string surname, decimal balance, string clerkId) : IValidation
|
||||
/// <param name="depositClients">вклады клиента</param>
|
||||
/// <param name="creditProgramClients">кредитные программы клиента</param>
|
||||
public class ClientDataModel(string id, string name, string surname, decimal balance, string clerkId,
|
||||
List<DepositClientDataModel> depositClients, List<ClientCreditProgramDataModel> creditProgramClients) : IValidation
|
||||
{
|
||||
public string Id { get; private set; } = id;
|
||||
|
||||
@@ -24,6 +27,10 @@ public class ClientDataModel(string id, string name, string surname, decimal bal
|
||||
|
||||
public string ClerkId { get; private set; } = clerkId;
|
||||
|
||||
public List<DepositClientDataModel> Deposits { get; private set; } = depositClients;
|
||||
|
||||
public List<ClientCreditProgramDataModel> CreditPrograms { get; private set; } = creditProgramClients;
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (Id.IsEmpty())
|
||||
@@ -54,5 +61,13 @@ public class ClientDataModel(string id, string name, string surname, decimal bal
|
||||
{
|
||||
throw new ValidationException("The value in the field Clerkid is not a unique identifier");
|
||||
}
|
||||
if ((Deposits?.Count ?? 0) == 0)
|
||||
{
|
||||
throw new ValidationException("The client must include deposits");
|
||||
}
|
||||
if ((CreditPrograms?.Count ?? 0) == 0)
|
||||
{
|
||||
throw new ValidationException("The client must include credit programs");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ namespace BankContracts.DataModels;
|
||||
/// <param name="maxCost">максимальная сумма</param>
|
||||
/// <param name="storekeeperId">уникальный Guid Индентификатор кладовщика</param>
|
||||
/// <param name="periodId">уникальный Guid Индентификатор срока</param>
|
||||
public class CreditProgramDataModel(string id, string name, decimal cost, decimal maxCost, string storekeeperId, string periodId) : IValidation
|
||||
/// <param name="currencyCreditPrograms">валюты кредитной программы</param>
|
||||
public class CreditProgramDataModel(string id, string name, decimal cost, decimal maxCost, string storekeeperId, string periodId,
|
||||
List<CreditProgramCurrencyDataModel> currencyCreditPrograms) : IValidation
|
||||
{
|
||||
public string Id { get; private set; } = id;
|
||||
|
||||
@@ -27,6 +29,8 @@ public class CreditProgramDataModel(string id, string name, decimal cost, decima
|
||||
|
||||
public string PeriodId { get; private set; } = periodId;
|
||||
|
||||
public List<CreditProgramCurrencyDataModel> Currencies { get; private set; } = currencyCreditPrograms;
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (Id.IsEmpty())
|
||||
@@ -65,5 +69,9 @@ public class CreditProgramDataModel(string id, string name, decimal cost, decima
|
||||
{
|
||||
throw new ValidationException("The value in the field PeriodId is not a unique identifier");
|
||||
}
|
||||
if ((Currencies?.Count ?? 0) == 0)
|
||||
{
|
||||
throw new ValidationException("The credit program must include currencies");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,9 @@ namespace BankContracts.DataModels;
|
||||
/// <param name="cost">стоимость</param>
|
||||
/// <param name="period">срок</param>
|
||||
/// <param name="clerkId">уникальный Guid индентификатор клерка</param>
|
||||
public class DepositDataModel(string id, float interestRate, decimal cost, int period, string clerkId) : IValidation
|
||||
/// <param name="depositCurrencies">валюты вклада</param>
|
||||
public class DepositDataModel(string id, float interestRate, decimal cost, int period, string clerkId,
|
||||
List<DepositCurrencyDataModel> depositCurrencies) : IValidation
|
||||
{
|
||||
public string Id { get; private set; } = id;
|
||||
|
||||
@@ -24,6 +26,8 @@ public class DepositDataModel(string id, float interestRate, decimal cost, int p
|
||||
|
||||
public string ClerkId { get; private set; } = clerkId;
|
||||
|
||||
public List<DepositCurrencyDataModel> Currencies { get; private set; } = depositCurrencies;
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (Id.IsEmpty())
|
||||
@@ -54,5 +58,9 @@ public class DepositDataModel(string id, float interestRate, decimal cost, int p
|
||||
{
|
||||
throw new ValidationException("The value in the field ClerkId is not a unique identifier");
|
||||
}
|
||||
if ((Currencies?.Count ?? 0) == 0)
|
||||
{
|
||||
throw new ValidationException("The deposit must include currencies");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,13 @@ namespace BankContracts.DataModels;
|
||||
/// <param name="password">пароль</param>
|
||||
/// <param name="email">адрес электронной почты</param>
|
||||
/// <param name="phoneNumber">номер телефона</param>
|
||||
/// <param name="currencies">валюты</param>
|
||||
/// <param name="periods">сроки</param>
|
||||
/// <param name="creditPrograms">кредитные программы</param>
|
||||
public class StorekeeperDataModel(
|
||||
string id, string name, string surname, string middleName,
|
||||
string login, string password, string email, string phoneNumber) : IValidation
|
||||
string login, string password, string email, string phoneNumber, List<CurrencyDataModel> currencies,
|
||||
List<PeriodDataModel> periods, List<CreditProgramDataModel> creditPrograms) : IValidation
|
||||
{
|
||||
public string Id { get; private set; } = id;
|
||||
|
||||
@@ -36,6 +40,12 @@ public class StorekeeperDataModel(
|
||||
|
||||
public string PhoneNumber { get; private set; } = phoneNumber;
|
||||
|
||||
public List<CurrencyDataModel> Currencies { get; private set; } = currencies;
|
||||
|
||||
public List<PeriodDataModel> Periods { get; private set; } = periods;
|
||||
|
||||
public List<CreditProgramDataModel> CreditPrograms { get; private set; } = creditPrograms;
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (Id.IsEmpty())
|
||||
@@ -82,5 +92,17 @@ public class StorekeeperDataModel(
|
||||
{
|
||||
throw new ValidationException("Field PhoneNumber is not a phone number");
|
||||
}
|
||||
if (Currencies is null)
|
||||
{
|
||||
throw new ValidationException("Field Currencies is null");
|
||||
}
|
||||
if (Periods is null)
|
||||
{
|
||||
throw new ValidationException("Field Periods is null");
|
||||
}
|
||||
if (CreditPrograms is null)
|
||||
{
|
||||
throw new ValidationException("Field CreditPrograms is null");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user