public async Task <ResultData <RetroGame> > CreateRetroGameAsync(string name, string template, int teamId) { if (string.IsNullOrEmpty(name)) { return(new ResultData <RetroGame>(InvalidRetroGameNameMessage, false)); } if (string.IsNullOrEmpty(template)) { return(new ResultData <RetroGame>(InvalidRetroGameTemplateMessage, false)); } if (!_teamsRepository.TeamExists(teamId)) { string errorMessage = string.Format(TeamDoesntExistMessage, teamId); return(new ResultData <RetroGame>(errorMessage, false)); } RetroGame game = await _retroGameRepository.CreateRetroGameAsync(name, template, teamId); if (game == null) { string errorMessage = string.Format(TeamHasGameWithSameNameMessage, name); return(new ResultData <RetroGame>(errorMessage, false)); } string message = string.Format(RetroGameCreationSuccessMessage, game.Name); return(new ResultData <RetroGame>(message, true, game)); }
public async Task <ResultData <int> > GetDefaultTeamAsync(string userId) { if (string.IsNullOrEmpty(userId)) { return(new ResultData <int>(OwnerIdNullMessage, false)); } int defaultTeamId = await _teamRepository.GetDefaultTeamAsync(userId); if (!_teamRepository.TeamExists(defaultTeamId)) { defaultTeamId = 0; } string successMessage = string.Format(GetDefaultTeamSuccessMessage, userId); return(new ResultData <int>(successMessage, true, defaultTeamId)); }