Giter Site home page Giter Site logo

cinema-api's Introduction

CinemaApi

.NET Core EF Core PostgreSQL

About

  • A simple CinemaAPI using C# and .NET core API. The API allows users to create, read, update, and delete records of cinema in database

Endpoints:

  • GET /cinemas - to get a list of all cinemas
  • GET /cinemas/{id} - to retrieve a single cinema with id
  • GET /cinemas/{id}/showtimes – to get times when shows start
  • POST /cinemas - to create a new cinema
  • PUT /cinemas/{id} - to update a specific cinema by ID
  • DELETE /cinemas/{id} - to delete a specific cinema by ID

About Showtimes

The function receives four parameters:

  • Id - cinema Id
  • open - Hour at which the cinema opens.
  • close - Hour at which the cinema closes.
  • length - Length of the movie, in minutes.

The endpoint returns an array of tuples where each tuple includes hour and minute values. For instance, (19, 30) represents 19:30. The last session in the array must not end later than the cinema's closing time. The array is sorted from earliest to latest and a 15-minute break is required between the end of one session and the start of the next one to ensure sufficient time for the audience to settle in.

Technology

  • Backend: C#, .NET Core API, Entity Framework Core, PostgreSQL, Docker, xUnit testing.

Run the app with Docker

Ensure that you have Docker Desktop installed. Then run below commands on the terminal:

  • docker pull hunghoang108/cinemaapi
  • docker run -p 5000:80 cinemaapi:1.0.0

After the docker is run. you can access to the swagger ui with http://localhost:5000/swagger/index.html

Note: There will be some errors executing crud operations because the database hasn't been containerized

Run the app with Github codes

  • Step 1: Fork and clone the project to your local machine
  • Step 2: Cd to cinemaApi repository and install all nescessary nuget packages
  • Step 3: In the appsettings.Development.json file, add your local database address to DefaultConnection
  • Step 4: run command 'dotnet watch' to run the project

How to test the app

  • Step 1: Cd to cinemaApi.Test repository and install all nescessary nuget packages
  • Step 2: run command 'dotnet test'

Project Structure

ApiCinema
├─ .git
├─ .gitignore
├─ ApiCinema.sln
├─ cinemaApi
│  ├─ appsettings.Development.json
│  ├─ cinemaApi.csproj
│  ├─ Controllers
│  │  ├─ BaseController.cs
│  │  └─ CinemaController.cs
│  ├─ Database
│  │  └─ DataContext.cs
│  ├─ DTOs
│  │  └─ CinemaDto.cs
│  ├─ Helpers
│  │  └─ ServiceException.cs
│  ├─ Mapping
│  │  └─ MappingProfile.cs
│  ├─ Middlewares
│  │  └─ ErrorHandlerMiddleware.cs
│  ├─ Models
│  │  ├─ BaseModel.cs
│  │  └─ Cinema.cs
│  ├─ Program.cs
│  ├─ Properties
│  │  └─ launchSettings.json
│  ├─ Repositories
│  │  ├─ BaseRepo
│  │  │  ├─ BaseRepo.cs
│  │  │  └─ IBaseRepo.cs
│  │  └─ CinemaRepo
│  │     ├─ CinemaRepo.cs
│  │     └─ ICinemaRepo.cs
│  └─ Services
│     ├─ BaseService
│     │  ├─ BaseService.cs
│     │  └─ IBaseService.cs
│     └─ CinemaService
│        ├─ CinemaService.cs
│        └─ ICinemaService.cs
├─ cinemaApi.Test
│  ├─ cinemaApi.Test.csproj
│  ├─ CinemaRepoTests.cs
│  ├─ ShowTimesControllerTests.cs
│  └─ Usings.cs
└─ README.md

cinema-api's People

Contributors

hunghoang108 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.