public async Task <string> GetUserFullName(string emailAddress) { var route = $"{Gravatar.GetHash(emailAddress)}.json"; var response = await _httpClient.GetAsync(route); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); var profile = JsonConvert.DeserializeObject <GravatarProfile>(content); return(profile?.Entry?.FirstOrDefault()?.Name.Formatted); } else { return(null); } }
public async Task <GravatarProfile> GetGravatarProfile(string email) { GravatarProfile result; var emailHash = Gravatar.GetHash(email); if (!_profileCache.TryGetValue(emailHash, out result)) { result = await _gravatarClient.GetGravatarProfile(emailHash); _profileCache.Set(emailHash, result, new MemoryCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(CacheDurationHours), }); } return(result); }