A simple .NetCore 2.1 web application has been created and bootstrapped with data. The application contains information about all employees at a company. On application start-up, an in-memory database is bootstrapped with a serialized snapshot of the database. While the application runs, the data may be accessed and mutated in the database without impacting the snapshot.
You can run this by executing dotnet run on the command line or in Visual Studio Community Edition.
The following endpoints are available to use:
* CREATE
* HTTP Method: POST
* URL: localhost:8080/api/employee
* PAYLOAD: Employee
* RESPONSE: Employee
* READ
* HTTP Method: GET
* URL: localhost:8080/api/employee/{id}
* RESPONSE: Employee
* UPDATE
* HTTP Method: PUT
* URL: localhost:8080/api/employee/{id}
* PAYLOAD: Employee
* RESPONSE: Employee
The Employee has a JSON schema of:
{
"type":"Employee",
"properties": {
"employeeId": {
"type": "string"
},
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"position": {
"type": "string"
},
"department": {
"type": "string"
},
"directReports": {
"type": "array",
"items" : "string"
}
}
}For all endpoints that require an "id" in the URL, this is the "employeeId" field.
Clone or download the repository, do not fork it.
Create a new type, ReportingStructure, that has two properties: employee and numberOfReports. ASSUMPTION - The employee property is of type Employee.
For the field "numberOfReports", this should equal the total number of reports under a given employee. The number of reports is determined to be the number of directReports for an employee and all of their direct reports. For example, given the following employee structure:
John Lennon
/ \
Paul McCartney Ringo Starr
/ \
Pete Best George Harrison
The numberOfReports for employee John Lennon (employeeId: 16a596ae-edd3-4847-99fe-c4518e82c86f) would be equal to 4.
This new type should have a new REST endpoint created for it. This new endpoint should accept an employeeId and return the fully filled out ReportingStructure for the specified employeeId. ASSUMPTION - A fully filled out reporting structure should include the direct reports property of the Employee object. The values should be computed on the fly and will not be persisted.
ASSUMPTION - The Employee services, repositories, and controllers should be changed as little as possible.
The following endpoints are available to use:
* READ
* HTTP Method: GET
* URL: localhost:8080/api/reportingStructure/{id}
* RESPONSE: ReportingStructure
The ReportingStructure has a JSON schema of:
{
"type":"ReportingStructure",
"properties": {
"employee": {
"type": "Employee"
},
"numberOfReports": {
"type": "number"
}
}
}For all endpoints that require an "id" in the URL, this is the "employeeId" field.
Create a new type, Compensation. A Compensation has the following fields: employee, salary, and effectiveDate. Create two new Compensation REST endpoints. One to create and one to read by employeeId. These should persist and query the Compensation from the persistence layer.
The following endpoints are available to use:
* CREATE
* HTTP Method: POST
* URL: localhost:8080/api/compensation
* PAYLOAD: Compensation
* RESPONSE: Compensation
* READ
* HTTP Method: GET
* URL: localhost:8080/api/compensation/{id}
* RESPONSE: Compensation array
The Compensation has a JSON schema of:
{
"type":"Compensation",
"properties": {
"employee": {
"type": "string"
},
"salary": {
"type": "number"
},
"effectiveDate": {
"type": "date"
}
}
}For all endpoints that require an "id" in the URL, this is the "employeeId" field.
ASSUMPTIONS
- The employee property is the employee id since it would be awkward to populate an employee object when setting the employee's compensation.
- The salary property should be a non-negative decimal number.
- The presence of the effective date property implies that an employee's compensation changes over time and each change should be recorded.
- The effective date can be in the past (I limit to 1900 for no good reason) or the future.
- A employee id/effective date combo should be unique to avoid having multiple "active" compensations.
- The new read endpoint should return the complete compensation history for the employee.
Please upload your results to a publicly accessible Git repo. Free ones are provided by Github and Bitbucket.