📄 Documentation: IrbyImaging/Views/JDE/Edit.cshtml
Table of Contents
- Overview & Purpose
- File Structure & Data Flow
- Dependencies & Technologies
- ViewModel & Data Models
- Styles Section
- Form Layout & Fields
- Helper Methods & Utilities
- Error Handling & Validation
- API Endpoints Overview
- Third-party Integrations
- Sample Code Blocks
- Usage Examples
- UML Class Diagram 🧩
- Conclusion 🎯
1. Overview & Purpose
This Razor view (Edit.cshtml) is part of the JDE section within the IrbyImaging ASP.NET Core MVC application. It allows users to update (Edit) an existing Field Office record.
Key features include:
- Pre-populating a form with existing data (via the
FieldOfficemodel). - Rich drop-downs (Select2) for choosing employees (Manager, Superintendent, etc.).
- Client‐side validation and input masks for phone numbers.
- Integration with date‐pickers, TinyMCE (for rich text), and file‐upload styles.
Emoji Legend:
🎨 – UI/Styles
⚙️ – Configuration
🛠 – Helper/Utilities
✅ – Validation/Error Handling
🔗 – Third-party
2. File Structure & Data Flow
IrbyImaging
└── Views
└── JDE
└── Edit.cshtml <-- This view
-
Controller (
JdeController.Edit(int id))
• Fetches aFieldOfficedomain object by ID
• PopulatesEmployeeData(SelectList of employees)
• ReturnsView(model) -
View (
Edit.cshtml)
• Binds@model IrbyImaging.DomainClasses.FieldOffice
• Renders form fields & dropdowns
• Posts back toJdeController.Edit(FieldOffice model)on submit -
POST Action
• Validates model
• Updates database
• Redirects or redisplays with validation errors
3. Dependencies & Technologies
| Category | Libraries / Frameworks | Purpose |
|---|---|---|
| ⚙️ Framework | ASP.NET Core MVC (Razor) | Server‐side view rendering |
| 🎨 CSS | Bootstrap, Select2, bootstrap-datepicker | Layout, forms, date pickers |
| 🛠 JS Utilities | jQuery, Select2, TinyMCE, jquery.repeater | Dynamic selects, rich text editing |
| 🛠 UI Plugins | metisMenu, simplebar, waves | Navigation, custom scrollbars, effects |
| ✅ Validation | asp-validation-for, _ValidationScriptsPartial |
Client‐side form validation |
4. ViewModel & Data Models
Domain Model: FieldOffice
| Property | Type | Description |
|---|---|---|
int Id |
int | Primary key |
string JdeNumber |
string | JDE system code |
string Name |
string | Field Office name |
int? ManagerId |
int? | FK to Employee |
Employee Manager |
object | Navigation property |
| … | … | … |
SelectList EmployeeData |
SelectList | Dropdown data for all employee roles |
Note: The domain class likely contains properties for
ProjectManagerId,AsstProjectManagerId,SuperintendentId,LeadId,DirectorId,PrimaryContactId,SecondaryContactId, plus address and phone fields.
5. Styles Section
@section styles {
<!-- Datepicker CSS -->
<link href="~/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet" />
<!-- Dropzone CSS -->
<link href="~/libs/dropzone/min/dropzone.min.css" rel="stylesheet" />
}
- Ensures datepickers and file‐upload styles are loaded in the
<head>. - Leverages Bootstrap 4/5 theming.
6. Form Layout & Fields
6.1. Header & Layout
@{
ViewData["Title"] = "Field Office Update";
Layout = "~/Views/Shared/_ATSLayout.cshtml";
}
<h2>Field Office Update</h2>
<hr />
- Title: Sets the page title.
- Layout: Uses a shared layout for consistent header/footer.
6.2. Dropdown Placeholder Initialization
@{
var mgrVal = Model.Manager?.FullName ?? "Select Manager";
var pmgrVal = Model.ProjectManager?.FullName ?? "Select Project Manager";
// ... similarly for AsstProjectManager, Superintendent, Lead, Director, PrimaryContact, SecondaryContact
}
- Dynamically sets the first
<option>text based on existing selection or a default prompt.
6.3. Form & Fields
<form asp-action="Edit">
<input type="hidden" asp-for="Id" />
<!-- Row: JDE #, Field Office Name -->
<div class="form-group row mb-4">
<label class="col-form-label col-sm-1"><strong>JDE Number</strong></label>
<div class="col-lg-2">
<input asp-for="JdeNumber" class="form-control" />
<span asp-validation-for="JdeNumber" class="text-danger"></span>
</div>
<!-- Field Office Name -->
<label class="col-form-label col-sm-1"><strong>Field Office Name</strong></label>
<div class="col-lg-2">
<input asp-for="Name" class="form-control" />
<span asp-validation-for="Name" class="text-danger"></span>
</div>
</div>
<!-- Row: Manager, Superintendent, Lead, Director -->
<div class="form-group row mb-4">
@* Manager *@
<label class="col-form-label col-sm-1"><strong>Manager</strong></label>
<div class="col-lg-2">
<select asp-for="ManagerId" class="js-example-basic-single" asp-items="@Model.EmployeeData">
<option>@mgrVal</option>
</select>
</div>
@* Superintendent *@
<label class="col-form-label col-sm-1"><strong>Superintendent</strong></label>
<div class="col-lg-2">
<select asp-for="SuperintendentId" class="js-example-basic-single" asp-items="@Model.EmployeeData">
<option>@supVal</option>
</select>
</div>
<!-- Lead -->
<label class="col-form-label col-sm-1"><strong>Lead</strong></label>
<div class="col-lg-2">
<select asp-for="LeadId" class="js-example-basic-single" asp-items="@Model.EmployeeData">
<option>@leadVal</option>
</select>
</div>
<!-- Director -->
<label class="col-form-label col-sm-1"><strong>Director</strong></label>
<div class="col-lg-2">
<select asp-for="DirectorId" class="js-example-basic-single" asp-items="@Model.EmployeeData">
<option>@directorVal</option>
</select>
</div>
</div>
<!-- Row: Project Manager, Asst PM, Office Phone, Fax -->
<!-- … Additional rows for mailing/shipping address & primary/secondary contact … -->
<div class="form-group">
<a asp-action="Index" class="btn btn-danger irby-red">Index List</a>
<input type="submit" value="Update" class="btn btn-success irby-green" />
</div>
</form>
- Layout: Uses Bootstrap grid (
.row,.col-lg-#,.form-group). - Input Types:
text,tel(with regex pattern for000-00-000phone format). - Select Lists:
.js-example-basic-single→ initialized by Select2.
7. Helper Methods & Utilities
- Placeholder Logic:
var mgrVal = Model.Manager != null ? Model.Manager.FullName : "Select Manager"; asp-forTag Helper: Binds input/select to the model’s property.asp-itemsTag Helper: Populates<select>fromModel.EmployeeData(SelectList).
8. Error Handling & Validation
- Inline Validation Messages:
<span asp-validation-for="JdeNumber" class="text-danger"></span> - Validation Scripts Partial:
@section Scripts { @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } } - Follows standard Unobtrusive jQuery validation.
9. API Endpoints Overview
This is a server‐rendered view, not a Web API. However, it posts back to:
- HTTP GET
/Jde/Edit/{id}→ Populate form - HTTP POST
/Jde/Edit→ Process update
10. Third‑party Integrations
| Plugin | Purpose |
|---|---|
| Select2 🎯 | Enhanced dropdowns |
| bootstrap-datepicker | Date picker styles/scripts |
| TinyMCE 📝 | Rich-text editing (if used) |
| dropzone | File-upload CSS (JS not shown) |
| jquery.repeater | Form repeaters (if used) |
Initialization of Select2:
<script>
$(document).ready(function () {
$('.js-example-basic-single').select2();
});
</script>
11. Sample Code Blocks
a) Controller Example (C#)
public class JdeController : Controller
{
private readonly IFieldOfficeService _service;
public JdeController(IFieldOfficeService service) => _service = service;
[HttpGet]
public async Task<IActionResult> Edit(int id)
{
var model = await _service.GetFieldOfficeAsync(id);
model.EmployeeData = await _service.GetEmployeeSelectListAsync();
return View(model);
}
[HttpPost]
public async Task<IActionResult> Edit(FieldOffice model)
{
if (!ModelState.IsValid) {
model.EmployeeData = await _service.GetEmployeeSelectListAsync();
return View(model);
}
await _service.UpdateFieldOfficeAsync(model);
return RedirectToAction(nameof(Index));
}
}
b) FieldOffice Domain Class (Simplified)
public class FieldOffice
{
public int Id { get; set; }
public string JdeNumber { get; set; }
public string Name { get; set; }
// Employee roles
public int? ManagerId { get; set; }
public virtual Employee Manager { get; set; }
// … other roles …
public SelectList EmployeeData { get; set; }
}
12. Usage Examples
- Navigate to
/Jde/Edit/5to update Field Office with ID=5. - Modify the JDE number, addresses, or assigned employees.
- Click “Update” (✅ client‐side validation fires).
- On success, redirect to the Index list.
13. UML Class Diagram 🧩
classDiagram
FieldOffice <|.. JdeController
FieldOffice : +int Id
FieldOffice : +string JdeNumber
FieldOffice : +string Name
FieldOffice : +int? ManagerId
FieldOffice : +Employee Manager
FieldOffice : +SelectList EmployeeData
JdeController : +Edit(int id) : IActionResult
JdeController : +Edit(FieldOffice model) : IActionResult
14. Conclusion 🎯
The Edit.cshtml view is a comprehensive, user-friendly interface for updating Field Office data in the JDE module. It leverages:
- ASP.NET Core MVC for model binding & validation
- Select2 for searchable dropdowns
- Bootstrap for responsive layout
- Unobtrusive jQuery Validation for a robust UX
By following this documentation, developers can quickly understand, maintain, and extend the update functionality for Field Offices within the IrbyImaging application.