/gv-bootcamp-odev3-e-commerce

Third assignment of the Gelecek Varlık Fullstack Bootcamp. Created an e-commerce project. Learned about enterprise architecture.

Primary LanguageC#

E-Commerce Project with .Net 5.

Simple E-Commerce WebApi project.

Frontend UI

I made a simple UI for this project with React <3. You can check it out here.

Features

  • Create, delete, update (User, Product, Category)
  • User Login

API Reference

keep in mind that https://localhost:44359 can change for you.

Categories

Create a new category

Request

POST /Category/

curl --location --request POST 'https://localhost:44359/api/Category' \
     --header 'Content-Type: application/json' \
     --data-raw
     '{
          "name": "category1",
          "description": "category1",
          "iuser": 1
     }'

Response

{
  "isSuccess": true,
  "entity": {
    "name": "category1",
    "description": "category1",
    "idatetime": "2021-12-07T22:51:00.7407267+03:00",
    "iuser": 1
  },
  "list": null,
  "totalCount": 0,
  "validationErrorList": null,
  "exceptionMessage": null
}

Get list of categories

Request

GET /api/Category

curl --location --request GET 'https://localhost:44359/api/Category'

Response

{
  "isSuccess": true,
  "entity": null,
  "list": [
    {
      "id": 1,
      "name": "category1",
      "description": "category1",
      "idatetime": "2021-12-07T22:51:00.7407267+03:00",
      "iuser": "user1"
    },
    {
      "id": 2,
      "name": "category2",
      "description": "category2",
      "idatetime": "2021-12-07T22:51:30.3207267+03:00",
      "iuser": "user1"
    }
  ],
  "totalCount": 2,
  "validationErrorList": null,
  "exceptionMessage": null
}

Update a Category

PUT /Category/id

Request

curl --location
    --request PUT 'https://localhost:44359/api/Category/1' \
    --header 'Content-Type: application/json' \
    --data-raw
    '{
        "name": "category1",
        "description": "category1Test",
        "uuser": 1
    }'

Response

{
  "isSuccess": true,
  "entity": {
    "name": "category1",
    "description": "category1Test",
    "udatetime": "2021-12-09T16:27:45.7578499+03:00",
    "uuser": 1
  },
  "list": null,
  "totalCount": 0,
  "validationErrorList": null,
  "exceptionMessage": null
}

Products

Create a new Product

POST /Product/

Request
curl --location --request POST 'https://localhost:44359/api/Product' \
     --header 'Content-Type: application/json' \
     --data-raw
     '{
          "categoryId": 1,
          "name": "product2",
          "displayName": "product2",
          "description": "product2",
          "price": 9999.9,
          "iuser": 1
     }'
Response
{
  "isSuccess": true,
  "entity": {
    "categoryId": 1,
    "name": "product2",
    "displayName": "product2",
    "description": "product2",
    "price": 9999.9,
    "idatetime": "2021-12-07T22:52:24.7407267+03:00",
    "iuser": 1
  },
  "list": null,
  "totalCount": 0,
  "validationErrorList": null,
  "exceptionMessage": null
}

Get list of Products

GET /api/product

Request
curl -X GET "https://localhost:44359/api/Product" -H  "accept: text/plain"
Response
{
  "isSuccess": true,
  "entity": null,
  "list": [
    {
      "id": 1,
      "category": "category1",
      "name": "product1",
      "displayName": "product1",
      "description": "product1",
      "price": "999,90 ₺",
      "idatetime": "2021-12-07T17:20:29.057",
      "udatetime": "0001-01-01T00:00:00",
      "iuser": "user1"
    },
    {
      "id": 2,
      "category": "category2",
      "name": "product2",
      "displayName": "product2",
      "description": "product2",
      "price": "999,90 ₺",
      "idatetime": "2021-12-07T17:21:29.057",
      "udatetime": "0001-01-01T00:00:00",
      "iuser": "user1"
    }
  ],
  "totalCount": 1,
  "validationErrorList": null,
  "exceptionMessage": null
}

Update a Product

Request

PUT /Product/id

Request
curl --location
    --request PUT 'https://localhost:44359/api/Product/1002' \
    --header 'Content-Type: application/json' \
    --data-raw
    '{
        "categoryId": 1,
        "name": "product2",
        "displayName": "product2Test",
        "description": "product2",
        "price": 99,
        "stock": 99,
        "uuser": 1
    }'
Response
{
  "isSuccess": true,
  "entity": {
    "categoryId": 1,
    "name": "product2",
    "displayName": "product2Test",
    "description": "product2",
    "price": 99,
    "stock": 99,
    "udatetime": null,
    "uuser": 11
  },
  "list": null,
  "totalCount": 0,
  "validationErrorList": null,
  "exceptionMessage": null
}

Users

Create a new User

POST /User

Request
curl --location --request POST 'https://localhost:44359/api/User/register' \
     --header 'Content-Type: application/json' \
     --data-raw
     '{
          "name": "user",
          "username": "user1",
          "email": "user@mail.com",
          "password": "veryStrongPassword"
     }'
Response
{
  "isSuccess": true,
  "entity": {
    "name": "user",
    "username": "user1",
    "email": "user@mail.com",
    "password": "veryStrongPassword"
  },
  "list": null,
  "totalCount": 0,
  "validationErrorList": null,
  "exceptionMessage": null
}

User Login

POST /User/login

Request
curl --location --request POST 'https://localhost:44359/api/User/login' \
     --header 'Content-Type: application/json' \
     --data-raw
     '{
          "username": "user1",
          "password": "veryStrongPassword"
     }'

Response
{
  "isSuccess": true,
  "entity": {
    "username": "user1",
    "password": "veryStrongPassword"
  },
  "list": null,
  "totalCount": 0,
  "validationErrorList": null,
  "exceptionMessage": null
}

Get list of Users

GET /User

Request
curl --location --request GET 'https://localhost:44359/api/User'
Response
{
  "isSuccess": true,
  "entity": null,
  "list": [
    {
      "id": 1,
      "name": "user",
      "username": "user1",
      "email": "user@mail.com",
      "idatetime": "2021-12-07T22:53:24.7407267+03:00"
    },
    {
      "id": 2,
      "name": "user2",
      "username": "user2",
      "email": "user2@mail.com",
      "idatetime": "2021-12-07T23:30:24.7407267+03:00"
    }
  ],
  "totalCount": 2,
  "validationErrorList": null,
  "exceptionMessage": null
}

Update a User

PUT /User/id

Request
curl --location
    --request PUT 'https://localhost:44359/api/User/1002' \
    --header 'Content-Type: application/json' \
    --data-raw
    '{
        "username": "user1",
        "email": "updatedUserMail@mail.com",
        "password": "updatedVeryStrongPassword",
        "uuser": 1
    }'
Response
{
  "isSuccess": true,
  "entity": {
    "username": "user1",
    "email": "updatedUserMail@mail.com",
    "password": "updatedVeryStrongPassword",
    "udatetime": "2021-12-09T16:27:45.7578499+03:00",
    "uuser": 11
  },
  "list": null,
  "totalCount": 0,
  "validationErrorList": null,
  "exceptionMessage": null
}

Delete a Thing (Works Same For All Entities)

Request

DELETE /Thing/id

curl --location --request DELETE 'https://localhost:44359/api/Thing/1'

Response

{
  "isSuccess": true,
  "entity": {
    "thing-key1": "thing-value1",
    "thing-key2": "thing-value2",
    "thing-key3": "thing-value3",
    "thing-key4": "thing-value4",
    "thing-key5": "thing-value5"
  },
  "list": null,
  "totalCount": 0,
  "validationErrorList": null,
  "exceptionMessage": null
}

Try to delete same Thing again

Request

DELETE /Thing/id

curl --location --request DELETE 'https://localhost:44359/api/Thing/1'

Response

{
  "isSuccess": false,
  "entity": null,
  "list": null,
  "totalCount": 0,
  "validationErrorList": null,
  "exceptionMessage": "Thing with id: 1 is not found"
}

Tech Stack

Backend: .Net Core

Database: MS Sql

Acknowledgements