Skip to content

lovomax/CarSale

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CarSale

Use instructions

  1. Clone the repository.
  • git@github.com:lovomax/CarSales.git.
    • Enter the folder of the repository you've just cloned
    • cd CarSales
  1. Install the dependencies and initialize the project.

To build the project's backend and the SqlServer Database.

  • dotnet build CarSaleServer
  • dotnet ef database update

To install the dependencies of the project's frontend, enter the CarSaleClient folder.

  • cd CarSaleClient
  • yarn

By initializing the backend you are provided with an Admin account, the following variables are the credentials needed to use the application correctly.

  • Username= admin
  • Password = admin

After configuring the server and the frontend, we already have all we need to start using the application, all that's left is to run the following commands to start the application:

  • On the application's root folder:
    • dotnet run --project CarSaleServer
  • On the application's CarSaleClient folder:
    • yarn start

Administrative flow

After logging in, you will be redirected to the homepage, where you can move between pages in the application, in here, you will be capable to move to:

  • Buy Cars: Allows the user to see all of the registered cars
  • Sell Car: Allows for the creation of a new car
  • Logging in (if you are still not logged in)
  • Details of the Car: In here you can update the general data and image of the car or outright delete it.

API Documentation


Log-in

POST /api/Auth/login

The endpoint does a validation for the login and returns a token for authentication

  • example request body

    {
      "username": "admin",
      "password": "admin"
    }
    • example response body
    {
      "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjQ3N2IyOTlhLTIzMWYtNDBkYS05N2MzLWFjNzUyNjU0NTI2ZiIsImZ1bGxuYW1lIjoiSm9zZSBEYW5pZWwgQXJyZWF6YSBQdWVydGEiLCJ1c2VybmFtZSI6ImpkYW5pZWxfYXAiLCJlbWFpbCI6ImFkbWluQGFkbWluLmNvbSIsIm1lZGljUm9sZSI6dHJ1ZSwiaWF0IjoxNjMxNDQ2MDUxLCJleHAiOjE2MzE0NDYzNTEsInN1YiI6IjQ3N2IyOTlhLTIzMWYtNDBkYS05N2MzLWFjNzUyNjU0NTI2ZiJ9.HgKfpimfS1ExsvkXMcgNx09GAiaO1yxzI4qfrtStS_o",
    "success": true,
    "message": ""
    }

Get cars

GET api/Car/getallcars

This endpoint returns all of the registered cars

  • Example request No parameters required

  • Example response

"data": [
   {
     "id": 0,
     "name": "string",
     "model": "string",
     "kilometers": 0,
     "price": 0,
     "year": "2022-11-12T17:17:40.795Z",
     "make": {
       "name": "string"
     },
     "photo": {
       "photoURL": "string",
       "publicId": "string"
     }
   },
   {
     "id": 1,
     "name": "string",
     "model": "string",
     "kilometers": 0,
     "price": 0,
     "year": "2022-11-12T17:17:40.795Z",
     "make": {
       "name": "string"
     },
     "photo": {
       "photoURL": "string",
       "publicId": "string"
     }
   }
 ],
 "success": true,
 "message": ""

Get car

GET /api/Car/:id

This endpoint returns to the user the information of the specified car


  • Example request

  • Example response

{
 "data": {
   "id": 0,
   "model": "string",
   "name": "string",
   "kilometers": 0,
   "price": 0,
   "color": "string",
   "year": "2022-11-12T17:29:07.929Z",
   "make": {
     "name": "string"
   },
   "photo": {
     "photoURL": "string",
     "publicId": "string"
   }
 },
 "success": true,
 "message": ""
}

Add car [Authorize]

POST /api/Car/addcar


This endpoint allows for the creation of a new Car

  • Example request

  • headers

{
  "Content-Type": "multipart/form-data",
  "Authorization": "(Login Token)"
}
  • Example request body
{
 "model": "string",
 "name": "string",
 "price": 0,
 "color": "string",
 "kilometers": 0,
 "year": "2022-11-12T17:33:46.367Z",
 "makeId": 0
}
  • Example response
{
 "data": {
   "id": 0,
   "model": "string",
   "name": "string",
   "kilometers": 0,
   "price": 0,
   "color": "string",
   "year": "2022-11-12T17:33:46.371Z",
   "make": {
     "name": "string"
   },
   "photo": {
     "photoURL": "string",
     "publicId": "string"
   }
 },
 "success": true,
 "message": ""
}

Update car [Authorize]

PUT /api/Car/updatecar

The endpoint returns the updated entity and updates the database

  • Example request

  • headers

{
  "Content-Type": "multipart/form-data",
  "Authorization": "(Login Token)"
}
  • Example request body
{
 "id": 0,
 "model": "string",
 "name": "string",
 "kilometers": 0,
 "price": 0,
 "color": "string",
 "year": "2022-11-12T17:40:07.730Z"
}
  • Example response body
{
 "data": {
   "id": 0,
   "model": "string",
   "name": "string",
   "kilometers": 0,
   "price": 0,
   "color": "string",
   "year": "2022-11-12T17:40:07.741Z",
   "make": {
     "name": "string"
   },
   "photo": {
     "photoURL": "string",
     "publicId": "string"
   }
 },
 "success": true,
 "message": "string"
}

Delete car [Authorize]

``DELETE` api/Car/deletecar/:id

The endpoint deletes an endpoint

  • Example request

  • headers

{
  "Content-Type": "multipart/form-data",
  "Authorization": "(Login Token)"
}
  • Example response body
{
  "data": "the car has been deleted",
  "message": "operation complete",
  "success": "true"
}

Get photo

GET /api/Image/get/{request}

The endpoint returns a photo with a certain ID

  • Example request

  • headers

{
  "Content-Type": "multipart/form-data",
  "Authorization": "(Login Token)"
}
  • Example response body
{
  "data": {
    "photoURL": "string",
    "publicId": "string",
    "timeStamp": "string"
  },
  "success": true,
  "message": "string"
}

Add photo [Authorize]

POST /api/Image/add

The endpoint registers a photo under a car id

  • Example ``request` string($binary)File, integer($int32) CarId

  • headers

{
  "Content-Type": "multipart/form-data",
  "Authorization": "(Login Token)"
}
  • Example response body
{
  "data": {
    "photoURL": "string",
    "publicId": "string",
    "timeStamp": "string"
  },
  "success": true,
  "message": "string"
}

Update photo [Authorize]

PUT /api/Image/update

The endpoint updates a photo and its URL

  • Example ``request` string($binary)File, string PublicId

  • headers

{
  "Content-Type": "multipart/form-data",
  "Authorization": "(Login Token)"
}
  • Example response body
{
  "data": {
    "photoURL": "string",
    "publicId": "string",
    "timeStamp": "string"
  },
  "success": true,
  "message": "string"
}

Delete photo [Authorize]

DELETE /api/Image/delete

This endpoint deletes a photo in the database and in the service.

  • Example request

  • headers

{
  "Content-Type": "multipart/form-data",
  "Authorization": "(Login Token)"
}

-request body

 {
   "publicId": "string"
 }

-example response body

{ "data": "string", "success": true, "message": "string" }


The endpoints with the tag [Authorize] can only be used by a registered user.

About

Car.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published