Given definition of a Person:
public class Person
{
public string Id { get; set; }
public string Name { get; set; }
}
Create a new .net framework or dotnet core HTTP API that allows saving and retrieving objects of that type:
- [X] API should accepts and return JSON payloads
- [X] Saving a person with an ID that already exists, overwrites existing data
- [X] Can retrieve a person by Id
- [X] Provide proper error responses
- [X] Provide logging to console
- [X] Can use storage of your choice (in-memory, mongo, sql, etc.), if not using in memory then provide instructions for settings up the storage.
- [X] Can use any frameworks libraries you deem necessary
- [X] Please commit your code to a GitHub repository provide the link to the repository.
- Logging to console provided by
NLog
. - Database provided by
SQLite
. - Uses
EntityFrameworkCore
(EFCore) for the ORM and migrations..
This project uses dotnet core, and mostly the CLI based commands to restore, configure and run the project. The exact steps are:
- Clone the repository.
- Change to the directory where the project is clone.
- Run
dotnet restore
to restore packages - Change to the project directory using
cd PersonSaver
- Run
dotnet ef database update
to create database and apply migrations. dotnet run
to run the project.- The logging is available on the console.
- The project is hosted on https://localhost:5001/api/persons
It supports the usual GET
, POST
and PUT
operations to fetch, create and
update the resources.
- GET https://localhost:5001/api/persons to get all the persons.
- POST https://localhost:5001/api/persons with the json body containing just the name as a string to create resource for that name. The response contains the ID of the newly created resource.
- PUT https://localhost:5001/api/persons/(guid) with the json body containing both id & name to update the resource on the server.
- DELETE operation for the controllers.
- Tests