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.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Cicm.Database.Models;
|
using Cicm.Database.Models;
|
||||||
using cicm_web.Models;
|
using cicm_web.Areas.Admin.Models;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
@@ -23,8 +23,14 @@ namespace cicm_web.Areas.Admin.Controllers
|
|||||||
// GET: DocumentCompanies
|
// GET: DocumentCompanies
|
||||||
public async Task<IActionResult> Index()
|
public async Task<IActionResult> Index()
|
||||||
{
|
{
|
||||||
return View(await _context.DocumentCompanies.Select(d => new CompanyViewModel {Id = d.Id, Name = d.Name})
|
return View(await _context.DocumentCompanies
|
||||||
.ToListAsync());
|
.Select(d => new DocumentCompanyViewModel
|
||||||
|
{
|
||||||
|
Id = d.Id,
|
||||||
|
Name = d.Name,
|
||||||
|
Company = d.Company.Name,
|
||||||
|
CompanyId = d.CompanyId
|
||||||
|
}).ToListAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: DocumentCompanies/Details/5
|
// GET: DocumentCompanies/Details/5
|
||||||
@@ -32,7 +38,15 @@ namespace cicm_web.Areas.Admin.Controllers
|
|||||||
{
|
{
|
||||||
if(id == null) return NotFound();
|
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();
|
if(documentCompany == null) return NotFound();
|
||||||
|
|
||||||
return View(documentCompany);
|
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";
|
ViewData["Title"] = "Details";
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
<h1>Details</h1>
|
<h1>Details</h1>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h4>DocumentCompany</h4>
|
<h4>Document company</h4>
|
||||||
<hr />
|
<hr />
|
||||||
<dl class="row">
|
<dl class="row">
|
||||||
<dt class="col-sm-2">
|
<dt class="col-sm-2">
|
||||||
@@ -17,17 +17,24 @@
|
|||||||
@Html.DisplayFor(model => model.Name)
|
@Html.DisplayFor(model => model.Name)
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="col-sm-2">
|
<dt class="col-sm-2">
|
||||||
@Html.DisplayNameFor(model => model.CompanyId)
|
@Html.DisplayNameFor(model => model.Company)
|
||||||
</dt>
|
</dt>
|
||||||
<dd class="col-sm-10">
|
<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>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<a asp-action="Edit"
|
<a asp-action="Edit"
|
||||||
asp-route-id="@Model.Id">
|
asp-route-id="@Model.Id"
|
||||||
|
class="btn btn-primary">
|
||||||
Edit
|
Edit
|
||||||
</a> |
|
</a>
|
||||||
<a asp-action="Index">Back to List</a>
|
<a asp-action="Index"
|
||||||
|
class="btn btn-secondary">
|
||||||
|
Back to List
|
||||||
|
</a>
|
||||||
</div>
|
</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";
|
ViewData["Title"] = "Index";
|
||||||
@@ -18,16 +19,25 @@
|
|||||||
<th>
|
<th>
|
||||||
@Html.DisplayNameFor(model => model.Name)
|
@Html.DisplayNameFor(model => model.Name)
|
||||||
</th>
|
</th>
|
||||||
|
<th>
|
||||||
|
@Html.DisplayNameFor(model => model.Company)
|
||||||
|
</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach(CompanyViewModel item in Model)
|
@foreach(DocumentCompanyViewModel item in Model)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.Name)
|
@Html.DisplayFor(modelItem => item.Name)
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<a asp-action="Details"
|
||||||
|
asp-route-id="@item.CompanyId"
|
||||||
|
asp-controller="Companies">
|
||||||
|
@Html.DisplayFor(modelItem => item.Company)</a>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a asp-action="Details"
|
<a asp-action="Details"
|
||||||
class="btn btn-primary"
|
class="btn btn-primary"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
<Version>3.0.99.856</Version>
|
<Version>3.0.99.857</Version>
|
||||||
<Company>Canary Islands Computer Museum</Company>
|
<Company>Canary Islands Computer Museum</Company>
|
||||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||||
<Product>Canary Islands Computer Museum Website</Product>
|
<Product>Canary Islands Computer Museum Website</Product>
|
||||||
|
|||||||
Reference in New Issue
Block a user