diff --git a/cicm_web/Areas/Admin/Controllers/CompanyLogosController.cs b/cicm_web/Areas/Admin/Controllers/CompanyLogosController.cs index 57428b99..ec6c2f30 100644 --- a/cicm_web/Areas/Admin/Controllers/CompanyLogosController.cs +++ b/cicm_web/Areas/Admin/Controllers/CompanyLogosController.cs @@ -24,7 +24,11 @@ namespace cicm_web.Areas.Admin.Controllers public async Task Index() { IIncludableQueryable cicmContext = _context.CompanyLogos.Include(c => c.Company); - return View(await cicmContext.OrderBy(l => l.Company.Name).ThenBy(l => l.Year).ToListAsync()); + return View(await cicmContext.OrderBy(l => l.Company.Name).ThenBy(l => l.Year) + .Select(l => new CompanyLogoViewModel + { + Company = l.Company.Name, Id = l.Id, Year = l.Year + }).ToListAsync()); } // GET: CompanyLogos/Details/5 @@ -73,7 +77,8 @@ namespace cicm_web.Areas.Admin.Controllers CompanyLogo companyLogo = await _context.CompanyLogos.FirstOrDefaultAsync(c => c.Id == id); if(companyLogo == null) return NotFound(); - ViewData["CompanyId"] = new SelectList(_context.Companies.OrderBy(l => l.Name), "Id", "Name", companyLogo.CompanyId); + ViewData["CompanyId"] = + new SelectList(_context.Companies.OrderBy(l => l.Name), "Id", "Name", companyLogo.CompanyId); return View(companyLogo); } @@ -103,7 +108,8 @@ namespace cicm_web.Areas.Admin.Controllers return RedirectToAction(nameof(Index)); } - ViewData["CompanyId"] = new SelectList(_context.Companies.OrderBy(l => l.Name), "Id", "Name", companyLogo.CompanyId); + ViewData["CompanyId"] = + new SelectList(_context.Companies.OrderBy(l => l.Name), "Id", "Name", companyLogo.CompanyId); return View(companyLogo); } diff --git a/cicm_web/Areas/Admin/Models/CompanyLogoViewModel.cs b/cicm_web/Areas/Admin/Models/CompanyLogoViewModel.cs new file mode 100644 index 00000000..55a23e33 --- /dev/null +++ b/cicm_web/Areas/Admin/Models/CompanyLogoViewModel.cs @@ -0,0 +1,39 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : CompanyLogo.cs +// Author(s) : Natalia Portillo +// +// --[ Description ] ---------------------------------------------------------- +// +// Describes a company logo and contains the GUID for its file. +// +// --[ 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 +*******************************************************************************/ + +namespace Cicm.Database.Models +{ + public class CompanyLogoViewModel + { + public string Company; + public int Id; + public int? Year; + } +} \ No newline at end of file diff --git a/cicm_web/Areas/Admin/Views/CompanyLogos/Index.cshtml b/cicm_web/Areas/Admin/Views/CompanyLogos/Index.cshtml index d14ca030..f465f694 100644 --- a/cicm_web/Areas/Admin/Views/CompanyLogos/Index.cshtml +++ b/cicm_web/Areas/Admin/Views/CompanyLogos/Index.cshtml @@ -1,5 +1,5 @@ @using Cicm.Database.Models -@model IEnumerable +@model IEnumerable @{ ViewData["Title"] = "Index"; @@ -27,11 +27,11 @@ - @foreach(CompanyLogo item in Model) + @foreach(CompanyLogoViewModel item in Model) { - @Html.DisplayFor(modelItem => item.Company.Name) + @Html.DisplayFor(modelItem => item.Company) @Html.DisplayFor(modelItem => item.Year) diff --git a/cicm_web/cicm_web.csproj b/cicm_web/cicm_web.csproj index d10291d6..22220f66 100644 --- a/cicm_web/cicm_web.csproj +++ b/cicm_web/cicm_web.csproj @@ -2,7 +2,7 @@ netcoreapp2.2 - 3.0.99.547 + 3.0.99.548 Canary Islands Computer Museum Copyright © 2003-2018 Natalia Portillo Canary Islands Computer Museum Website