예제 #1
0
        async Task <Data.Model.TwitterUser> GetUser(long userId)
        {
            Data.Model.TwitterUser user = null;
            var existingUser            = await _twitterRepository.GetUserFrom(userId);

            if (existingUser == null)
            {
                var userFromApi = _twitterService.GetUserProfileFor(new GetUserProfileForOptions {
                    UserId = userId
                });
                user = new Data.Model.TwitterUser
                {
                    TwitterId       = userId,
                    TwitterUsername = userFromApi.ScreenName
                };

                await _twitterRepository.AddAsync(user);
            }
            else
            {
                user = existingUser;
            }

            return(user);
        }