https://github.com/timothyjan/todolist-asp.netcorewebapi-javascript
Todo List using the ASP.NET Core Web API and JavaScript. Controller-based web API that uses a database.
https://github.com/timothyjan/todolist-asp.netcorewebapi-javascript
Last synced: about 1 year ago
JSON representation
Todo List using the ASP.NET Core Web API and JavaScript. Controller-based web API that uses a database.
- Host: GitHub
- URL: https://github.com/timothyjan/todolist-asp.netcorewebapi-javascript
- Owner: TimothyJan
- Created: 2024-08-21T16:34:09.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-21T18:11:13.000Z (almost 2 years ago)
- Last Synced: 2025-01-31T06:08:23.252Z (over 1 year ago)
- Language: C#
- Size: 16.8 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# TodoList-ASP.NetCoreWebApi-JavaScript
Todo List using the ASP.NET Core Web API and JavaScript. Controller-based web API that uses a database.
ASP.NET Core Web API and JavaScript link
ASP.NET Core Web API Tutorial link
Design
Swagger Documentation link
CheckList:
- Create Web Project.
- Add a NuGet package to support the database used.
- Add a model class that represent the data that the app manages. .
- Add a database context that coordinates Entity Framework functionality for a data model. .
- Register the database context with the dependency injection (DI) container to provide service to controllers.
- Scaffold a controller to generate code.
- Update methods accordingly.
- Prevent over-posting to limit the data that's input and returned using a Data Transfer Object(DTO or subset of the model).
API Notes:
- A model is a set of classes that represent the data that the app manages. The model for this app is the TodoItem class.
- The database context is the main class that coordinates Entity Framework functionality for a data model. In ASP.NET Core, services such as the DB context must be registered with the dependency injection (DI) container. The container provides the service to controllers.
- Add new Scaffolded Item in the Controllers folder to generate code.
- The return type of
ActionResult<T>type. ASP.NET Core automatically serializes the object to JSON and writes the JSON into the body of the response message.
Prevent over-posting:
- Production apps typically limit the data that's input and returned using a subset of the model.
- There are multiple reasons behind this, and security is a major one.
- The subset of a model is usually referred to as a Data Transfer Object (DTO), input model, or view model.
- A DTO may be used to:
- Prevent over-posting.
- Hide properties that clients are not supposed to view.
- Omit some properties in order to reduce payload size.
- Flatten object graphs that contain nested objects. Flattened object graphs can be more convenient for clients.