A layered .NET Framework 4.8 solution for managing companies and their employees. I built it as coursework to practise n-tier structure: one business-logic layer and one data-access layer shared by a WPF desktop client, an ASP.NET MVC site and an ASP.NET Web API.
It's unfinished. The commit history says "GUI handling incomplete" and that's still true (details below).
| Project | Type | Role |
|---|---|---|
DTO |
Class library | Shared data transfer objects (Company, Employee) |
EmployeeDataAccess |
Class library | Entity Framework context, entities, repositories and entity↔DTO mappers |
BusinessLogic |
Class library | CompanyBLL and EmployeeBLL, which the clients call |
WebAPI |
ASP.NET Web API 2 | REST endpoints (CompanyApiController, EmployeeApiController) |
WebGUI |
ASP.NET MVC 5 | Web frontend (Company, Employee and Home controllers) |
EmployeeWPF |
WPF | Desktop client |
TestApp |
WPF | Throwaway harness I used to poke the Web API over HTTP |
There's also a testAPI folder, which is an unused Web API project template and isn't part of the solution.
EmployeeWPF (WPF) WebGUI (MVC) WebAPI (REST) <──HTTP── TestApp
\ | /
\ | /
BusinessLogic (CompanyBLL, EmployeeBLL) referenced in-process
|
EmployeeDataAccess (EF, repositories + mappers)
|
SQL Server Express (code-first, seeded by EmployeeInitializer)
All three front ends reference BusinessLogic directly and call it in-process. The WPF client and the MVC controllers do new EmployeeBLL() themselves; they don't go through the Web API. The Web API is a third front end over the same layers, and the only thing that calls it is TestApp.
The parts I'd point at are the repository pattern and the mapping between EF entities and DTOs: nothing above EmployeeDataAccess sees an EF entity, and only the DTOs cross layer boundaries.
- WebGUI can look up a company or employee by id, create new ones, and the home page lists all of both.
- The WPF client is lookup-only: get an employee or a company by id, and see a company's employees.
- The Web API exposes get-by-id and create for both. Routes include the action, e.g.
GET api/employeeapi/getemployee/1andPOST api/employeeapi/addemployee. An unknown id gives a 404. - Editing and deleting aren't implemented.
CompanyBLL.editCompany/deleteCompanyandEmployeeBLL.editEmployeeare emptyTODOstubs, there's no employee delete at all, andaddEmployeeToCompanyexists in the BLL but nothing in the UI calls it. TestAppcalls a hard-codedhttps://localhost:44367(WebAPI's IIS Express port), so WebAPI has to be running from Visual Studio first.- There are no automated tests.
- C# on .NET Framework 4.8
- ASP.NET Web API 2 and ASP.NET MVC 5
- Entity Framework 6, code-first, with a
CreateDatabaseIfNotExistsinitializer that seeds sample data - WPF
- SQL Server Express
This needs Windows, Visual Studio (or Rider) and a local SQL Server Express instance.
- Open
EmployeeApp.sln. - Each runnable project has its own
Employeesconnection string (Web.configfor WebGUI and WebAPI,App.configfor the WPF apps). They all point atlocalhost\SQLEXPRESS, so changeData Sourceif your instance is named differently. The database isEmployees18, and EF creates and seeds it on first use. - Run
WebGUIorEmployeeWPFon its own. Neither needs the Web API running. StartWebAPIonly if you want to hit the REST endpoints.
Employees need YearsEmployed between 1 and 45 (validated on the DTO).