diff --git a/cicm_web/Areas/Admin/Controllers/DocumentCompaniesController.cs b/cicm_web/Areas/Admin/Controllers/DocumentCompaniesController.cs index ea19b2ea..ed39c77b 100644 --- a/cicm_web/Areas/Admin/Controllers/DocumentCompaniesController.cs +++ b/cicm_web/Areas/Admin/Controllers/DocumentCompaniesController.cs @@ -1,6 +1,7 @@ using System.Linq; using System.Threading.Tasks; using Cicm.Database.Models; +using cicm_web.Models; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -19,7 +20,11 @@ namespace cicm_web.Areas.Admin.Controllers } // GET: DocumentCompanies - public async Task Index() => View(await _context.DocumentCompanies.ToListAsync()); + public async Task Index() + { + return View(await _context.DocumentCompanies.Select(d => new CompanyViewModel {Id = d.Id, Name = d.Name}) + .ToListAsync()); + } // GET: DocumentCompanies/Details/5 public async Task Details(int? id) diff --git a/cicm_web/Areas/Admin/Views/DocumentCompanies/Index.cshtml b/cicm_web/Areas/Admin/Views/DocumentCompanies/Index.cshtml index bf6b18f6..ea42e3c5 100644 --- a/cicm_web/Areas/Admin/Views/DocumentCompanies/Index.cshtml +++ b/cicm_web/Areas/Admin/Views/DocumentCompanies/Index.cshtml @@ -1,14 +1,16 @@ -@using Cicm.Database.Models -@model IEnumerable +@model IEnumerable @{ ViewData["Title"] = "Index"; } -

Index

+

Document companies

- Create New + + Create New +

@@ -16,32 +18,29 @@ - - @foreach(DocumentCompany item in Model) + @foreach(CompanyViewModel item in Model) { -
@Html.DisplayNameFor(model => model.Name) - @Html.DisplayNameFor(model => model.CompanyId) -
@Html.DisplayFor(modelItem => item.Name) - @Html.DisplayFor(modelItem => item.CompanyId) - - - Edit - | Details - | + + + Edit + Delete diff --git a/cicm_web/cicm_web.csproj b/cicm_web/cicm_web.csproj index f8469db6..5a21630b 100644 --- a/cicm_web/cicm_web.csproj +++ b/cicm_web/cicm_web.csproj @@ -2,7 +2,7 @@ netcoreapp2.2 - 3.0.99.840 + 3.0.99.842 Canary Islands Computer Museum Copyright © 2003-2018 Natalia Portillo Canary Islands Computer Museum Website