Skip to main content

MVC Architecture

Introduction

Damsy ERP uses ASP.NET MVC 5 with a hybrid structure: root controllers handle login, dashboard, and shared masters, while MVC Areas isolate each business module (Payroll, Bills, Stock, and others). Each Area has its own controllers, views, and typically a dedicated layout shell.

Purpose

This page documents how the presentation layer is organized so you can add screens, wire navigation, and apply the correct layout and asset bundle for a module.

When to Use

Consult this page when you:

  • Add a new controller or view inside a module
  • Choose or create a layout for a new Area screen
  • Link from the dashboard or sidebar to a module route
  • Debug routing issues (/Payroll/... vs /Login/...)

How It Works

Root vs Area structure

Registered Areas

Each Area is registered via *AreaRegistration.cs under DamsyERP.UI/Areas/<AreaName>/ and discovered at startup by AreaRegistration.RegisterAllAreas().

Area folderRoute prefixPrimary dashboard controller
Payroll/Payroll/...PayrollDashboardController
Registration/Registration/...RegistrationDashboardController
Bills/Bills/...BillsDashboardController
Stock/Stock/...StockDashboardController
Sales/Sales/...SalesDashboardController
ESS/ESS/...EssDashboardController
Adminisration/Adminisration/...UserDashBoardController
AttendancePunching/AttendancePunching/...AttendanceDashboardController
Operation/Operation/...OperationDashboardController
ManagmentDashBoard/ManagmentDashBoard/...ManagmentDashBoardController
ContractedRates/ContractedRates/...ContractedDashboardController
VerificationAndApproval/VerificationAndApproval/...VerificationApprovalDashboardController

Area URL pattern:

{area}/{controller}/{action}/{id}

Controllers

Root controllers (DamsyERP.UI/Controllers/):

  • LoginController — authentication, module redirect, logout
  • DashboardController — home tile hub after login
  • EmployeeMController — shared employee master (used across modules via Session["Module"])
  • ManageErrorController — global error pages

Area controllers live under Areas/<Area>/Controllers/ and follow standard MVC naming (PayrollDashboardController, CreateBillsController, etc.).

Typical controller action pattern:

public ActionResult Index()
{
if (string.IsNullOrEmpty(Convert.ToString(Session["CompID"])))
return RedirectToAction("UserLogin", "Login", new { Area = "" });

// DAL calls, ViewBag/ViewData, return View()
}

Views and layouts

Razor views are co-located with their Area:

Areas/Payroll/Views/
PayrollDashboard/Index.cshtml
Shared/_LayoutPayroll.cshtml
ManageError/Index.cshtml

Module layouts wrap every page in a consistent shell (sidebar, header, module CSS):

ModuleLayout file
Payroll_LayoutPayroll.cshtml
Registration_RegistrationLayout.cshtml
Bills_BillsLayout.cshtml
Stock_StockLayout.cshtml
ESS_EssLayout.cshtml
Attendance Punching_AttPunchingLayout.cshtml
Management Dashboard_ManagmentDashBoardLayout.cshtml
Contracted Rates_ContractedRatesLayout.cshtml
Verification & Approval`_LayoutVerificationApproval.cshtml

Root shared partials (Views/Shared/):

  • _Layout.cshtml — base shell for login and dashboard
  • _HeaderLayout.cshtml — header chrome
  • _SidebarBrand.cshtml, _SidebarMenuSearch.cshtml — sidebar branding and search

Views set layout in _ViewStart.cshtml or per-view:

@{
Layout = "~/Areas/Payroll/Views/Shared/_LayoutPayroll.cshtml";
}

app-assets

Static front-end assets live under DamsyERP.UI/app-assets/:

PathContents
css/shell-modern.cssGlobal shell styling
css/sidebar-unified.cssUnified sidebar across modules
css/payroll-modern.css, payroll-dashboard.cssPayroll-specific styling
js/Shared JavaScript utilities

Module views reference these via ~/app-assets/... paths. Keep module-specific CSS alongside generic shell styles rather than duplicating layout markup.

Web Forms report viewers

Crystal Reports use legacy Web Forms .aspx pages inside Areas (for example Areas/Payroll/PayRollViewerForm/PayRollReportsForm.aspx). MVC RouteConfig ignores Crystal image handler routes. See Crystal Reports.

Developer Notes

  • UserLogin vs Index: Login GET is at /Login/Index; /Login/UserLogin redirects to Index for backward compatibility.
  • Shared employee screens: Root EmployeeMController uses Session["Module"] to determine which module initiated the screen.
  • Partial views for AJAX: Many modules return PartialView or JsonResult for DataTables and modal workflows.
  • Area-specific ManageError: Most Areas duplicate ManageErrorController and views so error pages retain module chrome.
Layout inheritance

When adding a new Payroll screen, place the view under Areas/Payroll/Views/<Controller>/ and rely on _ViewStart.cshtml to apply _LayoutPayroll automatically.

Examples

Linking to a Payroll action from a view

<a href="@Url.Action("Index", "SalaryProcess", new { area = "Payroll" })">
Salary Process
</a>

Redirect from root to an Area

return RedirectToAction("Index", "PayrollDashboard", new { area = "Payroll" });

ModuleManagement entry (from dashboard tile)

/Login/ModuleManagement?PageID=Payroll
→ RedirectToAction("Index", "PayrollDashboard", new { area = "Payroll" })

Important Notes

Preserve Area name typos

Routes Adminisration and ManagmentDashBoard are baked into URLs, AreaRegistration classes, and redirects. Renaming folders without a coordinated migration breaks production links.

Sales and Operation layouts

Sales and Operation modules may use shared or inline layout patterns. Check the specific controller's views for the active layout reference before assuming a _SalesLayout exists.

Common Mistakes

MistakeResult
Creating a view under Views/ instead of Areas/<Area>/Views/View not found for Area controller
Omitting area in Url.ActionLink resolves to root controller (404 or wrong screen)
Skipping CompID session checkUnauthenticated access or null reference in DAL
Adding SPA-style client routingConflicts with server-rendered MVC pattern used throughout

Next Steps