public IActionResult CreateMatchOdds(int matchId, [FromBody] MatchOddsForCreationDto matchOdds) { if (!_matchInfoRepository.MatchExists(matchId)) { return(NotFound()); } var finalMatchOdd = _mapper.Map <Entities.MatchOdds>(matchOdds); _matchInfoRepository.AddMatchOddsForMatch(matchId, finalMatchOdd); _matchInfoRepository.Save(); var createdMatchOddsToReturn = _mapper.Map <Models.MatchOddsDto>(finalMatchOdd); return(CreatedAtRoute( "GetMatchOdds", new { matchId, id = createdMatchOddsToReturn.MatchOddId }, createdMatchOddsToReturn)); }
public IActionResult CreateMatch([FromBody] MatchForCreationDto match) { var finalMatchOdd = _mapper.Map <Entities.Match>(match); _matchInfoRepository.AddMatch(finalMatchOdd); _matchInfoRepository.Save(); var createdMatchToReturn = _mapper.Map <Models.MatchDto>(finalMatchOdd); return(CreatedAtRoute( "GetMatch", new { id = createdMatchToReturn.MatchId }, createdMatchToReturn)); }