Ejemplo 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));
            }
        }
Ejemplo 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));
     }
 }
Ejemplo n.º 3
0
        private decimal GetMinimumLumensRequired()
        {
            var client  = new RestClient("https://api.coinmarketcap.com/v1/ticker/stellar/?convert=usd");
            var request = new RestRequest(Method.GET);

            try
            {
                var response = client.Execute <List <TickerReponse> >(request).Data.First();

                AppSettings.Logger.Information($"Current XLM Price: {response.PriceUsd}");

                var lumensRequired = 10.00m / decimal.Parse(response.PriceUsd);

                _appInfoRepository.UpdateLumensRequired(lumensRequired);

                return(lumensRequired);
            }
            catch (Exception)
            {
                AppSettings.Logger.Error("Unable to connect to CoinMarketCap API!");
                return(_appInfoRepository.GetAppInfo().LumensRequired);
            }
        }