From d3797f12abf02f0c1a360b80002b30f2e3511395 Mon Sep 17 00:00:00 2001 From: xom9k Date: Fri, 25 Apr 2025 09:57:08 +0400 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=BF=D0=BE=D0=B4=D0=B3=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D0=B5?= =?UTF-8?q?=D0=B9=20=D0=BA=20=D0=B4=D0=BB=D1=8F=20=D1=81=D0=B2=D1=8F=D0=B7?= =?UTF-8?q?=D0=B8=20=D0=BC=D0=BD=D0=BE=D0=B3=D0=B8=D0=B5=20=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=BC=D0=BD=D0=BE=D0=B3=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataModels/ClientDataModel.cs | 17 ++++++++++++- .../DataModels/CreditProgramDataModel.cs | 10 +++++++- .../DataModels/DepositDataModel.cs | 10 +++++++- .../DataModels/StorekeeperDataModel.cs | 24 ++++++++++++++++++- 4 files changed, 57 insertions(+), 4 deletions(-) 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"); + } } }