Git Product home page Git Product logo

cleanmovie's Introduction

CleanMovie

  1. Create a class library for CleanMovie.Domain and Name the solution CleanMovie
  • What is a domain?
    • Things you do with/without having a software for a movie rental system, you are going to walk into the store and ask-" What are the movies you have?" They might show you a book that has a list of movies kept in the store. Once you choose, they are going to take some details of you and give you the movie. Here the domains are-> movie, customer details etc.
  1. Add a domain class named "Movie" into the project
  2. Create another class library named "CleanMovie.Applicaton"
    • What's for Application -> for business logics
  3. Add project reference of domain into application
  4. Add a new interface named "IMovieRepository" and add the methods you are going to use to fetch from the repository
  5. Add a new interface named "IMovieService" and this is going to be the use case for the domain movie
  6. Add a new class named "MovieService" and implement the methods from "IMovieService" and use IMovieRepository as an dependency injection
  7. Add a new project named "CleanMovie.Infrastructure"
    • Infrastructure is going to do the actual operations like

      • talking to database
      • talking to another api
      • talking to system clock
      • talking to file system
      • anything external to your domain
    • Domain does not depend on anything

    • Application depends on Domain, domain only talks to application

    • Infrastructure depends on Application

    • Presentation depends on Application layer

  8. Add Application project referenct to CleanMovie.Infrastructure project
  9. Add new class named "MovieRepository" and implement IMovieRepository from application project
  10. Add presentation layer which is webAPI project in the same directory
  11. Add Application project reference to the web api project
  12. Add controller named "MoviesController.cs" and add api method for getting movies using service from application
  13. Add dependency injection in the program for IMovieServie
  14. Add dependency injection in the program for IMovieRepository(for that we have to add Infrastructure project reference to the presentation layer as IMovieRepository is not defined which one to implement)

  1. Add nuget package "EntityFrameworkCore", "EntityFrameworkCore.Design", "EntityFrameworkCore.Tools" "EntityFrameworkCore.SqlServer" into infrastructure
  2. Add CreateMovie method into IMovieRepository
  3. Implement the method CreateMovie with noImplementation in MovieRepository
  4. Add CreateMovie method into IMovieService
  5. Implement the method CreateMovie with noImplementation in MovieService
  6. Add MovieDbContext class into Infrastructure and inherit DbContext and add Entity Movie
  7. Add constructor and inject MovieDbContext into MovieRepository class
  8. Rewrite the CreateMovie and GetAllMovies method with MovieDbContext and remove the static movie list
  9. Rewrite the CreateMovie method with the help of IMovieRepository object in MovieService class
  10. Add post api method in MoviesController.cs
  11. Add ConnectionStrings in appsettings.json in the CleanMovie.API
  12. Register Configurationmanager and add database service in the program file in the CleanMovie.API
  13. Add nuget package "EntityFrameworkCore.Tools" into API project
  14. Register the DbContext into services into program file
  15. Open Package manager Console And write command for adding migration
  • add-migration InitialMigration // for vs
  • dotnet ef migrations add InitialMigration // for vscode
  1. then update the database using this command
  • dotnet ef database update

  1. Add a class named class "Member" in cleanMovie.Api
  2. Add a class "Rental" in CleanMovie.API
  3. Modify the class "Movie"
  • Modifying this class is going to make problem on migrations, so I deleted the db and migration folder for not having the problem
  1. Add a class named "MovieRental" in CleanMovie.API
  2. Go to MovieDbContext in the Infrastructure and add other Entities and add the overRide method to maintain the properties like primaryKey, foreignKey, decimals etc
  3. now add the migrations
  • dotnet ef migrations add AddedMoviesRentalMembers
  • dotnet ef database update -- this is going to make problem as there was already Movie entity in the db, so I deleted the migration folder and deleted the db and added the initial migration and update the db for shortcut resolve
  • dotnet ef migrations add InitialMigration
  • dotnet ef database update

dotnet ef migrations add MigrationName dotnet ef database update dotnet ef migrations remove

cleanmovie's People

Contributors

imtiaj-ahammad avatar

Watchers

Imtiaj Ahammad avatar  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.