public async Task <int> AddStockIndex(StockIndexTicker stockTickerIndex) { var connection = _connectionService.GetConnectionToCommonShard(); var indexId = await _stockIndexTickerData.AddStockIndex(connection, stockTickerIndex); _connectionService.DisposeConnection(connection); return(indexId); }
public async Task <int> AddStockIndex(IDbConnection connection, StockIndexTicker stockIndexTicker) { var parameters = new DynamicParameters(); parameters.Add("ticker", stockIndexTicker.Ticker); parameters.Add("tickerDescription", stockIndexTicker.TickerDescription); connection.Open(); var tickerId = await connection.QueryFirstAsync <int>(insStockIndexTicker, parameters); connection.Close(); return(tickerId); }
public async Task <IActionResult> Post([FromBody] StockIndexTicker stockIndexTicker) { try { var tickerExists = await _stockIndexService.CheckIfStockTickerExists(stockIndexTicker.Ticker); if (!tickerExists) { var tickerId = await _stockIndexService.AddStockIndex(stockIndexTicker); return(Ok(tickerId)); } else { return(BadRequest()); } } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }