コード例 #1
0
        public async Task <AthleteViewModel> GetOrCreateAthlete(StravaTokenSet tokenSet, string slackUserId, int athleteIdentifier, string name)
        {
            var existingAthlete = await _athleteRepository.GetAthlete(athleteIdentifier);

            if (existingAthlete == null)
            {
                tokenSet = await EnsureValidTokens(tokenSet, athleteIdentifier);

                return(await CreateAthlete(tokenSet, slackUserId, athleteIdentifier, name));
            }
            else
            {
                tokenSet = await EnsureValidTokens(tokenSet, athleteIdentifier);

                return(await GetAthlete(tokenSet, slackUserId, athleteIdentifier, name));
            }
        }