Exemplo n.º 1
0
        public async Task <IActionResult> Post([FromBody] TradeModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _tradeService.BuyOrSell(model.PortfolioId, model.Symbol, model.NoOfShares, model.Action);

            return(Created($"Trade/{result.PortfolioId}", Map(result)));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Post([FromBody] TradeModel model)
        {
            //BUG: The team found trade records in the database with an unexpected value in the action column
            //FIXED: in the model validation
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _tradeService.BuyOrSell(model.PortfolioId, model.Symbol, model.NoOfShares, model.Action);

            return(Created($"Trade/{result.PortfolioId}", Map(result)));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Post([FromBody] TradeModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (model.Action != "BUY" && model.Action != "SELL")
            {
                return(BadRequest());
            }
            await _tradeService.BuyOrSell(model.PortfolioId, model.Symbol, model.NoOfShares, model.Action);

            return(Created($"Trade/{model.PortfolioId}", model));
        }