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))); }
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))); }
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)); }