Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/prinx/dotnet-shopping-cart
Sample Shopping Cart API using .NET Core
https://github.com/prinx/dotnet-shopping-cart
Last synced: 15 days ago
JSON representation
Sample Shopping Cart API using .NET Core
- Host: GitHub
- URL: https://github.com/prinx/dotnet-shopping-cart
- Owner: prinx
- License: mit
- Created: 2021-06-10T08:51:34.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-06-23T08:28:25.000Z (over 3 years ago)
- Last Synced: 2024-12-20T01:16:00.691Z (15 days ago)
- Language: C#
- Size: 77.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dotnet Shopping Cart
Example of Shopping Cart API using .NET Core
This project assumes a user can have only one cart.
## API Documentation
### Add a new user
```http
POST http://localhost:5000/api/users
Content-type: application/json{
"name": "Caroline",
"phoneNumber": "233..."
}
```### Add product
```http
POST http://localhost:5000/api/products
Content-type: application/json{
"name": "Keyboard",
"price": 5000,
"inStock": true
}
```### Add item to cart
```http
POST http://localhost:5000/api/cartItems
Content-type: application/json{
"ProductId": 3,
"UserId": 2,
"Quantity": 1
}
```- Quantity is optional and is 1 by default
- A new cart item will be created if it does not exist
- Only cart item quantity will be updated if cart item already exist### Delete cart item
```http
DELETE http://localhost:5000/api/cartItems
Content-type: application/json{
"ProductId": 3,
"UserId": 2,
"Quantity": 1
}
```This will reduce the quantity of the cart item. The product is deleted when the remaining quantity is less or equal to 0.
### Get user's cart
```http
GET http://localhost:5000/api/cartItems/user/{userId}
```## Swagger link
Use this link Swagger interface after building the project (should open automatically in the browser after a build):
## Improvments
- Add unit tests
- Use a service based architecture## LICENSE
[MIT](LICENSE)