diff --git a/Marechai/Controllers/CompanyController.cs b/Marechai/Controllers/CompanyController.cs
index f76fa79f..2e8c38a4 100644
--- a/Marechai/Controllers/CompanyController.cs
+++ b/Marechai/Controllers/CompanyController.cs
@@ -75,23 +75,6 @@ namespace Marechai.Controllers
}).ToList());
}
- public IActionResult ByCountry(short id)
- {
- ViewBag.Iso3166 = _context.Iso31661Numeric.FirstOrDefault(i => i.Id == id);
-
- if(ViewBag.Iso3166 is null)
- RedirectToAction(nameof(Index));
-
- ViewBag.WebRootPath = hostingEnvironment.WebRootPath;
-
- return View(_context.Companies.Include(c => c.Logos).Where(c => c.CountryId == id).OrderBy(c => c.Name).
- Select(c => new CompanyViewModel
- {
- Id = c.Id, LastLogo = c.Logos.OrderByDescending(l => l.Year).FirstOrDefault().Guid,
- Name = c.Name
- }).ToList());
- }
-
public IActionResult Index()
{
ViewBag.WebRootPath = hostingEnvironment.WebRootPath;
diff --git a/Marechai/Marechai.csproj b/Marechai/Marechai.csproj
index c7d3387c..fe95f344 100644
--- a/Marechai/Marechai.csproj
+++ b/Marechai/Marechai.csproj
@@ -2,7 +2,7 @@
netcoreapp3.1
- 3.0.99.951
+ 3.0.99.954
Canary Islands Computer Museum
Copyright © 2003-2020 Natalia Portillo
Canary Islands Computer Museum Website
diff --git a/Marechai/Pages/Companies/Index.razor b/Marechai/Pages/Companies/Index.razor
index b479dcab..e938df95 100644
--- a/Marechai/Pages/Companies/Index.razor
+++ b/Marechai/Pages/Companies/Index.razor
@@ -8,7 +8,7 @@
//
// --[ Description ] ----------------------------------------------------------
//
-// Lists all companies
+// Lists all companies or companies by country
//
// --[ License ] --------------------------------------------------------------
//
@@ -31,6 +31,7 @@
}
@page "/companies"
+@page "/companies/country/{CountryId:int}"
@inherits OwningComponentBase
@inject IStringLocalizer L
@inject IWebHostEnvironment Host
@@ -43,6 +44,24 @@
}
+ @if (CountryId.HasValue)
+ {
+ @string.Format(L["Companies founded in {0}."], L[_countryName])
+ if (File.Exists(System.IO.Path.Combine(Host.WebRootPath, "assets/flags/countries", CountryId + ".svg")))
+ {
+
+
+
+
+
+ }
+
+ }
+
@if (_companies.Any())
{
@@ -72,15 +91,32 @@
}
else
{
-
There are no companies in the database.
+ @L["There are no companies in the database."]
}
@code
{
+ [Parameter]
+ public int? CountryId{get;set;}
+
List _companies;
+ string _countryName;
+
protected override async Task OnInitializedAsync()
{
- _companies = await Service.GetCompaniesAsync();
+ if (CountryId.HasValue)
+ {
+ _countryName = await Service.GetCountryNameAsync(CountryId.Value);
+
+ if (_countryName != null)
+ {
+ _companies = await Service.GetCompaniesByCountryAsync(CountryId.Value);
+ }
+ else
+ CountryId = null;
+ }
+
+ _companies ??= await Service.GetCompaniesAsync();
}
}
\ No newline at end of file
diff --git a/Marechai/Resources/Services/CompaniesService.es.resx b/Marechai/Resources/Services/CompaniesService.es.resx
index 72468aa2..8e94a0f4 100644
--- a/Marechai/Resources/Services/CompaniesService.es.resx
+++ b/Marechai/Resources/Services/CompaniesService.es.resx
@@ -242,4 +242,12 @@
<red>Ninguna</red> videoconsola conocida.
There are no known computers. Do not translate <red> neither </red> and keep negation in between.
+
+ No hay compañías en la base de datos.
+ No companies in the database
+
+
+ Compañías fundadas en {0}.
+ Companies founded in, {0} country name
+
\ No newline at end of file
diff --git a/Marechai/Services/CompaniesService.cs b/Marechai/Services/CompaniesService.cs
index 2a08ec42..2a606fd5 100644
--- a/Marechai/Services/CompaniesService.cs
+++ b/Marechai/Services/CompaniesService.cs
@@ -80,5 +80,28 @@ namespace Marechai.Services
{
Id = c.Id, Name = c.Name
}).FirstOrDefaultAsync(c => c.Id == id);
+
+ public async Task GetCountryNameAsync(int id) =>
+ (await _context.Iso31661Numeric.FirstOrDefaultAsync(c => c.Id == id))?.Name;
+
+ public Task> GetCompaniesByCountryAsync(int countryId) => _context.
+ Companies.
+ Include(c => c.Logos).
+ Where(c => c.CountryId ==
+ countryId).
+ OrderBy(c => c.Name).
+ Select(c =>
+ new CompanyViewModel
+ {
+ Id = c.Id,
+ LastLogo = c.
+ Logos.
+ OrderByDescending(l =>
+ l.
+ Year).
+ FirstOrDefault().
+ Guid,
+ Name = c.Name
+ }).ToListAsync();
}
}
\ No newline at end of file
diff --git a/Marechai/Views/Company/ByCountry.cshtml b/Marechai/Views/Company/ByCountry.cshtml
deleted file mode 100644
index 8fb9799f..00000000
--- a/Marechai/Views/Company/ByCountry.cshtml
+++ /dev/null
@@ -1,86 +0,0 @@
-@{
- /******************************************************************************
-// MARECHAI: Master repository of computing history artifacts information
-// ----------------------------------------------------------------------------
-//
-// Filename : ByCountry.cshtml
-// Author(s) : Natalia Portillo
-//
-// --[ Description ] ----------------------------------------------------------
-//
-// Lists companies by country (or all)
-//
-// --[ License ] --------------------------------------------------------------
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as
-// published by the Free Software Foundation, either version 3 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-//
-// ----------------------------------------------------------------------------
-// Copyright © 2003-2020 Natalia Portillo
-*******************************************************************************/
-
- ViewData["Title"] = "Companies";
-}
-@using System.IO
-@model IEnumerable
-
- @if (ViewBag.Iso3166 != null)
- {
- Companies founded in @ViewBag.Iso3166.Name
- if (File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/flags/countries", ViewBag.Iso3166.Id + ".svg")))
- {
-
-
-
-
-
- }
-
- }
-
- @if (Model.Any())
- {
-
- @Model.Count() companies found in the database.
-
- @foreach (var company in Model)
- {
-
- @if (company.LastLogo != null &&
- File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", company.LastLogo + ".svg")))
- {
-
-
-
-
-
- }
- @company.Name
-
-
- }
-
- }
- else
- {
- There are no companies found in the database founded in the requested country.
- }
-
\ No newline at end of file
diff --git a/Marechai/Views/Company/ByLetter.cshtml b/Marechai/Views/Company/ByLetter.cshtml
index 5fe72088..2675e0df 100644
--- a/Marechai/Views/Company/ByLetter.cshtml
+++ b/Marechai/Views/Company/ByLetter.cshtml
@@ -59,7 +59,7 @@
/assets/logos/thumbs/webp/3x/@(company.LastLogo).webp 3x">
+ /assets/logos/thumbs/png/3x/@(company.LastLogo).png 3x" src="/assets/logos/thumbs/png/1x@(company.LastLogo).png" alt="" height="auto" width="auto" style="max-height: 32px; max-width: 128px" />
}
@company.Name
diff --git a/Marechai/Views/Machine/View.cshtml b/Marechai/Views/Machine/View.cshtml
index 35002676..feaa63a5 100644
--- a/Marechai/Views/Machine/View.cshtml
+++ b/Marechai/Views/Machine/View.cshtml
@@ -45,7 +45,7 @@
/assets/logos/webp/3x/@(Model.Company.LastLogo.Guid).webp 3x">
+ /assets/logos/png/3x/@(Model.Company.LastLogo.Guid).png 3x" src="/assets/logos/png/1x/@(Model.Company.LastLogo.Guid).png" alt="" height="auto" width="auto" style="max-height: 256px; max-width: 256px" />
}