private bool ServerInitToConnectionRepo()
        {
            ApiResult serverResult = _server.InitClient(GetUser().BitcoinPrivateKey);

            if (serverResult != null)
            {
                _connection = _connectionRepo.GetConnection();
                if (_connection == null)
                {
                    _connection = new Connection
                    {
                        LastConnected   = DateTime.UtcNow,
                        NeedShowBrowser = true
                    };

                    _connection = _connectionRepo.Create(_connection);
                }
                else
                {
                    _connection.LastConnected = DateTime.UtcNow;
                    _connectionRepo.Update(_connection);
                }

                _context.SaveChanges();
                return(true);
            }

            return(false);
        }
        public IActionResult Post([FromBody] CreateConnectionViewModel model)
        {
            var provider = _providers.FirstOrDefault(p => p.Id == model.ProviderId);

            if (provider == null)
            {
                return(NotFound("The requested provider is not found."));
            }
            try
            {
                var result = _connectionRepository.Create <ConnectionModel>(new
                {
                    model.Name,
                    model.Description,
                    model.ProviderId
                });

                _connectionRepository.LinkOptions(result, model.Options);

                _transaction.Commit();
                return(Ok(result));
            }
            catch
            {
                _transaction.Rollback();
                throw;
            }
        }