- This project build with .Net entity framework core 6 and by code first it’s flexible to any relational database
The following Nuget packages are already installed
- Auto mapper
- AutoMapper.Extensions.Microsoft.DependencyInjection
- FluentValidation.AspNetCore
- FluentValidation.DependencyInjectionExtensions
- Microsoft.EntityFrameworkCore
- Microsoft.EntityFrameworkCore.Design
- Microsoft.EntityFrameworkCore.SqlServer
- Microsoft.EntityFrameworkCore.tools
- Microsoft.VisualStudio.Web.CodeGeneration.Design
- Mysql.Data.EntityFrameworkCore
- MySql.EntityFrameworkCore
- Pomelo.EntityFrameworkCore.MySql
- Swashbuckle.AspNetCore
git clone https://github.com/wythh24/backend-project.git v2.0.3
When working with this project, which has been built using code first, it is possible to use it with any relational database due to its flexibility. However, once the project has been cloned, it is necessary to configure the connection string in the appsetting.json file
- This project was used mysql database
Must create database before migration to get tables
"Development": "Server=localhost;Database=yourDatabaseName;Uid=yourUsername;Pwd=yourUserPassword"
Open terminal in project folder and run
initialize
it's just named for each migration
dotnet ef migrations add initialize
And run
dotnet ef database update
This project creates ths following API:
- Product controller
API | Description | Request body | Response body |
---|---|---|---|
POST api/product/getall | Get all product/specific | None/product list | List of product item |
GET api/product | Get all product/specific | None/product list | List of product item |
GET api/product/getbyid | Get a product | product list | A product item |
GET api/product/{id} | Get a product | None | A product item |
POST api/product | Create product as List | Product list | List of product id |
PUT api/product | Update product as List | Product list | List of product id |
DELETE api/product | Delete product as List | List of product id | List of product id |
POST https://localhost:7170/api/Product/getAll
Content-Type: application/json
{
"id": [
"productId",
"productId"
]
}
GET https://localhost:7170/api/Product
Content-Type: application/json
{
"id": [
"73b3cb2f-77a2-41e5-ae86-014ba188843b"
]
}
POST https://localhost:7170/api/Product/getAll
Content-Type: application/json
{
"id": null
}
GET https://localhost:7170/api/Product/73b3cb2f-77a2-41e5-ae86-014ba188843
GET https://localhost:7170/api/Product/GetById/
Content-Type: application/json
{
"id": "73b3cb2f-77a2-41e5-ae86-014ba18883b"
}
POST https://localhost:7170/api/Product
Content-Type: application/json
{
"command": [
{
"name": "product name",
"price": "price(double)",
"description": null,
"code": "product code"
},
{
"name": "apple",
"price": 3.0,
"description": "product from usa",
"code": "us-9000-1"
}
]
}
PUT https://localhost:7170/api/Product/
Content-Type: application/json
{
"command": [
{
"id": "df06fb32-d840-4abc-bbfd-178e3e742fc1",
"name": "1111",
"price": 20.0
},
{
"id": "9bbd9f6f-5e1c-4cf8-a952-5bb65cd39dd2",
"name": "2222",
"price": 10.0
}
]
}
DELETE https://localhost:7170/api/Product/
Content-Type: application/json
{
"id": [
"a7441313-532e-4766-a972-47be0b62c155"
]
}
MIT License
Copyright (c) 2023 wythh24
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.