diff --git a/TheBank/BankContracts/DataModels/ClientDataModel.cs b/TheBank/BankContracts/DataModels/ClientDataModel.cs index 1665709..d1c5763 100644 --- a/TheBank/BankContracts/DataModels/ClientDataModel.cs +++ b/TheBank/BankContracts/DataModels/ClientDataModel.cs @@ -12,7 +12,10 @@ namespace BankContracts.DataModels; /// фамилия клиента /// баланс клиента /// уникальный Guid индентификатор клерка -public class ClientDataModel(string id, string name, string surname, decimal balance, string clerkId) : IValidation +/// вклады клиента +/// кредитные программы клиента +public class ClientDataModel(string id, string name, string surname, decimal balance, string clerkId, + List depositClients, List 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 Deposits { get; private set; } = depositClients; + + public List 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"); + } } } diff --git a/TheBank/BankContracts/DataModels/CreditProgramDataModel.cs b/TheBank/BankContracts/DataModels/CreditProgramDataModel.cs index e7ee5af..7553777 100644 --- a/TheBank/BankContracts/DataModels/CreditProgramDataModel.cs +++ b/TheBank/BankContracts/DataModels/CreditProgramDataModel.cs @@ -13,7 +13,9 @@ namespace BankContracts.DataModels; /// максимальная сумма /// уникальный Guid Индентификатор кладовщика /// уникальный Guid Индентификатор срока -public class CreditProgramDataModel(string id, string name, decimal cost, decimal maxCost, string storekeeperId, string periodId) : IValidation +/// валюты кредитной программы +public class CreditProgramDataModel(string id, string name, decimal cost, decimal maxCost, string storekeeperId, string periodId, + List 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 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"); + } } } diff --git a/TheBank/BankContracts/DataModels/DepositDataModel.cs b/TheBank/BankContracts/DataModels/DepositDataModel.cs index 7dbcc47..82b49af 100644 --- a/TheBank/BankContracts/DataModels/DepositDataModel.cs +++ b/TheBank/BankContracts/DataModels/DepositDataModel.cs @@ -12,7 +12,9 @@ namespace BankContracts.DataModels; /// стоимость /// срок /// уникальный Guid индентификатор клерка -public class DepositDataModel(string id, float interestRate, decimal cost, int period, string clerkId) : IValidation +/// валюты вклада +public class DepositDataModel(string id, float interestRate, decimal cost, int period, string clerkId, + List 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 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"); + } } } diff --git a/TheBank/BankContracts/DataModels/StorekeeperDataModel.cs b/TheBank/BankContracts/DataModels/StorekeeperDataModel.cs index b9a9037..608af2d 100644 --- a/TheBank/BankContracts/DataModels/StorekeeperDataModel.cs +++ b/TheBank/BankContracts/DataModels/StorekeeperDataModel.cs @@ -16,9 +16,13 @@ namespace BankContracts.DataModels; /// пароль /// адрес электронной почты /// номер телефона +/// валюты +/// сроки +/// кредитные программы 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 currencies, + List periods, List 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 Currencies { get; private set; } = currencies; + + public List Periods { get; private set; } = periods; + + public List 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"); + } } }