Skip to content

Commit 90b6d54

Browse files
committed
Add country flag to Home.razor and enhance CountryService
1 parent 0784053 commit 90b6d54

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

sample/CountryData.Sample.Blazor/Components/Pages/Home.razor

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ else
1818
<thead>
1919
<tr>
2020
<th>Name</th>
21+
<th>Flag</th>
2122
<th>Country Short Code</th>
2223
<th>Phone Code</th>
2324
</tr>
@@ -27,6 +28,7 @@ else
2728
{
2829
<tr>
2930
<td>@country.CountryName</td>
31+
<td>@GrtCountryFlag(country.CountryShortCode)</td>
3032
<td>@country.CountryShortCode</td>
3133
<td>@country.PhoneCode</td>
3234
</tr>
@@ -48,4 +50,14 @@ else
4850
{
4951
countries = await CountryService.GetCountries();
5052
}
53+
54+
55+
56+
// getting counry flag
57+
58+
public string GrtCountryFlag(string countryShortCode)
59+
{
60+
return CountryService.GetCountryFlag(countryShortCode);
61+
}
62+
5163
}

sample/CountryData.Sample.Blazor/Components/Services/CountryService.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@ public CountryService(CountryHelper helper)
2525
/// <param name="countryCode">The country code.</param>
2626
/// <returns>The country flag as a string.</returns>
2727

28-
public Task<string> GetCountryFlag(string countryCode)
28+
public string GetCountryFlag(string countryCode)
2929
{
3030
var countryFlag = _helper.GetCountryEmojiFlag(countryCode);
3131

3232
if (string.IsNullOrEmpty(countryFlag))
3333
{
34-
return Task.FromResult("Country Flag not found");
34+
35+
return "No flag found";
3536
}
3637

37-
return Task.FromResult(countryFlag);
38+
return countryFlag;
3839
}
3940

4041

0 commit comments

Comments
 (0)