public async Task AddNewMatchAsync(MatchDTO matchDTO) { if (matchDTO.TeamAName == null || matchDTO.TeamBName == null || matchDTO.Category == null || matchDTO.MatchTime == default(DateTime)) { throw new Exception("All fields must be filled."); } var match = mapper.Map <MatchDTO, Match>(matchDTO); match.GenerateDefaultValues(); if (await repository.GetMatchAsync(match.MatchId) != null) { throw new Exception("Match already exists"); } await repository.AddNewMatchAsync(match); }