📑 LeaseDetails.cs Documentation


Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. Data Model: LeaseDetails
  4. Usage & Code Examples
  5. Best Practices & Notes
  6. Conclusion

1. Overview & Purpose

📌 LeaseDetails is a Domain Model representing the key attributes of a commercial or residential lease document in the Irby Imaging system.

  • It leverages Entity Framework Core (EF Core) for ORM (Object‑Relational Mapping).
  • Maps to the database table irby.LeaseDetails.
  • Central to storing and retrieving metadata about lease documents (e.g., rent amounts, dates, locations).

2. Dependencies & Technologies

Technology / Package Purpose
Microsoft.EntityFrameworkCore EF Core ORM
System.ComponentModel.DataAnnotations Data annotation attributes (Key, Table)
System.ComponentModel.DataAnnotations.Schema Table/Column mapping

Note: Ensure your project references EF Core NuGet packages and has proper DB connection strings in appsettings.json.


3. Data Model: LeaseDetails

Entity Mapping

[Table("LeaseDetails", Schema = "irby")]
public class LeaseDetails
{
    [Key]
    public Guid DocumentImageId { get; set; }
    // ... other properties ...
}
  • Table Attribute: Maps this class to the irby.LeaseDetails table.
  • Key Attribute: DocumentImageId is the Primary Key (non-nullable Guid).

Property Reference Table

Property Name Type Nullable Description
DocumentImageId Guid No Unique ID linking to the document image.
City string Yes City where the property is located.
County string Yes County of the lease property.
DocumentName string Yes Original file name of the lease document.
ExpirationDate string Yes Lease expiration date (e.g., "2025-12-31").
FullyExecuted string Yes Flag or date indicating full execution.
JobNumber string Yes Internal job/ticket number for processing.
LandLord string Yes Name of the landlord entity.
LeaseCode string Yes Internal code/classification for the lease.
LeaseCommencementDate string Yes Start date of the lease term.
LeasePurpose string Yes Purpose (e.g., office, retail).
LeaseTerm string Yes Duration of the lease (e.g., "5 years").
MonthlyAVTax decimal? Yes Monthly assessed value tax amount.
MonthlyBaseRent decimal? Yes Monthly base rent.
MonthlyInsurancePayment decimal? Yes Monthly insurance cost.
MonthlySalesTax decimal? Yes Monthly sales tax.
MonthlyTotalCost decimal? Yes Sum of monthly costs (rent + taxes + insurance).
QuantaReviewed string Yes Reviewer initials or flag.
State string Yes State/province abbreviation.
StreetAddress string Yes Full street address.
SubjectToEscalation string Yes Escalation clause indicator.
Director string Yes Name of the managing director.
ZipCode string Yes Postal code.

UML Class Diagram

classDiagram
    class LeaseDetails {
        «Table("LeaseDetails", Schema="irby")»
        +Guid DocumentImageId <<Key>>
        +string City
        +string County
        +string DocumentName
        +string ExpirationDate
        +string FullyExecuted
        +string JobNumber
        +string LandLord
        +string LeaseCode
        +string LeaseCommencementDate
        +string LeasePurpose
        +string LeaseTerm
        +decimal? MonthlyAVTax
        +decimal? MonthlyBaseRent
        +decimal? MonthlyInsurancePayment
        +decimal? MonthlySalesTax
        +decimal? MonthlyTotalCost
        +string QuantaReviewed
        +string State
        +string StreetAddress
        +string SubjectToEscalation
        +string Director
        +string ZipCode
    }

4. Usage & Code Examples

Integrating into DbContext

public class IrbyImagingContext : DbContext
{
    public IrbyImagingContext(DbContextOptions<IrbyImagingContext> options)
        : base(options) { }

    public DbSet<LeaseDetails> LeaseDetails { get; set; }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<LeaseDetails>()
            .ToTable("LeaseDetails", schema: "irby");
        // Additional fluent configuration...
    }
}

Pro Tip: Use Migrations to scaffold database schema changes:

dotnet ef migrations add AddLeaseDetails
dotnet ef database update

CRUD Operations

Create a Record

var lease = new LeaseDetails
{
    DocumentImageId = Guid.NewGuid(),
    City = "Austin",
    State = "TX",
    MonthlyBaseRent = 1500.00m,
    LeaseCommencementDate = "2023-01-01",
    ExpirationDate = "2028-01-01"
};

context.LeaseDetails.Add(lease);
await context.SaveChangesAsync();

Read Records

var activeLeases = await context.LeaseDetails
    .Where(l => l.ExpirationDate.CompareTo("2023-12-31") > 0)
    .ToListAsync();

Update a Record

var lease = await context.LeaseDetails.FindAsync(documentImageId);
lease.MonthlySalesTax = 75.00m;
await context.SaveChangesAsync();

Delete a Record

var lease = new LeaseDetails { DocumentImageId = guidToDelete };
context.LeaseDetails.Remove(lease);
await context.SaveChangesAsync();

5. Best Practices & Notes

  • 📌 Data Types: Consider switching date fields (ExpirationDate, LeaseCommencementDate) from string to DateTime for stronger validation and range queries.
  • 🔒 Validation: Use [Required], [StringLength], or custom validators to enforce data integrity.
  • 🔄 Mapping: Keep fluent API or data annotations in sync if you rename properties or columns.
  • 📊 Indexing: For high‑volume queries (e.g., by State or City), consider adding database indices.

6. Conclusion

The LeaseDetails entity is the cornerstone of managing lease metadata within Irby Imaging. By following the examples and best practices above, you can seamlessly integrate, maintain, and extend this model to support advanced reporting, searching, and automation scenarios.

✨ Happy Coding!