Consider we have three different database stores which we want to find an Id which is unique in all this three. I mean if we query first data store and we find that id. It's over and there is no need to further attempt, if that Id is in non of this three data stores we return null, I'm new in asynchronous programming, I wanted to know if there is any better implementation for this lines of code? I mean less if/else?
public async Task<WebData> GetDataByIdAsync(GetDataById input)
{
var twitterData = await DataAccess.FindDataById<TwitterData>(input.Id);
WebData result;
if (twitterData == null)
{
var facebookData = await DataAccess.FindDataById<FacebookData>(input.Id);
if facebookData == null)
{
var linkedinData = await DataAccess.FindDataById<LinkedinData>(input.Id);
if linkedinData == null)
{
return null;
}
result = linkedinData
}
else
{
result = facebookData;
}
}
else
{
result = twitterData ;
}
return result;
}