From 90b6d542304feefa97181597a67ce549570019fa Mon Sep 17 00:00:00 2001 From: Isaiah Clifford Opoku Date: Fri, 4 Oct 2024 12:22:27 +0000 Subject: [PATCH] Add country flag to Home.razor and enhance CountryService --- .../Components/Pages/Home.razor | 12 ++++++++++++ .../Components/Services/CountryService.cs | 7 ++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/sample/CountryData.Sample.Blazor/Components/Pages/Home.razor b/sample/CountryData.Sample.Blazor/Components/Pages/Home.razor index 66cb6ca..c2f4468 100644 --- a/sample/CountryData.Sample.Blazor/Components/Pages/Home.razor +++ b/sample/CountryData.Sample.Blazor/Components/Pages/Home.razor @@ -18,6 +18,7 @@ else Name + Flag Country Short Code Phone Code @@ -27,6 +28,7 @@ else { @country.CountryName + @GrtCountryFlag(country.CountryShortCode) @country.CountryShortCode @country.PhoneCode @@ -48,4 +50,14 @@ else { countries = await CountryService.GetCountries(); } + + + + // getting counry flag + + public string GrtCountryFlag(string countryShortCode) + { + return CountryService.GetCountryFlag(countryShortCode); + } + } diff --git a/sample/CountryData.Sample.Blazor/Components/Services/CountryService.cs b/sample/CountryData.Sample.Blazor/Components/Services/CountryService.cs index 07ff3bd..9cd1da3 100644 --- a/sample/CountryData.Sample.Blazor/Components/Services/CountryService.cs +++ b/sample/CountryData.Sample.Blazor/Components/Services/CountryService.cs @@ -25,16 +25,17 @@ public CountryService(CountryHelper helper) /// The country code. /// The country flag as a string. - public Task 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; }