📋 IrbyImaging/Views/Billing/Edit.cshtml Documentation


Table of Contents

  1. 🎯 Overview & Purpose
  2. 📂 File Location & Context
  3. 📦 Dependencies & Technologies
  4. 🧩 ViewModel
  5. 🔧 Layout & Styling
  6. 📝 Form Structure & Fields
  7. ⚙️ Scripts & Client‑Side Behavior
  8. 🔗 Controller & API Endpoints
  9. 🐞 Error Handling & Validation
  10. 🔄 UML Diagram
  11. 💻 Sample Usage & Code Snippets
  12. ✅ Conclusion

🎯 Overview & Purpose

The Edit.cshtml Razor View is part of the Billing feature in the IrbyImaging ASP.NET Core MVC application.
It provides a user interface for editing invoice records, including customer details and job/billing information. Users can view certain fields as read‑only (e.g., Carrier Name, Invoice Year/Month) while updating editable fields (e.g., First Name, Last Name, JDE Number, Job Number). Once edited, the form is posted back to the BillingController for processing.


📂 File Location & Context

IrbyImaging
 └── Views
     └── Billing
         └── Edit.cshtml    ← This file
  • Layer: Presentation
  • Pattern: MVC (View)
  • Layout: Inherits from _ATSLayout.cshtml

📦 Dependencies & Technologies

Type Library/Framework Purpose
Framework ASP.NET Core MVC Razor View engine & HTML helpers
CSS Bootstrap 5 Grid, form styling
CSS bootstrap-datepicker Datepicker UI
CSS Dropzone (Included for potential file uploads)
JavaScript jQuery DOM manipulation
JavaScript Bootstrap Bundle Components & utilities
JavaScript bootstrap-datepicker Datepicker initialization
JavaScript TinyMCE Rich text editing (included)
JavaScript jQuery Repeater Dynamic form lists
JavaScript MetisMenu, SimpleBar, Waves.js UI enhancements
Custom Scripts ~/js/app.js, ~/js/pages/task-create.init.js App-specific behaviors

🧩 ViewModel

// Model: IrbyImaging.UI.Models.Billing
public class BillingViewModel
{
    public string CarrierName { get; set; }
    public string InvoiceYearMonth { get; set; }
    public string PhoneNumber { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string JDENumber { get; set; }
    public string JobNumber { get; set; }
}
  • The view is strongly typed to BillingViewModel.
  • Read-only fields: CarrierName, InvoiceYearMonth, PhoneNumber.
  • Editable fields: FirstName, LastName, JDENumber, JobNumber.

🔧 Layout & Styling

@{
    ViewData["Title"] = "View";
    Layout = "~/Views/Shared/_ATSLayout.cshtml";
}

@section styles {
    <!-- Datepicker -->
    <link href="~/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet" />
    <!-- Dropzone (file uploads) -->
    <link href="~/libs/dropzone/min/dropzone.min.css" rel="stylesheet" type="text/css" />
}
  • Layout: _ATSLayout.cshtml provides common header, footer, and navigation.
  • Styles: Scoped to this page via @section styles.

📝 Form Structure & Fields

The HTML form uses Html.BeginForm("Edit", "Billing", FormMethod.Post) to send a POST request to BillingController.Edit.

@using (Html.BeginForm("Edit", "Billing", FormMethod.Post)) {
  <div class="row">
    <!-- Card Container -->
    <div class="col-lg-6">
      <div class="card">
        <div class="card-body">
          <h4 class="card-title mb-4">Edit Invoice Record</h4>

          <!-- Repeater Wrapper (outer-group) -->
          <div data-repeater-list="outer-group" class="outer">
            <div data-repeater-item class="outer">

              <!-- Carrier Name (readonly) -->
              <div class="mb-3 row">
                <label class="col-md-3 col-form-label">Carrier Name</label>
                <div class="col-md-9">
                  <input class="form-control" type="text"
                         asp-for="CarrierName"
                         readonly />
                </div>
              </div>

              <!-- Invoice Year Month (readonly) -->
              <div class="row mb-4">
                <label class="col-form-label col-lg-3">Invoice Year Month</label>
                <div class="col-lg-9">
                  <input class="form-control" type="text"
                         asp-for="InvoiceYearMonth"
                         readonly />
                </div>
              </div>

              <!-- Phone Number (readonly) -->
              <div class="row mb-4">
                <label class="col-form-label col-lg-3">Phone Number</label>
                <div class="col-lg-9">
                  <input class="form-control" type="text"
                         asp-for="PhoneNumber"
                         readonly />
                </div>
              </div>

              <!-- First Name (editable) -->
              <div class="row mb-4">
                <label class="col-form-label col-lg-3">First Name</label>
                <div class="col-lg-9">
                  <input class="form-control" type="text"
                         asp-for="FirstName" />
                </div>
              </div>

              <!-- Last Name (editable) -->
              <div class="row mb-4">
                <label class="col-form-label col-lg-3">Last Name</label>
                <div class="col-lg-9">
                  <input class="form-control" type="text"
                         asp-for="LastName" />
                </div>
              </div>

              <!-- Employee (JDE) Number -->
              <div class="row mb-4">
                <label class="col-form-label col-lg-3">Employee Number</label>
                <div class="col-lg-9">
                  <input class="form-control" type="text"
                         asp-for="JDENumber" />
                </div>
              </div>

              <!-- Job Number -->
              <div class="row mb-4">
                <label class="col-form-label col-lg-3">Job Number</label>
                <div class="col-lg-9">
                  <input class="form-control" type="text"
                         asp-for="JobNumber" />
                </div>
              </div>

            </div> <!-- repeater item -->
          </div>   <!-- repeater list -->

          <!-- Save Button -->
          <div class="row justify-content-end">
            <div class="col-lg-10">
              <button type="submit"
                      onclick="return SubmitForm();"
                      id="saveDocument"
                      class="btn btn-primary">
                Save
              </button>
            </div>
          </div>

        </div> <!-- card-body -->
      </div>   <!-- card -->
    </div>
  </div>
}

Field Summary

Property Label Editable? HTML Attribute
CarrierName Carrier Name ❌ Read‑only readonly
InvoiceYearMonth Invoice Year Month ❌ Read‑only readonly
PhoneNumber Phone Number ❌ Read‑only readonly
FirstName First Name ✅
LastName Last Name ✅
JDENumber Employee Number ✅
JobNumber Job Number ✅

⚙️ Scripts & Client‑Side Behavior

All scripts are included at the bottom of the view to optimize page load:

<script src="~/js/app.js"></script>
<script src="~/libs/jquery/jquery.min.js"></script>
<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 src="~/libs/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
<script src="~/libs/tinymce/tinymce.min.js"></script>
<script src="~/libs/jquery.repeater/jquery.repeater.min.js"></script>
<script src="~/js/pages/task-create.init.js"></script>
  • SubmitForm(): Client-side confirmation or validation before actual form submit.
  • Datepicker & Repeater: Prepared for advanced scenarios (e.g., dynamic date fields, repeating sections), though not active in current fields.

🔗 Controller & API Endpoints

  • Form Submission:
    [HttpPost]
    public IActionResult Edit(BillingViewModel model)
    {
        if (!ModelState.IsValid)
        {
            // Return view with validation messages
        }
        // Update invoice record in database
        return RedirectToAction("Index");
    }
    
  • Route: POST /Billing/Edit
  • Success Path: Redirects to Index or another confirmation page.
  • Validation: Server‑side checks via DataAnnotations on the BillingViewModel.

🐞 Error Handling & Validation

  • Server‑Side
    • DataAnnotations on BillingViewModel (e.g., [Required], [StringLength]) trigger ModelState.IsValid checks.
    • On failure, the same view is returned with ViewData["Title"] and error messages displayed near inputs (via asp-validation-for if used).
  • Client‑Side
    • HTML5 validation attributes (required, maxlength, etc.) can be added to inputs.
    • SubmitForm() can block submission if custom checks fail.

🔄 UML Diagram

classDiagram
    BillingViewModel <|-- Edit.cshtml : binds to
    BillingController o-- BillingViewModel : accepts in POST Edit()
    Edit.cshtml --> BillingController : POST /Billing/Edit

    class BillingViewModel {
      +string CarrierName
      +string InvoiceYearMonth
      +string PhoneNumber
      +string FirstName
      +string LastName
      +string JDENumber
      +string JobNumber
    }

Legend

  • Edit.cshtml ↔️ BillingViewModel: Data Binding
  • Edit.cshtml → BillingController: Form POST

💻 Sample Usage & Code Snippets

1. Rendering the Edit View in Controller (GET)

[HttpGet]
public IActionResult Edit(int invoiceId)
{
    // Fetch invoice from DB
    var invoice = _invoiceService.GetById(invoiceId);
    var vm = new BillingViewModel {
        CarrierName = invoice.Carrier,
        InvoiceYearMonth = invoice.YearMonth,
        PhoneNumber = invoice.Phone,
        FirstName = invoice.CustomerFirstName,
        LastName = invoice.CustomerLastName,
        JDENumber = invoice.JDENumber,
        JobNumber = invoice.JobNumber
    };
    return View(vm);
}

2. Submitting the Form (POST)

<form asp-action="Edit" asp-controller="Billing" method="post">
    <!-- fields as shown above -->
    <button type="submit">Save</button>
</form>

3. Server‑Side Update Logic

[HttpPost]
public IActionResult Edit(BillingViewModel model)
{
    if (!ModelState.IsValid) return View(model);
    // Map VM back to domain entity
    _invoiceService.Update(new Invoice {
        Id = model.Id,
        CustomerFirstName = model.FirstName,
        CustomerLastName = model.LastName,
        JDENumber = model.JDENumber,
        JobNumber = model.JobNumber
    });
    return RedirectToAction("Index");
}

✅ Conclusion

The Edit.cshtml view is a crucial piece of the billing workflow in the IrbyImaging application. It

  • Leverages ASP.NET Core MVC and Razor syntax for strong typing and server‑side integration
  • Uses Bootstrap for responsive layout and styling
  • Integrates third‑party scripts (e.g., Datepicker, TinyMCE, Repeater) for future enhancements
  • Provides a clean, user‑friendly interface to read and update invoice details

🚀 With this documentation, developers and maintainers can quickly understand the form’s structure, dependencies, and how it interacts with the backend. Happy coding!