コード例 #1
0
        public JsonResult AddExchange([FromBody] AddExchangeRequest addExchangeDraft)
        {
            var exchange = new Exchange
            {
                Rates = addExchangeDraft.Rates
            };

            exchange.SetBalances(_repository.Percentages, addExchangeDraft.Balance);

            return(new JsonResult(_repository.Add(exchange)));
        }
コード例 #2
0
        public async Task <IActionResult> Create(Exchange exchange)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    bool result = await _repo.Add(exchange);

                    if (result)
                    {
                        return(RedirectToAction("Index"));
                    }
                    return(View("Create"));
                }
                catch
                {
                }
            }
            return(RedirectToAction("Error", "Home"));
        }
コード例 #3
0
 public async Task <int> AddExchange(Exchanges exchanges)
 {
     return(await _exchangeRepository.Add(exchanges));
 }
コード例 #4
0
        public async Task <bool> Run(ILogger logger)
        {
            logger.LogInformation("Running repository bootstrapper");

            try
            {
                foreach (var currency in CurrencyFactory.List())
                {
                    await CurrencyRepository.Add(currency);
                }

                foreach (var symbol in SymbolFactory.List())
                {
                    await SymbolRepository.Add(symbol);
                }

                foreach (var group in IntervalFactory.ListGroups())
                {
                    foreach (var ik in IntervalFactory.ListIntervalKeys(group.IntervalGroup))
                    {
                        await IntervalRepository.Add(ik);
                    }
                }

                foreach (var exchange in ExchangeFactory.List())
                {
                    await ExchangeRepository.Add(exchange);

                    var httpClient = exchange.GetHttpClient();

                    foreach (var symbolCode in exchange.Symbol)
                    {
                        var symbol = SymbolFactory.Get(symbolCode);

                        await SymbolRepository.Add(symbol);

                        await ExchangeRepository.AddSymbol(exchange.Name, symbolCode);

                        var tradeFilter = await HistorianRepository.GetTradeFilter(exchange.Name, symbolCode);

                        if (tradeFilter == null)
                        {
                            using (var transaction = await StorageTransactionFactory.Begin())
                            {
                                await HistorianRepository.SetTradeFilter(transaction, exchange.Name, symbolCode, httpClient.InitialTradeFilter);

                                await transaction.Commit();
                            }
                        }
                    }
                }

                foreach (var orderSide in OrderSideFactory.List())
                {
                    await OrderSideRepository.Add(orderSide);
                }

                return(true);
            }
            catch (Exception ex)
            {
                logger.LogCritical(ex, "Unable to run repository bootstrapper");

                return(false);
            }
        }