mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Implement index page for document companies.
This commit is contained in:
@@ -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<IActionResult> Index() => View(await _context.DocumentCompanies.ToListAsync());
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.DocumentCompanies.Select(d => new CompanyViewModel {Id = d.Id, Name = d.Name})
|
||||
.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: DocumentCompanies/Details/5
|
||||
public async Task<IActionResult> Details(int? id)
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
@using Cicm.Database.Models
|
||||
@model IEnumerable<Cicm.Database.Models.DocumentCompany>
|
||||
@model IEnumerable<CompanyViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
}
|
||||
|
||||
<h1>Index</h1>
|
||||
<h1>Document companies</h1>
|
||||
|
||||
<p>
|
||||
<a asp-action="Create">Create New</a>
|
||||
<a asp-action="Create"
|
||||
class="btn btn-primary">
|
||||
Create New
|
||||
</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
@@ -16,32 +18,29 @@
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Name)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.CompanyId)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach(DocumentCompany item in Model)
|
||||
@foreach(CompanyViewModel item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.CompanyId)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Edit"
|
||||
asp-route-id="@item.Id">
|
||||
Edit
|
||||
</a> |
|
||||
<a asp-action="Details"
|
||||
class="btn btn-primary"
|
||||
asp-route-id="@item.Id">
|
||||
Details
|
||||
</a> |
|
||||
</a>
|
||||
<a asp-action="Edit"
|
||||
class="btn btn-secondary"
|
||||
asp-route-id="@item.Id">
|
||||
Edit
|
||||
</a>
|
||||
<a asp-action="Delete"
|
||||
class="btn btn-danger"
|
||||
asp-route-id="@item.Id">
|
||||
Delete
|
||||
</a>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<Version>3.0.99.840</Version>
|
||||
<Version>3.0.99.842</Version>
|
||||
<Company>Canary Islands Computer Museum</Company>
|
||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||
<Product>Canary Islands Computer Museum Website</Product>
|
||||
|
||||
Reference in New Issue
Block a user