/// <summary>
        /// Converts DTO account to account.
        /// </summary>
        /// <param name="dto">DTO account to convert.</param>
        /// <returns>Account.</returns>
        public static Account ToAccount(this AccountDTO dto)
        {
            if (dto == null)
            {
                throw new ArgumentNullException(nameof(dto));
            }

            BonusSystem bonusSystem = null;

            if (dto.BonusSystemType == typeof(BaseBonusSystem).ToString())
            {
                bonusSystem = new BaseBonusSystem();
            }
            else if (dto.BonusSystemType == typeof(GoldBonusSystem).ToString())
            {
                bonusSystem = new GoldBonusSystem();
            }
            else if (dto.BonusSystemType == typeof(GoldBonusSystem).ToString())
            {
                bonusSystem = new PlatinumBonusSystem();
            }
            else
            {
                throw new InvalidCastException("Can't cast AccountDTO to Account.");
            }

            Account account = null;

            if (dto.AccountType == typeof(DefaultAccount).ToString())
            {
                account = new DefaultAccount(dto.Id, bonusSystem, dto.IsClosed);
            }
            else if (dto.AccountType == typeof(CashbackAccount).ToString())
            {
                account = new CashbackAccount(dto.Id, bonusSystem, dto.Cashback, dto.IsClosed);
                ((CashbackAccount)account).CashbackPercent = dto.CashbackPercent;
            }
            else
            {
                throw new InvalidCastException("Can't cast AccountDTO to Account.");
            }

            account.FirstName = dto.FirstName;
            account.LastName  = dto.LastName;
            account.Balance   = dto.Balance;

            return(account);
        }
        /// <inheritdoc/>
        public int CreateAccount(AccountType accountType, BonusSystemType bonusSystemType)
        {
            BonusSystem bonusSystem;

            switch (bonusSystemType)
            {
            case BonusSystemType.Base:
                bonusSystem = new BaseBonusSystem();
                break;

            case BonusSystemType.Gold:
                bonusSystem = new GoldBonusSystem();
                break;

            case BonusSystemType.Platinum:
                bonusSystem = new PlatinumBonusSystem();
                break;

            default:
                throw new InvalidOperationException("Unregistered type of bonus system.");
            }

            int     id = this.CreateId();
            Account account;

            switch (accountType)
            {
            case AccountType.DefaultAccount:
                account = new DefaultAccount(id, bonusSystem);
                break;

            case AccountType.CashbackAccount:
                account = new CashbackAccount(id, bonusSystem, 0);
                break;

            default:
                throw new InvalidOperationException("Unregistered type of account.");
            }

            this.accounts.Add(account.Id, account);
            return(account.Id);
        }