📄 Documentation: IrbyImaging/Views/Issues/Details.cshtml


📑 Table of Contents

  1. Overview & Purpose
  2. File Location & Role
  3. Dependencies & Technologies
  4. Model & ViewModel
  5. Layout & ViewData
  6. HTML Structure & Razor Syntax
  7. ASP.NET Core Tag Helpers
  8. Integration with Controller
  9. Sample Usage & Code Snippets
  10. UML Class Diagram
  11. Conclusion

1. Overview & Purpose

Details.cshtml is an ASP.NET Core Razor View that renders the Details page for an Issue entity in the IrbyImaging application. Its main responsibilities are:

  • 📋 Display all relevant read‑only fields of an Issue.
  • 🖼️ Use a consistent layout across the application (_HDLayout).
  • 🔗 Provide navigation links to Edit the current issue or go Back to List of issues.

2. File Location & Role

Path Role
IrbyImaging/Views/Issues/Details.cshtml Presents the Details view in the Issues folder.
  • This file lives under the Views/Issues folder—standard for MVC views corresponding to the IssuesController.
  • It is invoked by the controller action Details(int id).

3. Dependencies & Technologies

Dependency Purpose
ASP.NET Core MVC Model–View–Controller framework
Razor Syntax Templating language for dynamic HTML
IrbyImaging.DomainClasses Contains the domain Issue model
HTML Helpers / Tag Helpers Generate HTML and routing links
  • .NET Core runtime (≥ 2.0)
  • Microsoft.AspNetCore.Mvc.Razor
  • Microsoft.AspNetCore.Mvc.TagHelpers

4. Model & ViewModel

This view is strongly-typed to a domain model:

@model IrbyImaging.DomainClasses.Issue

Issue Domain Model (excerpt)

Property Type Description
Id int Unique identifier
Description string Detailed description of the issue
... ... Additional properties (e.g. Status)

Note: Only the Description and Id are used within this view.


5. Layout & ViewData

@{
    Layout = "_HDLayout";
    ViewData["Title"] = "Details";
}
  • Layout: _HDLayout.cshtml defines header, footer, and site-wide styling.
  • ViewData["Title"]: Sets the HTML <title> element and any breadcrumbs or headings that read this value.

6. HTML Structure & Razor Syntax

<h2>Details</h2>
<div>
    <h4>Issue</h4>
    <hr />
    <dl class="dl-horizontal">
        <dt> @Html.DisplayNameFor(m => m.Description) </dt>
        <dd> @Html.DisplayFor(m => m.Description) </dd>
    </dl>
</div>
<div>
    <a asp-action="Edit" asp-route-id="@Model.Id">Edit</a> |
    <a asp-action="Index">Back to List</a>
</div>
  • <dl class="dl-horizontal">

    • <dt> (term): Renders the display name of Description (from data annotations or property name).
    • <dd> (definition): Renders the value of Description.
  • Two links at the bottom:

    • Edit: Navigates to Issues/Edit/{id}.
    • Back to List: Navigates to Issues/Index.

7. ASP.NET Core Tag Helpers

Tag Helper Rendered Output
asp-action="Edit" <a href="/Issues/Edit/5">Edit</a>
asp-route-id="@Model.Id" Injects the current issue’s Id.
asp-action="Index" <a href="/Issues">Back to List</a>

🔑 Key Points

  • Tag Helpers simplify URL generation.
  • They respect routing configurations.

8. Integration with Controller

IssuesController (snippet)

public class IssuesController : Controller
{
    private readonly IIssueRepository _repo;

    public IssuesController(IIssueRepository repo)
    {
        _repo = repo;
    }

    // GET: /Issues/Details/5
    public async Task<IActionResult> Details(int id)
    {
        var issue = await _repo.GetByIdAsync(id);
        if (issue == null)
        {
            return NotFound(); // 404
        }
        return View(issue); // Renders Details.cshtml
    }
}
  • The Details action fetches the Issue by id.
  • Returns 404 if not found.
  • Passes the model instance to Details.cshtml.

9. Sample Usage & Code Snippets

When you click Details in the list:

  1. Browser requests GET /Issues/Details/5.
  2. Controller loads the Issue with Id = 5.
  3. View renders the Description and provides Edit / Back links.

Example HTML Output

<!DOCTYPE html>
<html>
<head>
  <title>Details - IrbyImaging</title>
</head>
<body>
  <h2>Details</h2>
  <div>
    <h4>Issue</h4>
    <hr>
    <dl class="dl-horizontal">
      <dt>Description</dt>
      <dd>Leaking pipe in north wing.</dd>
    </dl>
  </div>
  <div>
    <a href="/Issues/Edit/5">Edit</a>  |
    <a href="/Issues">Back to List</a>
  </div>
</body>
</html>

10. UML Class Diagram

classDiagram
    class Issue {
        +int Id
        +string Description
        +DateTime CreatedOn
        +StatusType Status
    }

    class IssuesController {
        -IIssueRepository _repo
        +Details(int id) IActionResult
        +Edit(int id) IActionResult
        +Index() IActionResult
    }

    Issue <|-- Details.cshtml : viewModel
    IssuesController --> Issue : retrieves
  • Issue: Domain entity passed into the view.
  • IssuesController: Orchestrates fetching and returning the view.

11. Conclusion

🎯 Details.cshtml is a simple, read‑only Razor View for displaying an Issue entity’s details in IrbyImaging. It leverages:

  • Strongly-​typed view model binding
  • _HDLayout for site-wide look & feel
  • ASP.NET Core Tag Helpers and HTML Helpers for concise Razor code
  • Clear navigation via Edit and Back to List links

Use this as a template for other Details views—simply swap the model type, <dl> entries, and controller integration. Happy coding! 🚀