📄 IrbyImaging/Views/FieldOffices/Create.cshtml Documentation
📑 Table of Contents
- Overview & Purpose
- Context & Dependencies
- View Model & Data Binding
- Layout & Razor Sections
- Form Structure & Fields
- Validation & Error Handling
- Third‑Party Libraries & Scripts
- Sample Usage & Navigation
- UML Diagram of Related Entities
- Conclusion
1. Overview & Purpose
This Razor View renders the "Create Field Office" page in the IrbyImaging ASP.NET Core MVC application.
It allows users to input the necessary details to spin up a new Field Office record in the system.
- URL:
/FieldOffices/Create - Action:
POST /FieldOffices/Create - Layout: Uses a common ATS (Applicant Tracking System) layout defined in
~/Views/Shared/_ATSLayout.cshtml.
✨ Key Features
- Presents a clean form to capture JDE Number, Name, and Manager
- Client‑side & server‑side validation
- Reuses shared layout and partial views for consistency
2. Context & Dependencies
| Layer | Component |
|---|---|
| MVC Controller | FieldOfficesController.Create() |
| View Model (Domain) | IrbyImaging.DomainClasses.FieldOffice |
| Layout | ~/Views/Shared/_ATSLayout.cshtml |
| Validation Scripts | _ValidationScriptsPartial |
| CSS Framework | Bootstrap |
| JS Utilities | MetisMenu, SimpleBar, Waves |
Dependencies
- ASP.NET Core MVC
- Tag Helpers (
asp-for,asp-action,asp-items) - jQuery (for validation scripts)
- Bootstrap 4+ (for responsive layout)
3. View Model & Data Binding
@model IrbyImaging.DomainClasses.FieldOffice
FieldOffice DomainClass
| Property | Type | Required | Description |
|---|---|---|---|
| JdeNumber | string | Yes | Unique JDE identifier for the office |
| Name | string | Yes | Friendly name of the office |
| ManagerId | int | No | FK to the Manager (Employee) |
The ManagerId property is populated by the controller via ViewBag.ManagerId, which supplies a SelectList of managers.
4. Layout & Razor Sections
@{
ViewData["Title"] = "Create";
Layout = "~/Views/Shared/_ATSLayout.cshtml";
}
- ViewData["Title"] sets the browser tab title
- Layout points to a shared layout for ATS pages
- @section Scripts injects custom scripts for this page
5. Form Structure & Fields
<form asp-action="Create">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<!-- JDE Number -->
<div class="form-group">
<label asp-for="JdeNumber" class="control-label"></label>
<input asp-for="JdeNumber" class="form-control" />
<span asp-validation-for="JdeNumber" class="text-danger"></span>
</div>
<!-- Office Name -->
<div class="form-group">
<label asp-for="Name" class="control-label"></label>
<input asp-for="Name" class="form-control" />
<span asp-validation-for="Name" class="text-danger"></span>
</div>
<!-- Manager Selection -->
<div class="form-group">
<label asp-for="Manager" class="control-label"></label>
<select asp-for="ManagerId" class="form-control" asp-items="ViewBag.ManagerId"></select>
</div>
<!-- Action Buttons -->
<div class="form-group">
<a asp-action="Index" class="btn btn-danger irby-red">Index List</a>
<input type="submit" value="Create" class="btn btn-success irby-green" />
</div>
</form>
📋 Field Summary
| Field | Tag | CSS Class | Purpose |
|---|---|---|---|
| JdeNumber | <input> |
form-control | Enter the unique JDE code |
| Name | <input> |
form-control | Enter the office’s display name |
| ManagerId | <select> |
form-control | Choose the office manager from dropdown |
| Submit/Create | <input> |
btn btn-success | Posts form to server to create the record |
| Index List | <a> |
btn btn-danger | Navigate back to listing page |
6. Validation & Error Handling
-
asp-validation-summary
Renders model‑level errors at the top of the form. -
asp-validation-for
Renders field‑specific validation messages. -
Client‑Side Scripts
@section Scripts { @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } }Loads jQuery Validation and Unobtrusive scripts to enable instant feedback.
7. Third‑Party Libraries & Scripts
The view references several JS bundles at the bottom:
<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>
- Bootstrap: Responsive grid & form styling
- MetisMenu: Sidebar menu interactions
- SimpleBar: Custom scrollbars
- Node‑Waves: Ripple effects
8. Sample Usage & Navigation
- Navigate to
/FieldOffices/Create. - Fill out the JDE Number, Office Name, and select a Manager.
- Click Create â–º triggers
POST FieldOffices/Create. - On success, user is redirected back to
Indexwhere the new office appears.
# Example - cURL
curl -X POST https://yourdomain.com/FieldOffices/Create \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "JdeNumber=12345&Name=West+Region&ManagerId=7"
9. UML Diagram of Related Entities
classDiagram
class FieldOffice {
+int Id
+string JdeNumber
+string Name
+int? ManagerId
+Employee Manager
}
class Employee {
+int Id
+string FullName
+string Email
}
FieldOffice --> Employee : Manager
- FieldOffice holds a nullable foreign key to Employee (Manager).
10. Conclusion
This Create.cshtml view is a central part of the Field Offices feature in the IrbyImaging application. It leverages ASP.NET Core MVC Tag Helpers, robust validation, and a consistent shared layout to:
- Facilitate the creation of new field office records
- Guide users with inline feedback and error messages
- Reuse styling & scripting for a unified look-and-feel
🚀 You now have a detailed overview and code snippets to understand, extend, or troubleshoot the Create Field Office page!