Skip to content

lcsmota/MoviesApi

Repository files navigation

MoviesApi

🌐 Status

Finished project βœ…

🧰 Prerequisites

  • .NET 6.0 or +

  • Connection string to SQLServer in MoviesApi/appsettings.json named as Default

Database

Create a database in SQLServer that contains the table created from the following script:

CREATE TABLE [Movies] (
    [Id] int NOT NULL IDENTITY,
    [Title] nvarchar(255) NULL,
    [Genre] nvarchar(20) NULL,
    [ReleaseDate] datetime2 NOT NULL,
    CONSTRAINT [PK_Movies] PRIMARY KEY ([Id])
);
GO

CREATE TABLE [Stars] (
    [Id] int NOT NULL IDENTITY,
    [Name] nvarchar(80) NOT NULL,
    [Surname] nvarchar(80) NOT NULL,
    [Nationality] nvarchar(50) NULL,
    [BirthDate] datetime2 NOT NULL,
    [WonOscar] bit NOT NULL,
    CONSTRAINT [PK_Stars] PRIMARY KEY ([Id])
);
GO

πŸ”§ Installation

$ git clone https://github.com/lcsmota/MoviesApi.git

$ cd MoviesApi/

$ dotnet restore

$ dotnet run

Server listenning at https://localhost:7267/swagger or https://localhost:7267/api/v1/Movies and https://localhost:7267/api/v1/Stars

πŸ“« Routes for Movies

Return all objects (Movies)

  GET https://localhost:7267/api/v1/Movies

βš™οΈ Status Code:

  (200) - OK

πŸ“¬ Postman

πŸ“ Swagger

Return only one object (Movie)

  GET https://localhost:7267/api/v1/Movies/${id}
Parameter Type Description
id int Mandatory. The ID of the object you want to view

βš™οΈ Status Code:

  (200) - OK
  (404) - Not Found

πŸ“¬ Postman

πŸ“ Swagger

Insert a new object (Movie)

  POST https://localhost:7267/api/v1/Movies

πŸ“¨ body:

{
  "title": "Pacific Rim",
  "genre": "Science Fiction",
  "releaseDate": "2013-07-12T13:09:54.105Z"
}

🧾 response:

{
    "id": 8,
    "title": "Pacific Rim",
    "genre": "Science Fiction",
    "releaseDate": "2013-07-12T13:09:54.105Z"
}

βš™οΈ Status Code:

  (201) - Created
  (400) - Bad Request

πŸ“¬ Postman

πŸ“ Swagger

Update an object (Movie)

  PUT https://localhost:7267/api/v1/Movies/${id}
Parameter Type Description
id int Mandatory. The ID of the object you want to update

πŸ“¨ body:

{
  "id": 8,
  "title": "Pacific Rim",
  "genre": "Science Fiction",
  "releaseDate": "2013-07-12T13:09:54.105Z"
}

🧾 response:

βš™οΈ Status Code:

  (204) - No Content
  (400) - Bad Request

πŸ“¬ Postman

πŸ“ Swagger

Delete an object (Movie)

  DELETE https://localhost:7267/api/v1/Movies/${id}
Parameter Type Description
id int Mandatory. The ID of the object you want to delete

πŸ“¨ body:

🧾 response:

βš™οΈ Status Code:

  (204) - No Content
  (404) - Not Found

πŸ“¬ Postman

πŸ“ Swagger

πŸ“« Routes for Stars

Return all objects (Stars)

  GET https://localhost:7267/api/v1/Stars

βš™οΈ Status Code:

  (200) - OK

πŸ“¬ Postman

πŸ“ Swagger

Return only one object (Star)

  GET https://localhost:7267/api/v1/Stars/${id}
Parameter Type Description
id int Mandatory. The ID of the object you want to view

βš™οΈ Status Code:

  (200) - OK
  (404) - Not Found

πŸ“¬ Postman

πŸ“ Swagger

Insert a new object (Star)

  POST https://localhost:7267/api/v1/Stars

πŸ“¨ body:

{
  "name": "Charles",
  "surname": "Hunnam",
  "nationality": "English",
  "birthDate": "1980-04-10T13:40:58.735Z",
  "wonOscar": false
}

🧾 response:

{
    "id": 4,
    "name": "Charles",
    "surname": "Hunnam",
    "nationality": "English",
    "birthDate": "1980-04-10T13:40:58.735Z",
    "wonOscar": false
}

βš™οΈ Status Code:

  (201) - Created
  (400) - Bad Request

πŸ“¬ Postman

πŸ“ Swagger

Update an object (Star)

  PUT https://localhost:7267/api/v1/Stars/${id}
Parameter Type Description
id int Mandatory. The ID of the object you want to update

πŸ“¨ body:

{
  "id": 4,
  "name": "Charles",
  "surname": "Hunnam",
  "nationality": "English",
  "birthDate": "1980-04-10T13:40:58.735Z",
  "wonOscar": false
}

🧾 response:

βš™οΈ Status Code:

  (204) - No Content
  (400) - Bad Request

πŸ“¬ Postman

πŸ“ Swagger

Delete an object (Star)

  DELETE https://localhost:7267/api/v1/Stars/${id}
Parameter Type Description
id int Mandatory. The ID of the object you want to delete

πŸ“¨ body:

🧾 response:

βš™οΈ Status Code:

  (204) - No Content
  (404) - Not Found

πŸ“¬ Postman

πŸ“ Swagger

πŸ”¨ Tools used

πŸ–₯️ Technologies and practices used

  • C# 10
  • .NET CORE 6
  • SQL SERVER
  • Entity Framework 7
  • Code First
  • Swagger
  • Fluent Validation
  • Repository Pattern
  • Unit Of Work Pattern
  • Dependency injection
  • POO

πŸ“– Features

Registration, Listing, Update and Removal