public async Task <IActionResult> UpdateMatch(int id, MatchForCreateDto match)
        {
            var matchToUpdate = await matchRepository.GetMatch(id);

            matchToUpdate.TeamA = await teamRepository.GetTeam(match.TeamAId);

            matchToUpdate.TeamB = await teamRepository.GetTeam(match.TeamBId);

            matchToUpdate.Date      = match.Date;
            matchToUpdate.TeamAOdds = match.TeamAOdds;
            matchToUpdate.TeamBOdds = match.TeamBOdds;
            matchToUpdate.DrawOdds  = match.DrawOdds;

            if (await dataContext.Commit())
            {
                return(NoContent());
            }

            throw new Exception($"Updating match {id} failed on save.");
        }
        public async Task <IActionResult> AddMatch(MatchForCreateDto match)
        {
            if (match.TeamAId == match.TeamBId)
            {
                return(BadRequest("You picked the same team twice."));
            }

            if (await teamRepository.Exists(match.TeamAId) && await teamRepository.Exists(match.TeamBId))
            {
                var matchToCreate = mapper.Map <Match>(match);
                matchToCreate.TeamA = await teamRepository.GetTeam(match.TeamAId);

                matchToCreate.TeamB = await teamRepository.GetTeam(match.TeamBId);

                matchRepository.Add(matchToCreate);

                if (await dataContext.Commit())
                {
                    return(CreatedAtRoute("GetMatch", new { id = matchToCreate.Id }, matchToCreate));
                }
            }

            return(BadRequest("Could not add match."));
        }