📋 SystemAccessUser Model Documentation

Welcome to the detailed documentation of the SystemAccessUser model class in the IrbyImaging.UI.Models namespace. This guide covers everything from the model’s purpose and properties to usage examples, UML diagrams, integration points, and best practices.


📑 Table of Contents

  1. 🔍 Overview & Purpose
  2. 🛠️ Dependencies & Technologies
  3. 📦 Data Model: SystemAccessUser
  4. 📋 Usage Examples
  5. 🔗 Integration Points
  6. ⚙️ Conventions & Best Practices
  7. 🛑 Error Handling & Validation
  8. 🚀 Conclusion

🔍 Overview & Purpose

The SystemAccessUser class is a plain-old CLR object (POCO) used in the UI layer of the IrbyImaging application. It serves as a ViewModel or DTO that encapsulates all relevant user data required for:

  • Managing system access and permissions
  • Displaying user profiles in the UI
  • Transferring user data between layers (UI ⇄ API ⇄ Services)

By centralizing user-related properties in one model, we simplify data binding, serialization, and validation in our ASP.NET (Core) applications.


🛠️ Dependencies & Technologies

  • Language: C#
  • Framework: .NET Framework / .NET Core
  • UI Technology: ASP.NET MVC or Razor Pages
  • Serialization: JSON (via System.Text.Json or Newtonsoft.Json)
  • Mapping (Optional): AutoMapper for DTO ⇄ ViewModel conversion
  • ORM (Optional): Entity Framework or Dapper (for back-end data access)

📦 Data Model: SystemAccessUser

📝 Properties Detail

Property Type Description
EmployeeId string Unique key for the employee (e.g., GUID).
EmployeeNumber string Human-friendly employee number (e.g., "E12345").
FirstName string Employee’s first (given) name.
MiddleName string Employee’s middle name (optional).
LastName string Employee’s last (family) name.
DepartmentId string Identifier for the department the user belongs to.
DepartmentName string Friendly name of the department (e.g., "Radiology").
RoleId string Identifier for the user’s security role.
RoleName string Name of the role (e.g., "Technician", "Manager").
Title string Official job title (e.g., "Senior Imaging Technician").
Job string Job code or description for classification.
HireDate DateTime? Date the employee was hired (nullable if unknown).
TerminationDate DateTime? Date the employee was terminated (nullable).
RehireDate DateTime? Date the employee was rehired (nullable).
WorkEmail string Company email address (e.g., [email protected]).
UARApprover bool Flag indicating whether the user has rights to approve UAR (User Access Requests).

📊 UML Class Diagram

@startuml
class SystemAccessUser {
  +string EmployeeId
  +string EmployeeNumber
  +string FirstName
  +string MiddleName
  +string LastName
  +string DepartmentId
  +string DepartmentName
  +string RoleId
  +string RoleName
  +string Title
  +string Job
  +DateTime? HireDate
  +DateTime? TerminationDate
  +DateTime? RehireDate
  +string WorkEmail
  +bool UARApprover
}
@enduml

📋 Usage Examples

✏️ 1. Instantiating a SystemAccessUser

using IrbyImaging.UI.Models;
using System;

namespace Example
{
    class Program
    {
        static void Main()
        {
            var user = new SystemAccessUser
            {
                EmployeeId       = Guid.NewGuid().ToString(),
                EmployeeNumber   = "E12345",
                FirstName        = "Jane",
                MiddleName       = "A.",
                LastName         = "Doe",
                DepartmentId     = "D10",
                DepartmentName   = "Imaging",
                RoleId           = "R01",
                RoleName         = "Technician",
                Title            = "Senior Imaging Technician",
                Job              = "IMG-TECH",
                HireDate         = new DateTime(2015, 6, 1),
                WorkEmail        = "[email protected]",
                UARApprover      = true
            };
            
            Console.WriteLine($"User: {user.FirstName} {user.LastName}, Dept: {user.DepartmentName}");
        }
    }
}

🌐 2. Mapping from DTO / API Response

// Controller action in ASP.NET Core MVC
[HttpGet("{id}")]
public async Task<IActionResult> Details(string id)
{
    // Service returns a DTO (e.g., from EF or external API)
    var dto = await _userService.GetUserDtoAsync(id);

    // Map DTO → ViewModel (manually or via AutoMapper)
    var viewModel = new SystemAccessUser
    {
        EmployeeId     = dto.Id,
        EmployeeNumber = dto.Number,
        FirstName      = dto.FirstName,
        LastName       = dto.LastName,
        DepartmentId   = dto.DeptId,
        DepartmentName = dto.DeptName,
        RoleId         = dto.RoleId,
        RoleName       = dto.RoleName,
        HireDate       = dto.HiredOn,
        // … other properties …
    };

    return View(viewModel);
}

📖 3. Display in ASP.NET MVC Razor View

@model IrbyImaging.UI.Models.SystemAccessUser

<h2>User Profile</h2>
<table class="table">
    <tr>
        <th>Name:</th>
        <td>@Model.FirstName @Model.MiddleName @Model.LastName</td>
    </tr>
    <tr>
        <th>Department:</th>
        <td>@Model.DepartmentName</td>
    </tr>
    <tr>
        <th>Role:</th>
        <td>@Model.RoleName</td>
    </tr>
    <tr>
        <th>Hire Date:</th>
        <td>@Model.HireDate?.ToString("MM/dd/yyyy")</td>
    </tr>
    <tr>
        <th>Email:</th>
        <td><a href="mailto:@Model.WorkEmail">@Model.WorkEmail</a></td>
    </tr>
    <tr>
        <th>UAR Approver:</th>
        <td>@(Model.UARApprover ? "✅ Yes" : "❌ No")</td>
    </tr>
</table>

🔗 Integration Points

  • Controllers & Views: Used as the ViewModel for user-related pages.
  • Web APIs: Serialized to/from JSON for RESTful endpoints.
  • Service Layer: Mapped from or to service-layer DTOs.
  • Data Access: Backed by Entity Framework / Dapper for CRUD operations (if extended).
  • AutoMapper (Optional): Simplifies mapping between Database Entities ⇄ ViewModel.

⚙️ Conventions & Best Practices

  • PascalCase naming for properties.
  • Use nullable DateTime? for optional dates to differentiate “unknown” vs. “default” values.
  • Keep the model lightweight—no behavior (methods) here; business logic belongs in services.
  • Annotate with DataAnnotations ([Required], [EmailAddress], etc.) when you add validation to the UI.
  • Leverage AutoMapper profiles to centralize mapping rules.

🛑 Error Handling & Validation

Although this class has no built‑in validation, consider:

  • Applying DataAnnotations:
    [Required]
    public string EmployeeNumber { get; set; }
    
    [EmailAddress]
    public string WorkEmail { get; set; }
    
  • Validating in controllers or using FluentValidation.
  • Checking EmployeeId, EmployeeNumber, and WorkEmail are not null or empty before persisting.
  • Handling DateTime? conversion errors in your JSON serializer settings.

🚀 Conclusion

The SystemAccessUser model is a crucial building block in IrbyImaging’s UI architecture. It centralizes all user-related data required for rendering profiles, processing access requests, and integrating with back-end services or APIs. By adhering to best practices—such as keeping models behavior‑free, using DataAnnotations, and leveraging AutoMapper—you ensure a clean, maintainable codebase that seamlessly connects UI, API, and data layers.


😀 Happy coding!