This project implements a REST API for managing the hierarchical organizational structure of enterprises (Companies -> Divisions -> Projects -> Departments -> Employees). The application is developed in .NET and ASP.NET Core Web API, utilizing Entity Framework Core for SQL Server database access. Project includes complete CRUD operations, advanced hierarchical filtering, cascading data integrity protection, and an application-level Soft-Delete mechanism.
-
A prepared SQL script is provided in the repository. In SQL Server Management Studio create a new empty database. Run the attached script over this database or run the Update-Database command in the Package Manager Console.
-
In appsettings.json file ensure that the DefaultConnection key in the ConnectionStrings section correctly points to your SQL Server and the created database.
-
Run the project, execute the request: POST /api/testing/reset-db to create dummy data
-
Run TeaPie test, Open a Package Manager Console and navigate to the tests folder: cd CompaniesStructure.API/TeaPieTests teapie test
[ Company ] ──(1:N)──> [ Division ] ──(1:N)──> [ Project ] ──(1:N)──> [ Department ]
│ │ │ │
(1:N) (1:N) (1:N) (1:N)
│ │ │ │
▼ ▼ ▼ ▼
─────────────────────────────── [ Employee ] ────────────────────────────────
- One Company can oversee multiple Divisions.
- One Division contains multiple Projects.
- One Project can be internally divided into multiple Departments.
- The relationship between an employee and organizational units is flexible. An employee does not have to belong only to the lowest level (department) but can be assigned directly to a company, division, or project. In the database, this is handled using nullable foreign keys (CompanyId, DivisionId, ProjectId, DepartmentId).
- Every organizational unit (Company, Division, Project, Department) has exactly one assigned manager (ManagerId), which references the Employee entity.
- Company: The highest root node of the entire structure. It carries information about the company's name, ID number (ICO), address, and a unique code.
- Division: Represents a cohesive branch within the company (e.g., Development Division, Consulting Division). It is fully dependent on its parent company.
- Project: A time-bound activity tied to a specific division. It is governed primarily by its validity dates (StartDate and EndDate).
- Department: The lowest organizational unit tied to a project (e.g., Frontend, Backend, QA Testing).
- Employee: A specific person in the system. Contains personal data (title, name, surname, e-mail, phone), job position title, and links to the nodes where they work.