Department Model Overview
The Department object represents a real estate office or department in Destinet. It's a master entity stored in its own collection, referenced by Estate and Employee entities.
What is a Department?
A Department represents:
- A physical office location with address, contact information, and operating area
- The legal entity (company name, registration number)
- The marketing identity (marketing name, logo, website, branding)
- A container for employees who work at that office
Design Principles
1. Master Entity with References
Each department is stored once and referenced by ID:
- Estates link to departments via
DepartmentId - Employees link to departments via
DepartmentIds(employees can belong to multiple offices) - Projects link to the department handling the project
Benefit: Update department contact info once → all 500+ estates automatically show new phone number.
2. Multiple Name Types for Different Contexts
Departments need flexibility in how they're presented:
Name: Primary display name ("Proaktiv - Meglerhuset Borg Næring")MarketingName: Brand name for marketing ("Proaktiv Trondheim Sentrum")LegalName: Registered company name ("Meglerhuset Borg AS")
This supports multi-brand departments or franchises under one legal entity.
3. Geographic Service Areas
Departments define their operating territory through:
Address: Physical office location for customer visitsServiceAreaPostalCodes: List of postal codes the office covers.
Use Case: Find all departments serving postal code "7011" → filter by ServiceAreaPostalCodes.Contains("7011")
4. Personnel Management via References
Track key roles without embedding employee data:
ManagingDirectorIds(Daglig leder)DepartmentManagerIds(Avdelingsleder)ResponsibleBrokerIds(Fagansvarlig)
These reference the separate Employees collection for full details.
Core Structure
public class Department
{
// Core Identification
public string Id { get; set; }
public string Name { get; set; }
public string? RegistrationNumber { get; set; }
public bool? IsRegion { get; set; }
public bool? IsPartOfFranchise { get; set; }
public List<int>? SubDepartments { get; set; }
// Contact Information
public string? Phone { get; set; }
public string? Email { get; set; }
public string? LeadsEmail { get; set; }
public string? Website { get; set; }
// Address
public Address? Address { get; set; }
// Description & Content
public string? Description { get; set; }
public string? ShortDescription { get; set; }
// Media
public string? LogoUrl { get; set; }
public string? VideoUrl { get; set; }
public string? HeaderImageUrl { get; set; }
public string? PriceListUrl { get; set; }
public ImageCollection? Images { get; set; }
public DateTime? ImageTimestamp { get; set; }
// Publishing & Status
public bool? IsActive { get; set; }
// Staff References
public List<string>? ManagingDirectorIds { get; set; }
public List<string>? DepartmentManagerIds { get; set; }
public List<string>? ResponsibleBrokerIds { get; set; }
// Origin Data
public DateTime? LastModifiedOrigin { get; set; }
public DateTime? LastModifiedLocal { get; set; }
public string? OriginalDepartmentId { get; set; }
public string? Origin { get; set; }
public Dictionary<string, object>? CustomData { get; set; }
}
Geographic Organization and Multi-Department Towns
How Town/City Grouping Works
There is no separate "Town" entity in the system. Instead, geographic organization is achieved through each department's own Address object. This means:
- Each department maintains its own location data via
Address.City,Address.Municipality, andAddress.County - Multiple departments can be located in the same town/city
- Geographic grouping is done by querying departments based on their address fields
Handling Multiple Departments in One Town
When two or more departments are located in the same town, use the town registered on each department in their Address field:
// Department A in Trondheim
var departmentA = new Department
{
Id = "3005093",
Name = "Aktiv Eiendomsmegling Trondheim",
Address = new Address
{
City = "Trondheim",
Municipality = "Trondheim",
County = "Trøndelag"
}
};
// Department B also in Trondheim
var departmentB = new Department
{
Id = "3005094",
Name = "Privatmegleren Trondheim",
Address = new Address
{
City = "Trondheim",
Municipality = "Trondheim",
County = "Trøndelag"
}
};
Querying Departments by Location
To group or filter departments by geographic location:
// Get all departments in a specific city
var departmentsInOslo = departments.Where(d => d.Address.City == "Oslo");
// Get all departments in a municipality
var departmentsInTrondheim = departments.Where(d => d.Address.Municipality == "Trondheim");
// Get all departments in a county/region
var departmentsInTrondelag = departments.Where(d => d.Address.County == "Trøndelag");
// Get departments serving a specific postal code
var departmentsServingArea = departments.Where(d =>
d.ServiceAreaPostalCodes.Contains("7011")
);
Key Points
- Each department is an independent entity with its own location
- Use
Department.Address.CityorDepartment.Address.Municipalityfor town-based grouping - Multiple departments in the same town maintain separate records
- Service areas (via
ServiceAreaPostalCodes) define coverage zones, which may extend beyond the department's physical location
Geographic Hierarchy
The implicit geographic hierarchy from the Address model:
Country (Norway)
└── County (Oslo, Trøndelag, etc.)
└── Municipality (Oslo, Trondheim, etc.)
└── City (specific city areas)
└── LocalAreaName (neighborhoods: Gimle, Myrvang, etc.)
└── Street Address (individual properties)
Shared Classes
These classes are shared across Estate, Project, Employee, and other models. Full documentation is available in the Shared Classes section.
Address
Groups all location-related information (see Address documentation):
public class Address
{
public string Street { get; set; }
public string LocalAreaName { get; set; } // Gimle, Myrvang, etc.
public string ZipCode { get; set; }
public string City { get; set; }
public string Municipality { get; set; }
public string County { get; set; }
public string Country { get; set; }
public string CountryCode { get; set; }
public string FullAddress { get; } // Computed property
}
Working with Media
Image
Fetch images: GET /{installationId}/Departments/{departmentId}/Picture
public class Image
{
public string Id { get; set; }
public string OriginalUrl { get; set; }
public string Filename { get; set; }
public string FileExtension { get; set; }
public string ExternalProviderUrl { get; set; }
public string Caption { get; set; }
public string AltText { get; set; }
public string Category { get; set; } // "Office Facade", "Office Interior", "Team Photo"
public int Order { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public DateTime LastModifiedOrigin { get; set; }
public DateTime LastModifiedLocal { get; set; }
}
Usage:
department.Images.Add(new Image
{
Id = "4821283",
OriginalUrl = "https://cdn.example.com/office-facade.jpg",
Filename = "office-facade.jpg",
FileExtension = "jpg",
Caption = "Main office entrance",
AltText = "Modern office building facade with glass windows",
Category = "Office Facade",
Order = 1,
Width = 1920,
Height = 1080,
LastModifiedOrigin = DateTime.Parse("2025-10-25"),
LastModifiedLocal = DateTime.Parse("2025-10-25T10:30:00Z")
});
Relationship to Other Models
Department → Employee (One-to-Many)
// Employees reference departments they belong to
employee.DepartmentIds = new List<string> { "3005093", "3005094" };
// Find all employees in a department
var employeesInDept = employees.Where(e => e.DepartmentIds.Contains("3005093"));
Department → Estate (One-to-Many)
// Estates reference their department
estate.DepartmentId = 3005093;
// Find all estates for a department
var estatesForDept = estates.Where(e => e.DepartmentId == 3005093);
Department → Project (One-to-Many)
// Projects reference the department handling them
project.DepartmentId = "3005093";
// Find all projects for a department
var projectsForDept = projects.Where(p => p.DepartmentId == "3005093");