Exemplo n.º 1
0
        public IActionResult MarkDead([FromBody] Celebrity celebrity)
        {
            try
            {
                var celebrityRepository = new CelebrityRepository();
                var appInfoRepository   = new AppInfoRepository();
                var numLumensToPay      = appInfoRepository.GetAppInfo().LumensRequired;
                var winnersToBePaid     = celebrityRepository.MarkDead(celebrity).ToList();

                if (!winnersToBePaid.Any())
                {
                    return(Ok());
                }

                foreach (var address in winnersToBePaid)
                {
                    SendPayment(
                        address,
                        numLumensToPay.ToString(CultureInfo.InvariantCulture),
                        "You won in DeathRaffle!");
                }

                return(Ok());
            }
            catch (Exception e)
            {
                AppSettings.Logger.Error($"Unable to connect to the database at: {AppSettings.Logger}");
                AppSettings.Logger.Error($"The error was: {e.Message}");
                return(StatusCode(500));
            }
        }
Exemplo n.º 2
0
 public IActionResult Get()
 {
     try
     {
         var appInfoRepository = new AppInfoRepository();
         return(Ok(appInfoRepository.GetAppInfo()));
     }
     catch (Exception e)
     {
         AppSettings.Logger.Error("Unable to connect to the database.");
         AppSettings.Logger.Error($"The error was: {e.Message}");
         return(StatusCode(500));
     }
 }
Exemplo n.º 3
0
        public StellarClient()
        {
            _walletRepository  = new WalletsRepository();
            _poolRepository    = new PoolRepository();
            _ticketRepository  = new TicketRepository();
            _appInfoRepository = new AppInfoRepository();

            if (AppSettings.IsProduction)
            {
                AppSettings.Logger.Information("Connected to the public Stellar network.");
                Network.UsePublicNetwork();
                _server = new Server("https://horizon.stellar.org");
            }
            else
            {
                AppSettings.Logger.Information("Connected to the TEST Stellar network.");
                Network.UseTestNetwork();
                _server = new Server("https://horizon-testnet.stellar.org");
            }

            GetWallet();

            _url = $"https://horizon.stellar.org/accounts/{_keyPair.AccountId}/payments";
        }