# Address

**Kind:** Class

**Source:** `Pams/Logic/Pams.Business/Entity/Common/Address.Model.cs` (line 15)

**Part of:** [Pams](subsystem-pams)

`Address` is a C# entity model that stores address, destination, and location details for a record in the PAMS business layer. It includes identity fields, optional company ownership through `CompanyId`, and address components used by application and API layers.

## Diagram

```mermaid
graph LR
  Address[Address]
  Address --> AddressID["AddressID: long"]
  Address --> AddressLine["AddressLine: string"]
  Address --> CountryCode["CountryCode: string"]
  Address --> CompanyId["CompanyId: int?"]
  Address --> City["City: string"]
  Address --> State["State: string"]
  Address --> PostalCode["PostalCode: string"]
  Address --> ZipCode["ZipCode: string"]
  Address --> RowGuid["RowGuid: Guid"]
  Address --> Destination["Destination: string"]
```

## Usage

```ts
type AddressPayload = {
  AddressID: string;
  AddressLine: string;
  CountryCode: string;
  CompanyId: number | null;
  City: string;
  State: string;
  PostalCode: string;
  ZipCode: string;
  RowGuid: string;
  Destination: string;
};

async function saveAddress(address: AddressPayload) {
  await fetch("/api/addresses", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify(address),
  });
}

const address: AddressPayload = {
  AddressID: addressId,
  AddressLine: "Example Street",
  CountryCode: "US",
  CompanyId: null,
  City: "Example City",
  State: "Example State",
  PostalCode: "Example Postal Code",
  ZipCode: "Example Zip Code",
  RowGuid: rowGuid,
  Destination: "Primary",
};

await saveAddress(address);
```

## AI Coding Instructions

- Preserve the existing property names and casing when mapping `Address` to API request and response payloads.
- Treat `CompanyId` as nullable and send `null` when no company value is available.
- Follow the API serialization contract for `AddressID` and `RowGuid`; do not assume JavaScript numeric handling matches C# `long`.
- Keep `PostalCode` and `ZipCode` separate unless the calling API explicitly maps them together.

## Relationships

- IMPORTS → `Address`
- IMPORTS → `EntityBase`
- IMPORTS → `City`
- IMPORTS → `PamsLinqDataContext`

## Used by

12 references from 12 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Imported by (12)

- `AddressController` — `Pams/API/Pams.API/Controllers/Common/AddressController.cs`:15
- `CompanyBranchController` — `Pams/API/Pams.API/Controllers/Organization/CompanyBranchController.cs`:21
- `CompanyController` — `Pams/API/Pams.API/Controllers/Organization/CompanyController.cs`:26
- `EmployeeController` — `Pams/API/Pams.API/Controllers/Person/EmployeeController.cs`:29
- `AccountsController` — `Pams/API/Pams.API/Controllers/Person/AccountsController.cs`:23
- `PersonAddressController` — `Pams/API/Pams.API/Controllers/Person/PersonAddressController.cs`:21
- `ActivitiesController` — `Pams/API/Pams.API/Controllers/Tasks/Activities/ActivitiesController.cs`:17
- `BranchViewModel` — `Pams/API/Pams.API/Models/ViewModels/Branch/BranchViewModel.cs`:11

…and 4 more.
