using BankContracts.Exceptions; using BankContracts.Extensions; using BankContracts.Infrastructure; namespace BankContracts.DataModels; /// /// Дата модель вклада /// /// уникальный Guid индентификатор /// процентная ставка /// стоимость /// срок /// уникальный Guid индентификатор клерка /// валюты вклада public class DepositDataModel(string id, float interestRate, decimal cost, int period, string clerkId, List depositCurrencies) : IValidation { public string Id { get; private set; } = id; public float InterestRate { get; private set; } = interestRate; public decimal Cost { get; private set; } = cost; public int Period { get; private set; } = period; public string ClerkId { get; private set; } = clerkId; public List Currencies { get; private set; } = depositCurrencies; public void Validate() { if (Id.IsEmpty()) { throw new ValidationException("Field Id is null or empty"); } if (!Id.IsGuid()) { throw new ValidationException("The value in the field Id is not a unique identifier"); } if (InterestRate <= 0) { throw new ValidationException("Field InterestRate is less or equal to zero"); } if (Cost <= 0) { throw new ValidationException("Field Cost is less or equal to zero"); } if (Period <= 0) { throw new ValidationException("Field Period is less or equal to zero"); } if (ClerkId.IsEmpty()) { throw new ValidationException("Field ClerkId is null or empty"); } if (!ClerkId.IsGuid()) { throw new ValidationException("The value in the field ClerkId is not a unique identifier"); } if (Currencies is null) { throw new ValidationException("Field Currencies is null"); } } }