protected override Dictionary <string, decimal> GetAllPrice() { try { Dictionary <string, decimal> dic = new Dictionary <string, decimal>(); Log.Info("START GET ExChangeBase:" + GetExchangeName()); MarketRequestModel list = OkAPi.SendRequestContent <MarketRequestModel> (ApiUrlList.API_Market); Log.Info("End GET ExChangeBase:" + GetExchangeName()); List <Ticker> l = list.tickers.FindAll(S => S.symbol.Contains("usdt")); foreach (var item in l) { dic.Add(item.symbol, item.last); } return(dic); } catch (Exception e) { Alert(e.ToString()); return(null); } }
public async Task <int> CreateMarket(MarketRequestModel marketRequest) { Market market = await this.unitOfWorkManager.Markets.GetSingleAsync(x => x.Name == marketRequest.Name); if (market != null) { throw new IsRegisteredException("market is registered"); } await this.unitOfWorkManager.BeginTransactionAsync(); try { Market newMarket = new Market { Name = marketRequest.Name }; await this.unitOfWorkManager.Markets.AddAsync(newMarket); await this.unitOfWorkManager.CompleteAsync(); this.unitOfWorkManager.CommitTransaction(); return(newMarket.Id); } catch (Exception) { this.unitOfWorkManager.RollbackTransaction(); throw; } }
public async Task ChangeMarket(int id, MarketRequestModel marketRequest) { Market market = await this.unitOfWorkManager.Markets.FindAsync(id); if (market == null) { throw new IsNotRegisteredException("market not found"); } market.Name = marketRequest.Name; market.ChangeDate = DateTime.Now; this.unitOfWorkManager.Markets.Update(market); this.unitOfWorkManager.Complete(); }
protected override Dictionary <string, decimal> GetAllPrice() { try { Dictionary <string, decimal> dic = new Dictionary <string, decimal>(); Log.Info("START GET HuoBiProduct:" + GetExchangeName()); MarketRequestModel list = api.SendRequestContent <MarketRequestModel>(ApiUrlList.API_Market); Log.Info("End GET HuoBiProduct:" + GetExchangeName()); List <Datum> l = list.data.FindAll(S => S.symbol.Contains("usdt")); foreach (var item in l) { if (item.symbol.Length == 7) { item.symbol = item.symbol.Insert(3, "_"); } else if (item.symbol.Length == 8) { item.symbol = item.symbol.Insert(4, "_"); } else { item.symbol = item.symbol.Insert(5, "_"); } item.symbol = item.symbol.ToLower(); dic.Add(item.symbol, item.low); } return(dic); } catch (Exception e) { Alert(e.ToString()); return(null); } }
public async Task <IActionResult> Change(int id, [FromBody] MarketRequestModel request) { await this.marketsService.ChangeMarket(id, request); return(Ok()); }
public async Task <IActionResult> Add([FromBody] MarketRequestModel request) { int Id = await this.marketsService.CreateMarket(request); return(Ok(Id)); }