Mini Movie Database
Overview
The ConsoleApp.MiniMovieDatabase is a console-based application designed to manage a simple movie database. It allows users to perform CRUD (Create, Read, Update, Delete) operations on movie records.
Key Components
-
Movie Class:
- Represents a movie entity with properties such as
Title,Director,ReleaseYear, andGenre. - Example:
public class Movie { public string Title { get; set; } public string Director { get; set; } public int ReleaseYear { get; set; } public string Genre { get; set; } }
- Represents a movie entity with properties such as
-
MovieRepository Class:
- Manages a collection of movies.
- Provides methods to add, view, update, and delete movies.
- Example methods:
public void AddMovie(Movie movie) { ... } public Movie GetMovie(string title) { ... } public void UpdateMovie(string title, Movie updatedMovie) { ... } public void DeleteMovie(string title) { ... }
-
MovieService Class:
- Acts as an intermediary between the console application and the
MovieRepository. - Contains business logic to ensure data integrity and validation before performing repository operations.
- Example methods:
public void AddMovie(Movie movie) { ... } public void DisplayAllMovies() { ... } public void UpdateMovie(string title, Movie updatedMovie) { ... } public void RemoveMovie(string title) { ... }
- Acts as an intermediary between the console application and the
-
Console Interface:
- Provides a user interface for interacting with the movie database.
- Handles user input and displays information to the user.
- Example interaction:
Console.WriteLine("Enter movie title:"); string title = Console.ReadLine();
Example Usage
-
Adding a Movie:
var movie = new Movie { Title = "Inception", Director = "Christopher Nolan", ReleaseYear = 2010, Genre = "Sci-Fi" }; movieService.AddMovie(movie);
-
Viewing Movies:
movieService.DisplayAllMovies();
-
Updating a Movie:
var updatedMovie = new Movie { Title = "Inception", Director = "Christopher Nolan", ReleaseYear = 2010, Genre = "Science Fiction" }; movieService.UpdateMovie("Inception", updatedMovie);
-
Deleting a Movie:
movieService.RemoveMovie("Inception");
Conclusion
The ConsoleApp.MiniMovieDatabase provides a straightforward way to manage movie records through a console interface, demonstrating basic principles of object-oriented programming and CRUD operations.