From 27f30cc305fa3a6919c508dbb101c2247e9ec0a4 Mon Sep 17 00:00:00 2001
From: Natalia Portillo
Date: Fri, 20 Apr 2018 19:21:29 +0100
Subject: [PATCH] Add Index and ByCountry to Company.
---
cicm_web/Controllers/CompanyController.cs | 20 +++++
cicm_web/Views/Company/ByCountry.cshtml | 99 +++++++++++++++++++++++
cicm_web/Views/Company/Index.cshtml | 75 +++++++++++++++++
3 files changed, 194 insertions(+)
create mode 100644 cicm_web/Views/Company/ByCountry.cshtml
create mode 100644 cicm_web/Views/Company/Index.cshtml
diff --git a/cicm_web/Controllers/CompanyController.cs b/cicm_web/Controllers/CompanyController.cs
index 9717f217..e3cb96bf 100644
--- a/cicm_web/Controllers/CompanyController.cs
+++ b/cicm_web/Controllers/CompanyController.cs
@@ -29,8 +29,10 @@
*******************************************************************************/
using cicm_web.Models;
+using Cicm.Database.Schemas;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
+using Company = cicm_web.Models.Company;
namespace cicm_web.Controllers
{
@@ -65,5 +67,23 @@ namespace cicm_web.Controllers
ViewBag.WebRootPath = hostingEnvironment.WebRootPath;
return View(company);
}
+
+ public IActionResult ByCountry(int id)
+ {
+ Iso3166 iso3166 = Program.Database.Operations.GetIso3166(id);
+
+ ViewBag.Iso3166 = iso3166;
+
+ Company[] companies = iso3166 == null ? Company.GetAllItems() : Company.GetItemsByCountry(id);
+
+ ViewBag.WebRootPath = hostingEnvironment.WebRootPath;
+ return View(companies);
+ }
+
+ public IActionResult Index()
+ {
+ ViewBag.WebRootPath = hostingEnvironment.WebRootPath;
+ return View(Company.GetAllItems());
+ }
}
}
\ No newline at end of file
diff --git a/cicm_web/Views/Company/ByCountry.cshtml b/cicm_web/Views/Company/ByCountry.cshtml
new file mode 100644
index 00000000..dacee866
--- /dev/null
+++ b/cicm_web/Views/Company/ByCountry.cshtml
@@ -0,0 +1,99 @@
+@{
+ /******************************************************************************
+// Canary Islands Computer Museum Website
+// ----------------------------------------------------------------------------
+//
+// 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-2018 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(Company company in Model)
+ {
+
+ @if(company.LastLogo != null && File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", company.LastLogo.Guid + ".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/cicm_web/Views/Company/Index.cshtml b/cicm_web/Views/Company/Index.cshtml
new file mode 100644
index 00000000..56d5c0c7
--- /dev/null
+++ b/cicm_web/Views/Company/Index.cshtml
@@ -0,0 +1,75 @@
+@{
+ /******************************************************************************
+// Canary Islands Computer Museum Website
+// ----------------------------------------------------------------------------
+//
+// Filename : Index.cshtml
+// Author(s) : Natalia Portillo
+//
+// --[ Description ] ----------------------------------------------------------
+//
+// Lists all companies
+//
+// --[ 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"] = "Companies";
+}
+@using System.IO
+@model IEnumerable
+
+
+ @if(Model.Any())
+ {
+
+ @Model.Count() companies found in the database.
+ @foreach(Company company in Model)
+ {
+
+ @if(company.LastLogo != null && File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", company.LastLogo.Guid + ".svg")))
+ {
+
+
+
+
+
+
+ }
+ @company.Name
+
+
+ }
+
+ }
+ else
+ {
+ There are no companies in the database.
+ }
+
\ No newline at end of file