📄 Documentation: CreateInvoice.cshtml

Location: IrbyImaging/Views/Billing/CreateInvoice.cshtml
Purpose: Razor view for creating a new Invoice record in the Billing module.


📚 Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. File Structure
  4. View Model & Data Model
  5. Detailed Sections
    5.1 Layout & Page Title
    5.2 CSS Styles Section
    5.3 The Form & Bindings
    5.4 Form Fields & ASP.NET Tag Helpers
    5.5 Submit Button & Client‐Side Script
    5.6 JavaScript Includes & Plugins
  6. Third-Party Integrations
  7. Helper Methods & Utilities
  8. Sample Controller Usage
  9. UML Diagrams
  10. Conclusion

1. Overview & Purpose

This Razor view renders a Create Invoice form for the BillingController. It displays a set of input fields (carrier selection, invoice date, customer details, job details, charge) bound to an InvoiceViewModel. When submitted, it posts back to BillingController.Create for validation and persistence.

Key Goals

  • 📑 Collect invoice metadata (month, year, carrier)
  • 🧑‍💼 Gather customer details (phone, name, employee number)
  • 🛠️ Capture job details (job number, job name, charge)
  • 🎨 Provide a clean, responsive UI leveraging Bootstrap & plugins

2. Dependencies & Technologies

Category Library / Tech
Framework ASP.NET Core MVC, Razor
CSS Framework Bootstrap 4/5
Datepicker bootstrap-datepicker
File Upload Dropzone.js (CSS only here)
Rich Text Editor TinyMCE (script loaded but unused in this view)
Form Repeater jQuery Repeater
JS Utilities jQuery, Bootstrap Bundle, MetisMenu, SimpleBar, Waves.js
Custom JS ~/js/app.js, ~/js/pages/task-create.init.js

3. File Structure

IrbyImaging/
└─ Views/
   └─ Billing/
      └─ CreateInvoice.cshtml
Shared/
└─ _ATSLayout.cshtml      ← Master layout
wwwroot/
└─ libs/
   ├─ bootstrap-datepicker/css/bootstrap-datepicker.min.css
   ├─ dropzone/min/dropzone.min.css
   ├─ jquery/jquery.min.js
   ├─ bootstrap/js/bootstrap.bundle.min.js
   └─ … (other libs)
└─ js/
   ├─ app.js
   └─ pages/task-create.init.js

4. View Model & Data Model

namespace IrbyImaging.UI.Models.Billing
{
    public class InvoiceViewModel
    {
        public int CarrierId { get; set; }
        public IEnumerable<SelectListItem> Carrier { get; set; }

        public Month InvoiceMonth { get; set; }   // Enum: January…December
        public int InvoiceYear { 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; }
        public string JobName     { get; set; }

        public decimal Charge     { get; set; }
    }

    public enum Month { January=1, February, …, December }
}
Property Type Description
CarrierId int Selected Carrier (dropdown)
Carrier IEnumerable<SelectListItem> List of carriers for the dropdown
InvoiceMonth Month (enum) Month selector (Jan–Dec)
InvoiceYear int Year of invoice
PhoneNumber string Customer phone
FirstName string Customer first name
LastName string Customer last name
JDENumber string Employee number
JobNumber string Internal job identifier
JobName string Descriptive job name
Charge decimal Invoice amount

5. Detailed Sections

5.1 Layout & Page Title

@{
    ViewData["Title"] = "Create";
    Layout = "~/Views/Shared/_ATSLayout.cshtml";
}
  • ViewData["Title"]: Sets the page title to “Create”
  • Layout: Inherits site‐wide header, nav and footer from _ATSLayout

5.2 CSS Styles Section

@section styles {
  <!-- datepicker css -->
  <link href="~/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet">
  <link href="~/libs/dropzone/min/dropzone.min.css" rel="stylesheet" type="text/css" />
}
  • Loads bootstrap-datepicker and dropzone CSS
  • Placed in the <head> via Razor’s @RenderSection("styles")

5.3 The Form & Bindings

@using (Html.BeginForm("Create", "Billing", FormMethod.Post)) {
  <!-- … form content … -->
}
  • Posts back to BillingController.Create(InvoiceViewModel model)
  • Method: POST
  • Enables MVC Tag Helpers for model binding (asp-for, asp-items)

5.4 Form Fields & ASP.NET Tag Helpers

Each field is bound with asp-for:

Label Tag Helper Example
Carrier <select asp-for="CarrierId" asp-items="@Model.Carrier">
Invoice Month <select asp-for="InvoiceMonth" asp-items="@Html.GetEnumSelectList<Month>()">
Invoice Year <input asp-for="InvoiceYear" type="text">
Phone Number <input asp-for="PhoneNumber" type="text">
First Name <input asp-for="FirstName" type="text">
Last Name <input asp-for="LastName" type="text">
Employee Number <input asp-for="JDENumber" type="text">
Job Number <input asp-for="JobNumber" type="text">
Job Name <input asp-for="JobName" type="text">
Charge <input asp-for="Charge" type="text">

Tip: ASP.NET Core automatically handles name, id, and value binding thanks to Tag Helpers.


5.5 Submit Button & Client-side Script

<button type="submit" onclick="return SubmitForm();" id="saveDocument" class="btn btn-primary">
  Create
</button>
  • onclick="SubmitForm()": Custom JavaScript (defined in app.js or task-create.init.js)
  • Should return true to allow form submission or false to cancel if validation fails.

5.6 JavaScript Includes & Plugins

<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>
  • app.js: Core site scripts
  • task-create.init.js: Initializes datepickers, repeaters, TinyMCE, etc.
  • Order matters: jQuery → Bootstrap → Plugins → Custom Init

6. Third-Party Integrations

  • bootstrap-datepicker: Renders calendar widget for date‐type inputs
  • Dropzone.css: Styles for potential drag‐and‐drop uploads (not enabled here)
  • TinyMCE: WYSIWYG editor loaded, ready for future rich‐text fields
  • jQuery Repeater: Allows dynamic repeatable form sections (outer-group in markup)

7. Helper Methods & Utilities

  • Html.GetEnumSelectList()
    • Generates <option> tags for an enum
    • Usage: @Html.GetEnumSelectList<IrbyImaging.UI.Models.Month>()
  • SubmitForm()
    • (Defined in app.js) Performs client‐side validation
    • Returns true / false to continue / abort form submission

8. Sample Controller Usage

public class BillingController : Controller
{
    // GET: Billing/Create
    public IActionResult Create()
    {
        var model = new InvoiceViewModel {
            Carrier = _carrierService.GetAll()
                     .Select(c=> new SelectListItem(c.Name, c.Id.ToString()))
        };
        return View("CreateInvoice", model);
    }

    // POST: Billing/Create
    [HttpPost]
    [ValidateAntiForgeryToken]
    public IActionResult Create(InvoiceViewModel model)
    {
        if (!ModelState.IsValid)
            return View("CreateInvoice", model);

        _billingService.SaveInvoice(model);
        return RedirectToAction("Index");
    }
}

9. UML Diagrams

9.1 Sequence Diagram

sequenceDiagram
    participant User
    participant Browser
    participant CreateInvoiceView
    participant BillingController
    participant BillingService
    participant Database

    User->>Browser: Navigate to /Billing/Create
    Browser->>CreateInvoiceView: GET request
    CreateInvoiceView->>User: Renders form HTML
    User->>CreateInvoiceView: Fills form & clicks Create
    CreateInvoiceView->>BillingController: POST InvoiceViewModel
    BillingController->>BillingService: SaveInvoice(model)
    BillingService->>Database: INSERT Invoice
    Database-->>BillingService: Success
    BillingService-->>BillingController: Success
    BillingController-->>Browser: Redirect to /Billing/Index

9.2 Class Diagram (ViewModel)

classDiagram
    class InvoiceViewModel {
        +int CarrierId
        +IEnumerable<SelectListItem> Carrier
        +Month InvoiceMonth
        +int InvoiceYear
        +string PhoneNumber
        +string FirstName
        +string LastName
        +string JDENumber
        +string JobNumber
        +string JobName
        +decimal Charge
    }

    class Month <<enumeration>> {
        January
        February
        ...
        December
    }

10. Conclusion

The CreateInvoice.cshtml view provides a structured, user‐friendly interface for entering billing data. Leveraging ASP.NET Core MVC Tag Helpers, Bootstrap, and various JS plugins, it delivers a responsive experience with minimal boilerplate. Its tight integration with InvoiceViewModel ensures strong-typing and easy validation.

🎉 You are now equipped to customize, extend, or integrate this form into your IrbyImaging application!