diff --git a/Marechai/Controllers/CompanyController.cs b/Marechai/Controllers/CompanyController.cs
index 315de144..6b958200 100644
--- a/Marechai/Controllers/CompanyController.cs
+++ b/Marechai/Controllers/CompanyController.cs
@@ -30,7 +30,7 @@
using System.Linq;
using Marechai.Database.Models;
-using Marechai.Models;
+using Marechai.ViewModels;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
diff --git a/Marechai/Marechai.csproj b/Marechai/Marechai.csproj
index 39099e4d..6e1b2575 100644
--- a/Marechai/Marechai.csproj
+++ b/Marechai/Marechai.csproj
@@ -2,7 +2,7 @@
netcoreapp3.1
- 3.0.99.937
+ 3.0.99.944
Canary Islands Computer Museum
Copyright © 2003-2020 Natalia Portillo
Canary Islands Computer Museum Website
@@ -112,9 +112,6 @@
-
- ResXFileCodeGenerator
- NewsService.es.Designer.cs
-
+
\ No newline at end of file
diff --git a/Marechai/Models/CompanyViewModel.cs b/Marechai/Models/CompanyViewModel.cs
deleted file mode 100644
index d3ce7eab..00000000
--- a/Marechai/Models/CompanyViewModel.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System;
-
-namespace Marechai.Models
-{
- public class CompanyViewModel
- {
- public int Id;
- public Guid? LastLogo;
- public string Name;
- }
-}
\ No newline at end of file
diff --git a/Marechai/Models/ErrorViewModel.cs b/Marechai/Models/ErrorViewModel.cs
deleted file mode 100644
index 4c912c29..00000000
--- a/Marechai/Models/ErrorViewModel.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-/******************************************************************************
-// MARECHAI: Master repository of computing history artifacts information
-// ----------------------------------------------------------------------------
-//
-// Filename : ErrorViewModel.cs
-// Author(s) : Natalia Portillo
-//
-// --[ Description ] ----------------------------------------------------------
-//
-// Error view model
-//
-// --[ 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
-*******************************************************************************/
-
-namespace Marechai.Models
-{
- public class ErrorViewModel
- {
- public string RequestId { get; set; }
-
- public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
- }
-}
\ No newline at end of file
diff --git a/Marechai/Views/Company/Index.cshtml b/Marechai/Pages/Companies/Index.razor
similarity index 71%
rename from Marechai/Views/Company/Index.cshtml
rename to Marechai/Pages/Companies/Index.razor
index 02b7b5b2..b479dcab 100644
--- a/Marechai/Views/Company/Index.cshtml
+++ b/Marechai/Pages/Companies/Index.razor
@@ -1,9 +1,9 @@
-@{
- /******************************************************************************
+@{
+/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
-// Filename : Index.cshtml
+// Filename : Index.razor
// Author(s) : Natalia Portillo
//
// --[ Description ] ----------------------------------------------------------
@@ -28,22 +28,31 @@
// ----------------------------------------------------------------------------
// Copyright © 2003-2020 Natalia Portillo
*******************************************************************************/
-
- ViewData["Title"] = "Companies";
}
-@using System.IO
-@model IEnumerable
+
+@page "/companies"
+@inherits OwningComponentBase
+@inject IStringLocalizer L
+@inject IWebHostEnvironment Host
+
+@if (_companies is null)
+{
+ @L["Loading..."]
+
+ return;
+}
+
- @if (Model.Any())
+ @if (_companies.Any())
{
- @Model.Count() companies found in the database.
+ @string.Format(L["{0} companies found in the database."], _companies.Count())
- @foreach (var company in Model)
+ @foreach (var company in _companies)
{
-
+
@if (company.LastLogo != null &&
- File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", company.LastLogo + ".svg")))
+ File.Exists(Path.Combine(Host.WebRootPath, "assets/logos", company.LastLogo + ".svg")))
{
@@ -52,7 +61,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
@@ -65,4 +74,13 @@
{
There are no companies in the database.
}
-
\ No newline at end of file
+
+
+@code
+{
+ List _companies;
+ protected override async Task OnInitializedAsync()
+ {
+ _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
new file mode 100644
index 00000000..bd11c6b1
--- /dev/null
+++ b/Marechai/Resources/Services/CompaniesService.es.resx
@@ -0,0 +1,129 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Cargando...
+ Message that appears while data is being loaded from database
+
+
+ {0} compañías en la base de datos.
+ How many companies are in the database, {0} is a number
+
+
\ No newline at end of file
diff --git a/Marechai/Resources/Shared/NavMenu.es.resx b/Marechai/Resources/Shared/NavMenu.es.resx
index 4bbf9e18..8d4e36d5 100644
--- a/Marechai/Resources/Shared/NavMenu.es.resx
+++ b/Marechai/Resources/Shared/NavMenu.es.resx
@@ -146,4 +146,8 @@
Contacto
Contact
+
+ Compañías
+ Companies
+
\ No newline at end of file
diff --git a/Marechai/Services/CompaniesService.cs b/Marechai/Services/CompaniesService.cs
new file mode 100644
index 00000000..84368d6b
--- /dev/null
+++ b/Marechai/Services/CompaniesService.cs
@@ -0,0 +1,63 @@
+/******************************************************************************
+// MARECHAI: Master repository of computing history artifacts information
+// ----------------------------------------------------------------------------
+//
+// Filename : CompaniesService.cs
+// Author(s) : Natalia Portillo
+//
+// --[ Description ] ----------------------------------------------------------
+//
+// Companies service
+//
+// --[ 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
+*******************************************************************************/
+
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Marechai.Database.Models;
+using Marechai.ViewModels;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Localization;
+
+namespace Marechai.Services
+{
+ public class CompaniesService
+ {
+ readonly MarechaiContext _context;
+ readonly IStringLocalizer _l;
+
+ public CompaniesService(MarechaiContext context, IStringLocalizer localizer)
+ {
+ _context = context;
+ _l = localizer;
+ }
+
+ public Task> GetCompaniesAsync() => _context.
+ Companies.Include(c => c.Logos).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/Services/Register.cs b/Marechai/Services/Register.cs
index d929b798..99fafc3a 100644
--- a/Marechai/Services/Register.cs
+++ b/Marechai/Services/Register.cs
@@ -42,6 +42,7 @@ namespace Marechai.Services
// TODO: Use reflection
services.AddScoped();
+ services.AddScoped();
}
}
}
\ No newline at end of file
diff --git a/Marechai/Shared/NavMenu.razor b/Marechai/Shared/NavMenu.razor
index bbf9797f..acc1a9c9 100644
--- a/Marechai/Shared/NavMenu.razor
+++ b/Marechai/Shared/NavMenu.razor
@@ -14,6 +14,11 @@
@L["News"]
+
+
+ @L["Companies"]
+
+
diff --git a/Marechai/ViewModels/CompanyViewModel.cs b/Marechai/ViewModels/CompanyViewModel.cs
new file mode 100644
index 00000000..5dbec511
--- /dev/null
+++ b/Marechai/ViewModels/CompanyViewModel.cs
@@ -0,0 +1,11 @@
+using System;
+
+namespace Marechai.ViewModels
+{
+ public class CompanyViewModel
+ {
+ public int Id { get; set; }
+ public Guid? LastLogo { get; set; }
+ public string Name { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Marechai/Views/Company/ByCountry.cshtml b/Marechai/Views/Company/ByCountry.cshtml
index db59e3ff..8fb9799f 100644
--- a/Marechai/Views/Company/ByCountry.cshtml
+++ b/Marechai/Views/Company/ByCountry.cshtml
@@ -32,7 +32,7 @@
ViewData["Title"] = "Companies";
}
@using System.IO
-@model IEnumerable
+@model IEnumerable
@if (ViewBag.Iso3166 != null)
{
diff --git a/Marechai/Views/Company/ByLetter.cshtml b/Marechai/Views/Company/ByLetter.cshtml
index 16525837..5fe72088 100644
--- a/Marechai/Views/Company/ByLetter.cshtml
+++ b/Marechai/Views/Company/ByLetter.cshtml
@@ -32,7 +32,7 @@
ViewData["Title"] = "Companies";
}
@using System.IO
-@model IEnumerable
+@model IEnumerable
Search results:
@if (ViewBag.Letter != '\0')
diff --git a/Marechai/_Imports.razor b/Marechai/_Imports.razor
index 282d83dd..97e5eb6c 100644
--- a/Marechai/_Imports.razor
+++ b/Marechai/_Imports.razor
@@ -10,3 +10,5 @@
@using Marechai.Services
@using Marechai.ViewModels
@using Microsoft.Extensions.Localization
+@using System.IO
+@using Microsoft.AspNetCore.Hosting