📦 IrbyImaging.UI.Models.ShippingAddress.cs Documentation


📑 Table of Contents

  1. Overview & Purpose
  2. Namespace & Assembly
  3. Class Diagram (UML)
  4. Data Model: ShippingAddress
    4.1. Properties
  5. Usage Scenarios & Examples
  6. Dependencies & Technologies
  7. Integration Points
  8. Error Handling & Validation
  9. Best Practices & Notes
  10. Conclusion

1. Overview & Purpose

🌟 ShippingAddress.cs defines a simple Plain Old CLR Object (POCO) to represent a shipping address in the IrbyImaging.UI project.
This model encapsulates all the typical address fields required to ship physical goods:

  • Street
  • City
  • State
  • Zip code

Intent:

  • Provide a standard data container for UI forms, API requests/responses, and data binding.
  • Ensure consistency whenever an address is needed within the IrbyImaging UI.

2. Namespace & Assembly

Aspect Details
Assembly IrbyImaging.UI
Namespace IrbyImaging.UI.Models
Author kvamshi
Created On 05-17-2022
Last Updated 05-17-2022
namespace IrbyImaging.UI.Models
{
    public class ShippingAddress
    {
        // ...
    }
}

3. Class Diagram (UML)

@startuml
' ShippingAddress Class Diagram
class ShippingAddress {
    +string StreetAddress { get; set; }
    +string City          { get; set; }
    +string State         { get; set; }
    +string Zip           { get; set; }
}
@enduml

📈 Render the above PlantUML snippet in any UML viewer to visualize the class structure.


4. Data Model: ShippingAddress

This class exposes four auto-implemented properties, each representing a segment of a postal address.

4.1. Properties

Property Name Type Description Required / Optional
StreetAddress string The street portion of the address (e.g., 123 Main St). Required
City string The city name. Required
State string The state, province, or region. Required
Zip string The postal or ZIP code. Required

💡 All properties are simple string types. Consider applying validation attributes (e.g., [Required], [StringLength]) in a ViewModel or using FluentValidation for more robust checks.


5. Usage Scenarios & Examples

5.1. Creating a Shipping Address

using IrbyImaging.UI.Models;

public void ProcessOrder()
{
    // Instantiate and populate a ShippingAddress
    var shipAddress = new ShippingAddress
    {
        StreetAddress = "456 Elm Street",
        City          = "Seattle",
        State         = "WA",
        Zip           = "98101"
    };

    // Pass the model to your service or API
    OrderService.CreateOrder(customerId, shipAddress);
}

5.2. Data Binding in ASP.NET MVC / Blazor

@model IrbyImaging.UI.Models.ShippingAddress

<form method="post">
    <label>Street:</label>
    <input asp-for="StreetAddress" class="form-control" />

    <label>City:</label>
    <input asp-for="City" class="form-control" />

    <label>State:</label>
    <input asp-for="State" class="form-control" />

    <label>ZIP Code:</label>
    <input asp-for="Zip" class="form-control" />

    <button type="submit">Submit</button>
</form>

6. Dependencies & Technologies

  • Language: C# 8.0+
  • Framework: .NET Framework / .NET Core / .NET 5+ (compatible)
  • Project Type: Class Library inside IrbyImaging.UI solution
  • No External NuGet Packages are directly required by this model.

7. Integration Points

  • Order Processing Service: Passed as part of an OrderRequest DTO.
  • UI Forms & ViewModels: Bound directly in Razor / Blazor pages.
  • Web APIs: Serialized to JSON for remote shipping calculators or third-party logistics integrations.
{
  "streetAddress": "789 Pine St",
  "city": "Portland",
  "state": "OR",
  "zip": "97205"
}

8. Error Handling & Validation

As a pure data model, ShippingAddress itself has no built‑in validation or error handling.
Recommended Approaches:

  • Use [DataAnnotations] in a corresponding ViewModel:
    public class ShippingAddressViewModel
    {
        [Required, StringLength(100)]
        public string StreetAddress { get; set; }
    
        [Required, StringLength(50)]
        public string City { get; set; }
    
        [Required, StringLength(20)]
        public string State { get; set; }
    
        [Required, RegularExpression(@"\d{5}(-\d{4})?", ErrorMessage = "Invalid ZIP code.")]
        public string Zip { get; set; }
    }
    
  • Consider FluentValidation for richer rules and conditional logic.

9. Best Practices & Notes

  • 🔄 Immutability
    If you require thread‑safety or immutable instances, refactor to use init accessors (C# 9+):
    public string StreetAddress { get; init; }
    
  • 🇮🇳 International Addresses
    This model is US-centric. For global shipping, consider extending with Country, Province, PostalCode variations.
  • 🔗 Mapping
    Use AutoMapper or manual mapping when converting between domain models and UI models.

10. Conclusion

🎯 ShippingAddress.cs is a foundational data model within the IrbyImaging.UI library that standardizes how shipping addresses are represented throughout the application.

By encapsulating address fields in one reusable class, you ensure consistency in UI forms, API payloads, and service calls. While simple, it provides a clear contract between client‑side code and back‑end services.

🚀 Next Steps:

  • Apply validation in your ViewModels or DTOs.
  • Extend for internationalization if needed.
  • Integrate with shipping calculators or third‑party logistic APIs using serialized JSON objects.

Happy coding! 🛠️🚚✨