public async Task<RealTimeStockItem> GetRealTimeStockAsync(StockInfoItem stockItem) { GoogleStockClient client = new GoogleStockClient(); RealTimeStockModel stockData = await client.QueryStockAsync(stockItem.Id); return RealTimeStockItem.ConvertFrom(stockData); }
private async void AddStock_Click() { StockInfoItem stockItem = null; try { string localStockNum = StockNumber; stockItem = _localStockService.Get(localStockNum); var stockData = await _queryService.GetMultipleRealTimeStockAsync(new List <StockInfoItem> { stockItem }); // check if the stock is exist in the list if (stockData.Count > 0) { StockListViewModel.AddStock(stockData); } stockItem.Order = _favoriteStockService.GetLastOrder(0); _favoriteStockService.Add(stockItem); } catch (FavoriteStockExistException e) { Dialog.ShowError(string.Format("目前 {0}({1}) 已經存在於清單內!", stockItem.Name, stockItem.Id)); } catch (Exception e) { Dialog.ShowError(e.Message + (e.InnerException == null ? string.Empty : " (detail : " + e.InnerException + ")")); } StockNumber = string.Empty; }
public void Add(StockInfoItem item) { var stockEntity = new StockEntity { Id = item.Id, Name = item.Name, MarketType = item.MarketType, Category = item.Category }; using (StockUnitOfWork db = new StockUnitOfWork()) { db.Stock.Add(stockEntity); db.SaveChanges(); } }
public void Add(StockInfoItem item) { using (StockUnitOfWork db = new StockUnitOfWork()) { // check if the stock is exist in favorite table if (db.FavoriteStock.GetById(item.Id) != null) throw new FavoriteStockExistException(item.Id, item.Name); StockEntity stockEntity = db.Stock.GetById(item.Id); var favoriteStockEntity = new FavoriteStockEntity { Id = item.Id, ParentStock = stockEntity, // TODO : it must rewrite the category source from category table //CustomCategory = item.Category, Order = item.Order }; db.FavoriteStock.Add(favoriteStockEntity); db.SaveChanges(); } }
public async Task<StockChartModel> GetRealTimeTradeChartAsync(StockInfoItem stockItem) { TwseStockClient client = new TwseStockClient(); var resutl = await client.QueryRealTimeTradeChartAsync(stockItem.Convert()); return resutl; }