The MovieApp in ASP.NET Core Web App (MVC).
- The .NET 8 SDK with the
ASP.NET
and web development workload.
The solution contains the release assets in the file assets.zip
(and full solution source code in source.zip
). The assets can be unzipped and this section can be skipped.
To build and run the project, open a command prompt to the root of the solution, and perform the following:
-
Run tests
dotnet test
-
Publish the Web project to a folder:
cd ./src/Movies.Web dotnet publish -o ../../assets/web cd ../..
-
Run the
scripts.sql
to create the database and related tables. NB: The solution uses the Express edition of the SQL Server. The connection string can be found insideappsettings.json
and be modified to any valid connection string.
-
To run the application, open command prompt to the
assets
folder created from the previous step (should be at the root of the solution), or extracted from theassets.zip
, and run the executable-
From the Web app Command Prompt:
cd ./web dotnet Movies.Web.dll --urls "https://localhost:50423"
-
-
Open your favourite browser and visit
https://localhost:50423
The application provides loosely coupled access to the data, i.e. the web frontend has no idea how to retrieve the underlying data. This allows us to switch to another service (e.g. an external API) without interrupting our application.
This houses the infrastructure for the data access.
This is the entry point for the web front-end application. This is the ASP.NET Core MVC web application, which is responsible for the UI logic. The app configurations are contained in the appsettings.json
file.
These house our project tests.
The system implements a simple concurrency via concurrency token, Version
. i.e. The data modification fail on save if the data has changed since it was queried.
In the code below, the [Timestamp]
attribute maps a property to a SQL Server rowversion
column. Since rowversion
automatically changes when the row is updated, this provides a very useful concurrency token with minimum-effort that protects the entire row.
public class Movie
{
public string Id { get; set; }
public string MovieName { get; set; } = default!;
[Timestamp]
public byte[] Version { get; set; }
}
The solution architecture uses the CQRS pattern (Command and Query Responsibility Segregation) together with the Unit of Work pattern.
CQRS pattern_: Separates write commands from read queries.
Unit of Work pattern_: Manages transactions and ensures that multiple operations are treated as a single logical unit, i.e. they should all succeed or fail. This guarantees data integrity and consistency in applications.