示例#1
0
        public async Task <IActionResult> GetLatestPrice([FromRoute] string symbol)
        {
            //BUG: The team reports that they get 500 response code sometimes from "/api/share/{symbol}/latest" call.
            //FIX: startup.cs- exception middleware will resolve this
            var item = await _shareService.GetLastPriceAsync(symbol);

            return(Ok(item.Rate));
        }
示例#2
0
        public async Task <IActionResult> GetLatestPrice([FromRoute] string symbol)
        {
            var item = await _shareService.GetLastPriceAsync(symbol);

            if (item == null)
            {
                return(NotFound());
            }
            return(Ok(item.Rate));
        }
示例#3
0
        public async Task <Trade> BuyOrSell(int portfolioId, string symbol, int noOfShares, string action)
        {
            // get the last price
            var price = await _shareService.GetLastPriceAsync(symbol);

            if (price == null)
            {
                return(null);
            }

            var trade = new Trade()
            {
                Action        = action,
                PortfolioId   = portfolioId,
                Symbol        = symbol,
                NoOfShares    = noOfShares,
                ContractPrice = price.Rate * noOfShares
            };

            await EntityRepository.InsertAsync(trade);

            return(trade);
        }