diff --git a/cicm_web/Controllers/ComputerController.cs b/cicm_web/Controllers/ComputerController.cs
index 5ea14579..23025c4b 100644
--- a/cicm_web/Controllers/ComputerController.cs
+++ b/cicm_web/Controllers/ComputerController.cs
@@ -34,5 +34,12 @@ namespace cicm_web.Controllers
return View(computers);
}
+
+ public IActionResult ByYear(int id)
+ {
+ ViewBag.Year = id;
+
+ return View(ComputerMini.GetItemsFromYear(id));
+ }
}
}
\ No newline at end of file
diff --git a/cicm_web/Models/Computer.cs b/cicm_web/Models/Computer.cs
index 64069aeb..8cc8e569 100644
--- a/cicm_web/Models/Computer.cs
+++ b/cicm_web/Models/Computer.cs
@@ -182,9 +182,22 @@ namespace cicm_web.Models
return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Model).ToArray();
}
+ public static ComputerMini[] GetItemsFromYear(int year)
+ {
+ List dbItems = null;
+ bool? result = Program.Database?.Operations.GetComputers(out dbItems);
+ if(result == null || result.Value == false || dbItems == null) return null;
+
+ List items = new List();
+ foreach(Cicm.Database.Schemas.Computer dbItem in dbItems)
+ if(dbItem.Year == year)
+ items.Add(TransformItem(dbItem));
+
+ return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Model).ToArray();
+ }
+
static ComputerMini TransformItem(Cicm.Database.Schemas.Computer dbItem)
{
- System.Console.WriteLine("Transforming item");
return new ComputerMini {Company = Company.GetItem(dbItem.Company), Id = dbItem.Id, Model = dbItem.Model};
}
}
diff --git a/cicm_web/Views/Computer/ByYear.cshtml b/cicm_web/Views/Computer/ByYear.cshtml
new file mode 100644
index 00000000..63cfdb80
--- /dev/null
+++ b/cicm_web/Views/Computer/ByYear.cshtml
@@ -0,0 +1,54 @@
+@{
+/******************************************************************************
+// Canary Islands Computer Museum Website
+// ----------------------------------------------------------------------------
+//
+// Filename : ByLetter.cshtml
+// Author(s) : Natalia Portillo
+//
+// --[ Description ] ----------------------------------------------------------
+//
+// Lists computers by letter (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-2018 Natalia Portillo
+*******************************************************************************/
+
+ ViewData["Title"] = "Computers";
+}
+
+@model IEnumerable
+
+Search results:
+
+ @ViewBag.Year
+
+ @if(Model.Any())
+ {
+
@Model.Count() computers found in the database.
+ @foreach(ComputerMini computer in @Model)
+ {
+ @computer.Company.Name @computer.Model
+ }
+
+ }
+ else
+ {
+ There are no computers found in the database released this year.
+ }
+
diff --git a/cicm_web/cicm_web.csproj b/cicm_web/cicm_web.csproj
index e035936c..1c7f4829 100644
--- a/cicm_web/cicm_web.csproj
+++ b/cicm_web/cicm_web.csproj
@@ -2,7 +2,7 @@
netcoreapp2.0
- 3.0.99.67
+ 3.0.99.68
Canary Islands Computer Museum
Copyright © 2003-2018 Natalia Portillo
Canary Islands Computer Museum Website