public override IPerson GetPerson(params ICardType[][] cardTypesList)
        {
            var mockPerson = new MockPerson();

            foreach (var cardTypes in cardTypesList)
            {
                var wallet = WalletFactory.GetWallet(cardTypes);
                mockPerson.Wallets.Add(wallet);
            }

            return(mockPerson);
        }
        /// <summary>
        /// Function returns Wallet stored in database based on id
        /// </summary>
        /// <returns>IWallet object created based on specified type</returns>
        public IWallet GetWallet(Guid id)
        {
            try
            {
                //using var context = new DbEconomyContext();
                var wallet = context.Wallets
                             .Where(w => !w.Deleted)
                             .Where(w => w.Id == id.ToString())
                             .FirstOrDefault();

                return(wallet.Fill(WalletFactory.GetWallet(new Guid(), new Guid(), (WalletTypes)wallet.Type, string.Empty, false, string.Empty, 0)));
            }
            catch (Exception ex)
            {
                log.Error("Cannot get wallet from Db", ex);
                return(null);
            }
        }
        /// <summary>
        /// Function returns all Wallets stored in database
        /// </summary>
        /// <returns>List of IWallet object created based on specified type</returns>
        public List <IWallet> GetWallets()
        {
            try
            {
                ////using var context = new DbEconomyContext();

                var walllets = new List <IWallet>();

                foreach (var w in context.Wallets.Where(w => !w.Deleted))
                {
                    // todo: add RPC save!!!!!!
                    walllets.Add(w.Fill(WalletFactory.GetWallet(new Guid(), new Guid(), (WalletTypes)w.Type, w.Name, true, w.Host, w.Port)));
                }

                return(walllets);
            }
            catch (Exception ex)
            {
                log.Error("Cannot get wallets list from Db", ex);
                return(null);
            }
        }
        public override async Task <string> UpdateWallet(Guid id, Guid ownerid, string walletName, WalletTypes type, string urlBase, int port, IDbConnectorService dbservice)
        {
            //IDbConnectorService dbservice = new DbConnectorService();

            if (EconomyMainContext.Wallets.TryGetValue(id.ToString(), out var wallet))
            {
                wallet.Name = walletName;
                if (ownerid != Guid.Empty)
                {
                    wallet.Owner = ownerid;
                }
                wallet.Type           = type;
                wallet.BaseURL        = urlBase;
                wallet.ConnectionPort = port;
                Console.WriteLine($"New wallet connection address: {wallet.ConnectionAddress}");

                if (EconomyMainContext.WorkWithDb)
                {
                    if (!dbservice.SaveWallet(wallet))
                    {
                        Console.WriteLine("Cannot save Node to the db!");
                        return("Cannot save Node to the db!");
                    }
                }

                return("OK");
            }
            else
            {
                if (string.IsNullOrEmpty(id.ToString()))
                {
                    id = Guid.NewGuid();
                }

                if (string.IsNullOrEmpty(ownerid.ToString()))
                {
                    ownerid = Guid.NewGuid();
                }

                var wall = WalletFactory.GetWallet(id, ownerid, type, walletName, EconomyMainContext.WorkWithQTRPC, urlBase, port);

                if (wall != null)
                {
                    wall.NewTransaction += Wall_NewTransaction;
                    wall.NewConfirmedTransactionDetailsReceived += WalletHandler_NewTransactionDetailsReceived;

                    EconomyMainContext.Wallets.Add(wall.Id.ToString(), wall);

                    if (EconomyMainContext.WorkWithDb)
                    {
                        if (!dbservice.SaveWallet(wall))
                        {
                            log.Error("Cannot save wallet to the Db!");
                            return("Cannot save wallet to the Db!");
                        }
                    }
                }

                return("OK");
            }
        }