mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add Index and ByCountry to Company.
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
99
cicm_web/Views/Company/ByCountry.cshtml
Normal file
99
cicm_web/Views/Company/ByCountry.cshtml
Normal file
@@ -0,0 +1,99 @@
|
||||
@{
|
||||
/******************************************************************************
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ByCountry.cshtml
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ 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 <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2003-2018 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
ViewData["Title"] = "Companies";
|
||||
}
|
||||
@using System.IO
|
||||
@model IEnumerable<Company>
|
||||
|
||||
<p align=center>
|
||||
@if(ViewBag.Iso3166 != null)
|
||||
{
|
||||
<b>Companies founded in @ViewBag.Iso3166.Name</b>
|
||||
if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/flags/countries", ViewBag.Iso3166.Id + ".svg")))
|
||||
{
|
||||
<picture>
|
||||
<source type="image/svg+xml"
|
||||
srcset="/assets/flags/countries/@(ViewBag.Iso3166.Id).svg">
|
||||
<source type="image/webp"
|
||||
srcset="/assets/flags/countries/webp/1x/@(ViewBag.Iso3166.Id).webp,
|
||||
/assets/flags/countries/webp/1x/@(ViewBag.Iso3166.Id).webp 2x,
|
||||
/assets/flags/countries/webp/1x/@(ViewBag.Iso3166.Id).webp 3x">
|
||||
<img srcset="/assets/flags/countries/png/1x/@(ViewBag.Iso3166.Id).png,
|
||||
/assets/flags/countries/png/1x/@(ViewBag.Iso3166.Id).png 2x,
|
||||
/assets/flags/countries/png/1x/@(ViewBag.Iso3166.Id).webp 3x"
|
||||
src="/assets/flags/countries/png/1x@(ViewBag.Iso3166.Id).png")
|
||||
alt=""
|
||||
height="32" />
|
||||
</picture>
|
||||
}
|
||||
<br />
|
||||
}
|
||||
|
||||
@if(Model.Any())
|
||||
{
|
||||
<p>
|
||||
@Model.Count() companies found in the database.<br />
|
||||
@foreach(Company company in Model)
|
||||
{
|
||||
<a asp-controller="Company"
|
||||
asp-action="View"
|
||||
asp-route-id="@company.Id">
|
||||
@if(company.LastLogo != null && File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", company.LastLogo.Guid + ".svg")))
|
||||
{
|
||||
<picture>
|
||||
<source type="image/svg+xml"
|
||||
srcset="/assets/logos/@(company.LastLogo.Guid).svg">
|
||||
<source type="image/webp"
|
||||
srcset="/assets/logos/thumbs/webp/1x/@(company.LastLogo.Guid).webp,
|
||||
/assets/logos/thumbs/webp/1x/@(company.LastLogo.Guid).webp 2x,
|
||||
/assets/logos/thumbs/webp/1x/@(company.LastLogo.Guid).webp 3x">
|
||||
<img srcset="/assets/logos/thumbs/png/1x/@(company.LastLogo.Guid).png,
|
||||
/assets/logos/thumbs/png/1x/@(company.LastLogo.Guid).png 2x,
|
||||
/assets/logos/thumbs/png/1x/@(company.LastLogo.Guid).webp 3x"
|
||||
src="/assets/logos/thumbs/png/1x@(company.LastLogo.Guid).png")
|
||||
alt=""
|
||||
height="auto"
|
||||
width="auto"
|
||||
style="max-height: 32px; max-width: 128px" />
|
||||
</picture>
|
||||
}
|
||||
@company.Name
|
||||
</a>
|
||||
<br />
|
||||
}
|
||||
</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>There are no companies found in the database founded in the requested country.</p>
|
||||
}
|
||||
</p>
|
||||
75
cicm_web/Views/Company/Index.cshtml
Normal file
75
cicm_web/Views/Company/Index.cshtml
Normal file
@@ -0,0 +1,75 @@
|
||||
@{
|
||||
/******************************************************************************
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Index.cshtml
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ 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 <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2003-2018 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
ViewData["Title"] = "Companies";
|
||||
}
|
||||
@using System.IO
|
||||
@model IEnumerable<Company>
|
||||
|
||||
<p align=center>
|
||||
@if(Model.Any())
|
||||
{
|
||||
<p>
|
||||
@Model.Count() companies found in the database.<br />
|
||||
@foreach(Company company in Model)
|
||||
{
|
||||
<a asp-controller="Company"
|
||||
asp-action="View"
|
||||
asp-route-id="@company.Id">
|
||||
@if(company.LastLogo != null && File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", company.LastLogo.Guid + ".svg")))
|
||||
{
|
||||
<picture>
|
||||
<source type="image/svg+xml"
|
||||
srcset="/assets/logos/@(company.LastLogo.Guid).svg">
|
||||
<source type="image/webp"
|
||||
srcset="/assets/logos/thumbs/webp/1x/@(company.LastLogo.Guid).webp,
|
||||
/assets/logos/thumbs/webp/1x/@(company.LastLogo.Guid).webp 2x,
|
||||
/assets/logos/thumbs/webp/1x/@(company.LastLogo.Guid).webp 3x">
|
||||
<img srcset="/assets/logos/thumbs/png/1x/@(company.LastLogo.Guid).png,
|
||||
/assets/logos/thumbs/png/1x/@(company.LastLogo.Guid).png 2x,
|
||||
/assets/logos/thumbs/png/1x/@(company.LastLogo.Guid).webp 3x"
|
||||
src="/assets/logos/thumbs/png/1x@(company.LastLogo.Guid).png")
|
||||
alt=""
|
||||
height="auto" width="auto" style="max-height: 32px; max-width: 128px "/>
|
||||
</picture>
|
||||
|
||||
}
|
||||
@company.Name
|
||||
</a>
|
||||
<br />
|
||||
}
|
||||
</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>There are no companies in the database.</p>
|
||||
}
|
||||
</p>
|
||||
Reference in New Issue
Block a user