📦 RequestOption.cs Documentation
Assembly: IrbyImaging.DomainClasses
Author: kvamshi
Created: 05-17-2022
Last Modified: 05-17-2022
📑 Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Data Model: RequestOption
- 3.1 Class-Level Attributes
- 3.2 Properties
- 3.3 Database Mapping
- UML Diagram
- Sample Code Blocks & Usage Examples
- Conclusion
🔍 Overview & Purpose
The RequestOption class represents a configurable option in the Irby Imaging system—such as a print setting, image filter, or service add‑on—that can be requested by a user. Each option is stored in the database with its type, description, cost, and approval metadata. This domain entity is used throughout the application for:
- Displaying available options to end‑users
- Capturing user selections in job requests
- Enforcing business rules (e.g., approval workflows)
- Persisting option data via Entity Framework Core
⚙️ Dependencies & Technologies
| Technology / Library | Purpose |
|---|---|
| .NET 6+ / .NET Core | Runtime & language |
| Entity Framework Core | ORM for database mapping |
System.ComponentModel.DataAnnotations |
Declarative validation & metadata |
IrbyImaging.Utility |
Defines supporting types (e.g., RequestOptionType) |
📋 Data Model: RequestOption
using IrbyImaging.Utility;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace IrbyImaging.DomainClasses
{
[Table("RequestOption", Schema = "irby")]
public class RequestOption
{
[Key]
public Guid Id { get; set; }
public RequestOptionType Type { get; set; }
public string Item { get; set; }
public string Cost { get; set; }
[Display(Name = "Approval Required")]
public bool ApprovalRequired { get; set; }
[Display(Name = "Approval Department")]
public string ApprovalDepartment { get; set; }
}
}
3.1 Class-Level Attributes
[Table("RequestOption", Schema = "irby")]
Maps this class to the irby.RequestOption table in the database.
3.2 Properties
| Property | Type | Description |
|---|---|---|
| Id | Guid |
Primary key. Uniquely identifies each option. |
| Type | RequestOptionType |
Category of the option (e.g., Filter, PrintResolution, Frame). Defined in IrbyImaging.Utility. |
| Item | string |
Human‑readable name or description of the option (e.g., “Sepia Tone”). |
| Cost | string |
Price or cost of the option. Stored as string to preserve formatting (e.g., “$15.00”). |
| ApprovalRequired | bool |
Indicates whether selecting this option triggers an approval workflow. |
| ApprovalDepartment | string |
Department responsible for approving this option, if required (e.g., “Legal”). |
3.3 Database Mapping
- Schema: irby
- Table: RequestOption
- Primary Key:
Id - Annotations:
[Key]marksIdas the primary key.[Display(Name = "...")]controls label text in UI forms.
🧩 UML Diagram
classDiagram
direction TB
class RequestOption {
<<Entity>>
+Guid Id
+RequestOptionType Type
+string Item
+string Cost
+bool ApprovalRequired
+string ApprovalDepartment
}
💡 Sample Code Blocks & Usage Examples
1. Defining the DbContext
using IrbyImaging.DomainClasses;
using Microsoft.EntityFrameworkCore;
public class ImagingContext : DbContext
{
public DbSet<RequestOption> RequestOptions { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder
.UseSqlServer("YourConnectionStringHere");
}
}
2. Creating & Saving a New Option
var context = new ImagingContext();
var newOption = new RequestOption
{
Id = Guid.NewGuid(),
Type = RequestOptionType.ColorCorrection,
Item = "Brightness/Contrast Adjustment",
Cost = "$12.50",
ApprovalRequired = false,
ApprovalDepartment = null
};
context.RequestOptions.Add(newOption);
await context.SaveChangesAsync();
Console.WriteLine("✔️ RequestOption saved successfully!");
3. Querying Options Requiring Approval
var pendingApprovals = await context.RequestOptions
.Where(opt => opt.ApprovalRequired)
.ToListAsync();
foreach (var option in pendingApprovals)
{
Console.WriteLine($"🔔 {option.Item} needs approval from {option.ApprovalDepartment}");
}
🏁 Conclusion
The RequestOption domain class provides a clean, EF‑friendly representation of configurable imaging options within the Irby platform. By leveraging data annotations, it ensures proper database mapping, UI display hints, and ease of querying. This entity stands at the core of any feature that involves presenting, selecting, or approving supplemental imaging services or filters. With the provided setup and examples, you can seamlessly integrate it into your data layer and start building robust request workflows in minutes.
Happy coding! 🚀