public async Task <ServiceResult <DTO.Casting.CasterMetaData> > GetCasterMetaData(Guid userId) { var result = new ServiceResult <DTO.Casting.CasterMetaData>(); var user = await this.alexandriaContext.UserProfiles.Include(up => up.ExternalAccounts) .FirstOrDefaultAsync(up => up.Id == userId); if (user == null) { result.Error = Shared.ErrorKey.UserProfile.UserNotFound; return(result); } var metaData = new DTO.Casting.CasterMetaData(); ExternalAccount account = null; if (user.TryGetExternalAccount(ExternalProvider.Twitch, out account)) { metaData.TwitchChannel = $"https://twitch.tv/{account.Name}"; } result.Succeed(metaData); return(result); }
public bool TryGetExternalAccount(ExternalProvider provider, out ExternalAccount account) { account = this.ExternalAccounts.FirstOrDefault(ea => ea.Provider == provider); return(account != null); }