mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Implement details page for document companies.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Cicm.Database.Models;
|
||||
using cicm_web.Models;
|
||||
using cicm_web.Areas.Admin.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
@@ -23,8 +23,14 @@ namespace cicm_web.Areas.Admin.Controllers
|
||||
// GET: DocumentCompanies
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.DocumentCompanies.Select(d => new CompanyViewModel {Id = d.Id, Name = d.Name})
|
||||
.ToListAsync());
|
||||
return View(await _context.DocumentCompanies
|
||||
.Select(d => new DocumentCompanyViewModel
|
||||
{
|
||||
Id = d.Id,
|
||||
Name = d.Name,
|
||||
Company = d.Company.Name,
|
||||
CompanyId = d.CompanyId
|
||||
}).ToListAsync());
|
||||
}
|
||||
|
||||
// GET: DocumentCompanies/Details/5
|
||||
@@ -32,7 +38,15 @@ namespace cicm_web.Areas.Admin.Controllers
|
||||
{
|
||||
if(id == null) return NotFound();
|
||||
|
||||
DocumentCompany documentCompany = await _context.DocumentCompanies.FirstOrDefaultAsync(m => m.Id == id);
|
||||
DocumentCompanyViewModel documentCompany =
|
||||
await _context.DocumentCompanies
|
||||
.Select(d => new DocumentCompanyViewModel
|
||||
{
|
||||
Id = d.Id,
|
||||
Name = d.Name,
|
||||
Company = d.Company.Name,
|
||||
CompanyId = d.CompanyId
|
||||
}).FirstOrDefaultAsync(m => m.Id == id);
|
||||
if(documentCompany == null) return NotFound();
|
||||
|
||||
return View(documentCompany);
|
||||
|
||||
12
cicm_web/Areas/Admin/Models/DocumentCompanyViewModel.cs
Normal file
12
cicm_web/Areas/Admin/Models/DocumentCompanyViewModel.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace cicm_web.Areas.Admin.Models
|
||||
{
|
||||
public class DocumentCompanyViewModel : BaseViewModel<int>
|
||||
{
|
||||
public string Name { get; set; }
|
||||
[DisplayName("Linked company")]
|
||||
public string Company { get; set; }
|
||||
public int? CompanyId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
@model Cicm.Database.Models.DocumentCompany
|
||||
@model cicm_web.Areas.Admin.Models.DocumentCompanyViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Details";
|
||||
@@ -7,7 +7,7 @@
|
||||
<h1>Details</h1>
|
||||
|
||||
<div>
|
||||
<h4>DocumentCompany</h4>
|
||||
<h4>Document company</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@@ -17,17 +17,24 @@
|
||||
@Html.DisplayFor(model => model.Name)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.CompanyId)
|
||||
@Html.DisplayNameFor(model => model.Company)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.CompanyId)
|
||||
<a asp-action="Details"
|
||||
asp-route-id="@Model.CompanyId"
|
||||
asp-controller="Companies">
|
||||
@Html.DisplayFor(modelItem => Model.Company)</a>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
<a asp-action="Edit"
|
||||
asp-route-id="@Model.Id">
|
||||
asp-route-id="@Model.Id"
|
||||
class="btn btn-primary">
|
||||
Edit
|
||||
</a> |
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</a>
|
||||
<a asp-action="Index"
|
||||
class="btn btn-secondary">
|
||||
Back to List
|
||||
</a>
|
||||
</div>
|
||||
@@ -1,4 +1,5 @@
|
||||
@model IEnumerable<CompanyViewModel>
|
||||
@using cicm_web.Areas.Admin.Models
|
||||
@model IEnumerable<cicm_web.Areas.Admin.Models.DocumentCompanyViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
@@ -18,16 +19,25 @@
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Name)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Company)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach(CompanyViewModel item in Model)
|
||||
@foreach(DocumentCompanyViewModel item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Name)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Details"
|
||||
asp-route-id="@item.CompanyId"
|
||||
asp-controller="Companies">
|
||||
@Html.DisplayFor(modelItem => item.Company)</a>
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Details"
|
||||
class="btn btn-primary"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<Version>3.0.99.856</Version>
|
||||
<Version>3.0.99.857</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