diff --git a/cicm_web/Areas/Admin/Controllers/CompanyDescriptionsController.cs b/cicm_web/Areas/Admin/Controllers/CompanyDescriptionsController.cs index 8397c853..368915f5 100644 --- a/cicm_web/Areas/Admin/Controllers/CompanyDescriptionsController.cs +++ b/cicm_web/Areas/Admin/Controllers/CompanyDescriptionsController.cs @@ -31,6 +31,7 @@ using System.Linq; using System.Threading.Tasks; using Cicm.Database.Models; +using cicm_web.Areas.Admin.Models; using Markdig; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -58,7 +59,11 @@ namespace cicm_web.Areas.Admin.Controllers { IIncludableQueryable cicmContext = _context.CompanyDescriptions.Include(c => c.Company); - return View(await cicmContext.OrderBy(c => c.Company.Name).ToListAsync()); + return View(await cicmContext.OrderBy(c => c.Company.Name) + .Select(c => new CompanyDescriptionViewModel + { + Id = c.Id, Company = c.Company.Name + }).ToListAsync()); } // GET: CompanyDescription/Details/5 diff --git a/cicm_web/Areas/Admin/Models/CompanyDescriptionViewModel.cs b/cicm_web/Areas/Admin/Models/CompanyDescriptionViewModel.cs new file mode 100644 index 00000000..886758e1 --- /dev/null +++ b/cicm_web/Areas/Admin/Models/CompanyDescriptionViewModel.cs @@ -0,0 +1,38 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : CompanyDescription.cs +// Author(s) : Natalia Portillo +// +// --[ Description ] ---------------------------------------------------------- +// +// Holds company descriptions. +// +// --[ 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_web.Areas.Admin.Models +{ + public class CompanyDescriptionViewModel + { + public string Company; + public int Id; + } +} \ No newline at end of file diff --git a/cicm_web/Areas/Admin/Views/CompanyDescriptions/Index.cshtml b/cicm_web/Areas/Admin/Views/CompanyDescriptions/Index.cshtml index 71cfdf65..184ed090 100644 --- a/cicm_web/Areas/Admin/Views/CompanyDescriptions/Index.cshtml +++ b/cicm_web/Areas/Admin/Views/CompanyDescriptions/Index.cshtml @@ -29,8 +29,8 @@ // Copyright © 2003-2018 Natalia Portillo *******************************************************************************/ } -@using Cicm.Database.Models -@model IEnumerable +@using cicm_web.Areas.Admin.Models +@model IEnumerable @{ ViewData["Title"] = "Company descriptions (Admin)"; @@ -54,11 +54,11 @@ - @foreach(CompanyDescription item in Model) + @foreach(CompanyDescriptionViewModel item in Model) { - @Html.DisplayFor(modelItem => item.Company.Name) + @Html.DisplayFor(modelItem => item.Company) netcoreapp2.2 - 3.0.99.545 + 3.0.99.547 Canary Islands Computer Museum Copyright © 2003-2018 Natalia Portillo Canary Islands Computer Museum Website