Skip to content

kusl/mymodelviewpresenter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

.NET Modernization & MVP Pattern Demo

A comprehensive repository demonstrating the evolution of a .NET application from a legacy Web Forms architecture using the Model-View-Presenter (MVP) pattern to a modernized, container-ready Blazor application.

🏗️ Repository Overview

This repository is split into two main project tracks to demonstrate modernization strategies:

1. Legacy Track: MyModelViewPresenter

A "legacy" simulated application built using ASP.NET Web Forms (.NET Framework 4.8). It implements a strict MVP pattern to decouple business logic from the Web Forms lifecycle.

  • Core: Domain entities (Product.cs) and repository/service contracts.
  • Infrastructure: Data access via SQLite and Dapper, including a simple custom IoC container for Dependency Injection.
  • Presentation: Contains the Presenters and View interfaces that drive the UI.
  • Web: The actual ASP.NET Web Forms project (.aspx pages).

2. Modernized Track: MVPModernized

A modern take on the same functional requirements using .NET 9 and Blazor.

  • ProductApp.Domain: Clean domain models.
  • ProductApp.Application: Application services and business logic.
  • ProductApp.Infrastructure: Modern data persistence.
  • ProductApp.Web: A modern Blazor Web UI.

📁 Directory Structure

├── source
│   ├── MyModelViewPresenter/      # Legacy Web Forms Track
│   │   ├── Core/                  # Domain entities & Interfaces
│   │   ├── Infrastructure/        # SQLite Repositories & DI Container
│   │   ├── Presentation/          # MVP Presenters & View Interfaces
│   │   └── Web/                   # ASP.NET Web Forms UI
│   ├── MVPModernized/             # Modern .NET 9 Track
│   │   ├── ProductApp.Domain/     # Modern Domain Layer
│   │   ├── ProductApp.Application/ # Business Logic
│   │   ├── ProductApp.Infrastructure/ # Data Access
│   │   └── ProductApp.Web/        # Blazor Web Application
│   └── Denormalization/           # Support utilities & Docker tools


🎯 Architecture & Design Patterns

Model-View-Presenter (MVP) Implementation

The legacy project demonstrates how to make Web Forms maintainable and testable:

  • Model: Encapsulated in the ProductService and ProductRepository.
  • View: ASP.NET .aspx pages implement a C# interface (e.g., IProductView).
  • Presenter: A pure C# class that handles events from the View and interacts with the Service layer.

Clean Architecture (Modern Track)

The modern track moves toward a layered architecture:

  • Decoupling: Infrastructure and UI both depend on the Application and Domain layers.
  • Testability: Designed for easy unit and E2E testing.

SOLID Principles Applied

  • Single Responsibility: Separate classes for data access, business logic, and UI orchestration.
  • Dependency Inversion: High-level modules depend on abstractions (Interfaces), not concrete implementations.

🚀 Getting Started

Prerequisites

  • Visual Studio 2022 or JetBrains Rider.
  • .NET Framework 4.8 (for Legacy track).
  • .NET 9 SDK (for Modern track).
  • SQLite (used as the database for both tracks).

Running the Legacy App

  1. Open source/MyModelViewPresenter/MyModelViewPresenter.sln.
  2. Set the Web project as the Startup Project.
  3. The SQLite database is automatically initialized in App_Data/products.db on the first run.

Running the Modernized App

  1. Open source/MVPModernized/MVPModernized.sln.
  2. Run the ProductApp.Web project.

🧪 Testing

The repository includes multiple testing strategies:

  • Unit Tests: Located in ProductApp.Tests, focusing on service logic.
  • E2E Tests: Found in ProductApp.Tests.E2E, utilizing Playwright for automated browser testing.

🛠️ CI/CD Workflows

The project includes GitHub Action workflows for both tracks:

  • build.yml: Handles MSBuild and NuGet restoration for the .NET Framework legacy app.
  • mvp-modernized-ci.yml: A modern CI pipeline for .NET 9, including unit tests, Playwright E2E tests, and code analysis.

📊 Future Enhancements

  • Implementing a REST API layer for the legacy application to support a "Strangler Fig" migration pattern.
  • Adding containerization (Docker) for the modernized Blazor application.
  • Integrating a centralized logging framework (Serilog/NLog).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published