Skip to content

Commit

Permalink
Add country flag to Home.razor and enhance CountryService
Browse files Browse the repository at this point in the history
  • Loading branch information
Clifftech123 committed Oct 4, 2024
1 parent 0784053 commit 90b6d54
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 12 additions & 0 deletions sample/CountryData.Sample.Blazor/Components/Pages/Home.razor
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ else
<thead>
<tr>
<th>Name</th>
<th>Flag</th>
<th>Country Short Code</th>
<th>Phone Code</th>
</tr>
Expand All @@ -27,6 +28,7 @@ else
{
<tr>
<td>@country.CountryName</td>
<td>@GrtCountryFlag(country.CountryShortCode)</td>
<td>@country.CountryShortCode</td>
<td>@country.PhoneCode</td>
</tr>
Expand All @@ -48,4 +50,14 @@ else
{
countries = await CountryService.GetCountries();
}



// getting counry flag
public string GrtCountryFlag(string countryShortCode)
{
return CountryService.GetCountryFlag(countryShortCode);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ public CountryService(CountryHelper helper)
/// <param name="countryCode">The country code.</param>
/// <returns>The country flag as a string.</returns>

public Task<string> GetCountryFlag(string countryCode)
public string GetCountryFlag(string countryCode)
{
var countryFlag = _helper.GetCountryEmojiFlag(countryCode);

if (string.IsNullOrEmpty(countryFlag))
{
return Task.FromResult("Country Flag not found");

return "No flag found";
}

return Task.FromResult(countryFlag);
return countryFlag;
}


Expand Down

0 comments on commit 90b6d54

Please sign in to comment.