πŸ“„ Documentation: IrbyImaging/Views/Manufacturers/Index.cshtml


Table of Contents

  1. Overview & Purpose
  2. Key Functional Areas
  3. Dependencies & Technologies
  4. View Model & Data Model
  5. HTML & Razor Markup Breakdown
  6. Scripts & Third‑Party Integrations
  7. Usage Examples
  8. UML Class Diagram
  9. Conclusion

Overview & Purpose

This Razor view renders a list of manufacturers within the IrbyImaging ASP.NET Core MVC application. It leverages the powerful DataTables jQuery plugin for rich table features (sorting, searching, exporting), and displays:

  • A header with the total count of manufacturers
  • A button to add a new manufacturer
  • An interactive, exportable data grid

✨ Intended Audience: Front‑end developers integrating DataTables with MVC, and back‑end developers maintaining manufacturer administration.


Key Functional Areas

Section Description
ViewData / Layout Sets the page title and applies the shared _ATSLayout.cshtml.
Header & Actions Displays a <h2> with a dynamic badge of the total manufacturer count, and an β€œAdd New Manufacturer” button.
Table Markup Defines a <table> with column headers for Name, Availability, and Update action.
Data Binding Loops through Model (IEnumerable<Manufacturer>) to render each row with Razor HTML Helpers (DisplayFor, Url.Action).
Scripts Section Loads CSS/JS for DataTables, Buttons, jQuery, Bootstrap, and initializes the table with CSV/Excel/Print export buttons.

Dependencies & Technologies

Category Libraries / Frameworks
ASP.NET Core MVC Razor Views, HTML Helpers (DisplayNameFor, DisplayFor, Url.Action)
CSS Framework Bootstrap 4, Custom Irby Styles (irby-blue, irby-green)
JavaScript Framework jQuery 3.5.1
DataTables Plugins jquery.dataTables.min.css/js, dataTables.bootstrap4.min.css/js, Buttons (csv, etc.)
Export Utilities JSZip, pdfmake, pdfmake vfs_fonts
UI Helpers MetisMenu, Simplebar, Node-waves

View Model & Data Model

// Located in IrbyImaging.DomainClasses
public class Manufacturer
{
    public int    Id                { get; set; }    // Primary key
    public string Name              { get; set; }    // Display name
    public bool   IsAvailableOption { get; set; }    // Availability flag
}
  • @model IEnumerable<Manufacturer>
    The view expects a collection of Manufacturer objects.

HTML & Razor Markup Breakdown

@model IEnumerable<IrbyImaging.DomainClasses.Manufacturer>
@{
    ViewData["Title"] = "Manufacturer List";
    Layout = "~/Views/Shared/_ATSLayout.cshtml";
}
<h2>
  Manufacturers 
  <span class="badge irby-blue">@Model.Count()</span>
</h2>

<p>
  <a asp-action="Create" class="btn-sm btn-success irby-green">
    βž• Add New Manufacturer
  </a>
</p>
  1. Page Configuration

    • ViewData["Title"] sets the browser tab title.
    • Layout references a shared master layout.
  2. Header

    • Displays β€œManufacturers” and a badge with @Model.Count().
    • Emoji usage (βž•) enhances UI clarity.
<table id="manufacturersDatatable" class="table table-striped table-bordered dt-responsive nowrap">
  <thead>
    <tr>
      <th>@Html.DisplayNameFor(m => m.Name)</th>
      <th>@Html.DisplayNameFor(m => m.IsAvailableOption)</th>
      <th>Update</th>
    </tr>
  </thead>
  <tbody>
    @foreach (var item in Model)
    {
      <tr>
        <td>@Html.DisplayFor(m => item.Name)</td>
        <td>@(item.IsAvailableOption ? "βœ…" : "❌")</td>
        <td>
          <a href="@Url.Action("Edit", "Manufacturers", new { id = item.Id })"
             class="btn-sm btn-warning">
            ✏️ Update
          </a>
        </td>
      </tr>
    }
  </tbody>
</table>
  • DisplayNameFor / DisplayFor
    Ensures column headings and cell values come from model metadata.
  • Availability Column
    Renders βœ… or ❌ based on IsAvailableOption.
  • Update Action
    Links to /Manufacturers/Edit/{id}.

Scripts & Third‑Party Integrations

@section Scripts {
  <!-- jQuery & DataTables Core -->
  <script src="https://code.jquery.com/jquery-3.5.1.js"></script>
  <script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
  
  <!-- DataTables Buttons & Export -->
  <script src="https://cdn.datatables.net/buttons/1.7.1/js/dataTables.buttons.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
  <script src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.html5.min.js"></script>
  <script src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.print.min.js"></script>

  <!-- Bootstrap & UI Helpers -->
  <script src="~/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
  <script src="~/libs/metismenu/metisMenu.min.js"></script>
  <script src="~/libs/simplebar/simplebar.min.js"></script>
  <script src="~/libs/node-waves/waves.min.js"></script>

  <script type="text/javascript">
    $(document).ready(function () {
      $('#manufacturersDatatable').DataTable({
        dom: 'Bfrtip',
        buttons: ['csv', 'excel', 'print']
      });
    });
  </script>
}
  • DataTables Initialization
    • dom: 'Bfrtip' places buttons, filter, and table elements.
    • Buttons: CSV, Excel, Print.
  • UIs: MetisMenu, Simplebar, Node‐Waves provide consistent look‑and‑feel.

Usage Examples

  1. Controller Action
    public IActionResult Index()
    {
        var manufacturers = _manufacturerService.GetAll();
        return View(manufacturers);
    }
    
  2. Navigating the View
    • URL: /Manufacturers/Index
    • Click β€œAdd New Manufacturer” to navigate to /Manufacturers/Create.
    • Click β€œβœοΈ Update” on a row to go to /Manufacturers/Edit/{id}.
  3. Exporting Data
    • Use the CSV, Excel, or Print buttons embedded at the top of the table.

UML Class Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Manufacturer (Domain)    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ - int    Id                β”‚
β”‚ - string Name              β”‚
β”‚ - bool   IsAvailableOption β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β–²
        β”‚ IEnumerable<Manufacturer>
        β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Index.cshtml (View)       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ + Table of Manufacturers   β”‚
β”‚ + DataTables Integration   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Conclusion

This Index.cshtml view offers a user-friendly, data-driven interface for administrators to manage manufacturers. By combining ASP.NET Core MVC Razor syntax with DataTables for rich functionality (sorting, filtering, exporting), it delivers:

  • A scalable solution for large datasets
  • Responsive design via Bootstrap 4
  • Quick actions (Create, Edit) integrated seamlessly

πŸ‘ Next Steps:

  • Implement backend paging/filtering for very large lists
  • Add delete confirmations or bulk operations
  • Enhance accessibility (ARIA attributes)

Happy coding! πŸš€