Move all Blazor code to code-behind files.

This commit is contained in:
2020-05-24 22:10:20 +01:00
parent 08204a1f89
commit 737f69d7da
16 changed files with 307 additions and 259 deletions

View File

@@ -101,55 +101,3 @@
<p>@L["There are no companies in the database."]</p>
}
</p>
@code
{
[Parameter]
public int? CountryId { get; set; }
[Parameter]
public string StartingCharacter { get; set; }
List<CompanyViewModel> _companies;
string _countryName;
char? _character;
protected override async Task OnInitializedAsync()
{
_character = null;
if (!string.IsNullOrWhiteSpace(StartingCharacter) &&
StartingCharacter.Length == 1)
{
_character = StartingCharacter[0];
// ToUpper()
if (_character >= 'a' &&
_character <= 'z')
_character -= (char)32;
// Check if not letter or number
if (_character < '0' ||
(_character > '9' && _character < 'A') ||
_character > 'Z')
_character = null;
}
if (_character.HasValue)
_companies = await Service.GetCompaniesByLetterAsync(_character.Value);
if (CountryId.HasValue && _companies is null)
{
_countryName = await Service.GetCountryNameAsync(CountryId.Value);
if (_countryName != null)
{
_companies = await Service.GetCompaniesByCountryAsync(CountryId.Value);
}
else
CountryId = null;
}
_companies ??= await Service.GetAsync();
}
}