📘 BigBucketsViewModel Documentation


🚀 Index (Table of Contents)

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. View Models & Data Models
  4. Class Diagram (UML)
  5. Key Functional Areas
    5.1. Device Count Properties
    5.2. Filter Flags (ShouldInclude…)
    5.3. RequestList
    5.4. Additional Control Properties
  6. Helper Methods & Utilities
  7. Error Handling & Return Types
  8. API Endpoints Overview
  9. Third-Party Integrations
  10. Sample Code Blocks
  11. Usage Examples
  12. Conclusion

1. Overview & Purpose 📋

BigBucketsViewModel is a plain-old‑CLR‑object (POCO) used in the IrbyImaging.UI assembly to aggregate and transport grouped counts of device‐request “buckets” along with a list of open/in‑progress requests. Primarily designed for MVVM or ASP.NET MVC scenarios, it enables:

  • Summarization of requests by device type (phones, tablets, computers, etc.).
  • Dynamic inclusion/exclusion of columns via filter flags.
  • Passing both detailed lists and aggregate metrics from the controller (or view-model layer) to the view.

2. Dependencies & Technologies 🔧

Dependency Purpose
System Base .NET types (e.g., DateTime, string).
System.Collections.Generic Collection interfaces (ICollection<T>).
System.ComponentModel.DataAnnotations Display attributes for UI labels.

No external NuGet packages or third‑party SDKs are directly referenced in this file.


3. View Models & Data Models 🏷️

  • Namespace: IrbyImaging.ViewModels
  • Class: BigBucketsViewModel
  • Related ViewModel:
    • OpenAndInProgressRequestViewModel
      • Represents individual request details (ID, status, device type, etc.).
      • Note: Definition located in the same namespace; not shown here.

4. Class Diagram (UML) 💡

classDiagram
    class BigBucketsViewModel {
        +ICollection~OpenAndInProgressRequestViewModel~ RequestList
        +int NumberThatNeedPhones
        +int NumberThatNeedTablets
        +int NumberThatNeedComputers
        +int NumberThatNeedMiFi
        +int NumberThatNeedStarLink
        +int NumberThatNeedEnterprise
        +int NumberThatNeedSoftware
        +int NumberThatNeedSharedAccess
        +int NumberThatNeedIrbySystems
        +bool ShouldIncludePhones
        +bool ShouldIncludeTablets
        +bool ShouldIncludeComputers
        +bool ShouldIncludeMiFi
        +bool ShouldIncludeStarLink
        +bool ShouldIncludeEnterprise
        +bool ShouldIncludeSoftware
        +bool ShouldIncludeSharedAccess
        +bool ShouldIncludeIrbySystems
        -bool ShowAllColumns
        +DateTime RequestedInitialDate
        +bool ReviewAfter
        +DateTime? ReviewAfterDate
        +string ReviewReason
    }

5. Key Functional Areas 🔍

5.1. Device Count Properties

These integer properties hold the total counts of requests by category:

Property Description
NumberThatNeedPhones Count of phone requests 📱
NumberThatNeedTablets Count of tablet requests 📟
NumberThatNeedComputers Count of computer requests 💻
NumberThatNeedMiFi Count of MiFi hotspot requests 📶
NumberThatNeedStarLink Count of StarLink requests 🌐
NumberThatNeedEnterprise Count of enterprise-level requests 🏢
NumberThatNeedSoftware Count of software license requests 🖥️
NumberThatNeedSharedAccess Count of shared access requests 🔗
NumberThatNeedIrbySystems Count of Irby systems requests ⚙️

5.2. Filter Flags (ShouldInclude…)

Boolean flags marked with [Display(Name = "...")] to control which columns are shown in the UI:

Property Display Label Purpose
ShouldIncludePhones  Phones Show/Hide phone column
ShouldIncludeTablets  Tablets Show/Hide tablet column
ShouldIncludeComputers  Computers Show/Hide computer column
ShouldIncludeMiFi  MiFi Show/Hide MiFi column
ShouldIncludeStarLink  StarLink Show/Hide StarLink column
ShouldIncludeEnterprise  Enterprise Show/Hide enterprise column
ShouldIncludeSoftware  Software Show/Hide software column
ShouldIncludeSharedAccess  Shared Access Show/Hide shared access column
ShouldIncludeIrbySystems  Irby Systems Show/Hide Irby systems column

Private:

  • ShowAllColumns (bool) – internal flag, not exposed in UI.

5.3. RequestList

public ICollection<OpenAndInProgressRequestViewModel> RequestList { get; set; }
  • Holds: Detailed items (one per open/in-process request).
  • Purpose: Enables tabular or detailed list rendering alongside aggregate counts.

5.4. Additional Control Properties

Property Type Description
RequestedInitialDate DateTime Start date for filtering requests
ReviewAfter bool Indicates if review-by-date filter is active
ReviewAfterDate DateTime? Optional “review after” cutoff date
ReviewReason string Textual explanation for review filter

6. Helper Methods & Utilities 🔨

None.
This view‐model contains only auto‐implemented properties. Business logic, calculations, and mapping should reside in services or controllers.


7. Error Handling & Return Types ❗

  • Error Handling: N/A (no methods).
  • Return Types: N/A.

8. API Endpoints Overview 🌐

No direct API definitions in this file.
Typically consumed by:

  • ASP.NET MVC Controller actions returning a View(model).
  • MVVM frameworks (WPF, Xamarin) binding properties to the UI.

9. Third-Party Integrations 🔗

  • DataAnnotations for UI-friendly labels ([Display(Name = "...")]).
  • Compatible with:
    • ASP.NET MVC / Razor Pages.
    • Blazor (via @bind-).
    • WPF / Xamarin.Forms (via XAML binding).

10. Sample Code Blocks 📑

10.1. Instantiating in a Controller

public IActionResult BigBuckets(DateTime date, bool includePhones = true, /*…*/)
{
    // 1. Fetch data from service/repository
    var allRequests = _requestService.GetOpenAndInProgress(date);

    // 2. Build view model
    var vm = new BigBucketsViewModel
    {
        RequestList = allRequests
                        .Select(r => new OpenAndInProgressRequestViewModel {
                            Id = r.Id,
                            DeviceType = r.DeviceType,
                            DateRequested = r.DateRequested
                            // …
                        })
                        .ToList(),

        // Aggregate counts
        NumberThatNeedPhones      = allRequests.Count(r => r.DeviceType == DeviceType.Phone),
        NumberThatNeedTablets     = allRequests.Count(r => r.DeviceType == DeviceType.Tablet),
        // … other counts

        // User‑selected filters
        ShouldIncludePhones       = includePhones,
        ShouldIncludeTablets      = /* from query */,
        // …

        RequestedInitialDate      = date,
        ReviewAfter               = false
    };

    return View(vm);
}

10.2. Rendering in Razor View

@model IrbyImaging.ViewModels.BigBucketsViewModel

<form asp-action="BigBuckets" method="get">
    <label>
        <input asp-for="ShouldIncludePhones" type="checkbox" />
        @Html.DisplayNameFor(m => m.ShouldIncludePhones)
    </label>
    <!-- … other filters … -->
    <button type="submit">Apply Filters</button>
</form>

<table class="table">
    <thead>
        <tr>
            @if (Model.ShouldIncludePhones)      { <th>Phones</th> }
            @if (Model.ShouldIncludeTablets)     { <th>Tablets</th> }
            <!-- … -->
        </tr>
    </thead>
    <tbody>
        <tr>
            @if (Model.ShouldIncludePhones)      { <td>@Model.NumberThatNeedPhones</td> }
            @if (Model.ShouldIncludeTablets)     { <td>@Model.NumberThatNeedTablets</td> }
            <!-- … -->
        </tr>
    </tbody>
</table>

11. Usage Examples 🎯

  1. Dashboards: Show “big bucket” summary at the top of an equipment‑request page.
  2. Filtering: Let end-users toggle columns on/off without recalculating on server.
  3. Paging & Details: Bind RequestList to a secondary grid for drill-downs.

12. Conclusion 🎉

The BigBucketsViewModel is a lightweight, configuration-driven container tailor‑made for summarizing and displaying request data by device categories. Its simplicity (auto-properties only) ensures that all business logic remains in your service layer or controllers, while the view-model remains purely a data carrier optimized for UI rendering.

Happy coding! 🖥️📊🚀