In this episode, Jeffrey shows how to implement a Model View Controller pattern in Blazor WebAssembly using the BlazorMVC library.
Code sample: https://github.com/jeffreypalermo/onion-architecture-dotnet-6/
To recap previous episodes- We’ve been doing a lot with our sample application, a church bulletin application, that would print bulletins for a church service or project all the events happening at the church on a screen- Bible studies, events, etc. It’s a very simple application right now in Blazor WebAssembly.
We’ve done a lot with the structure of this application. The previous episodes will show you a multi-part series on things like how to implement onion architecture; the proper visual studio solutions structure; automated builds; integration tests; unit tests; the private build. Jeffrey goes through getting the build running as an integration build on both Azure Pipelines and GitHub actions. Be sure to check them out!
In this episode, Jeffrey is going to refactor some of the default templates in a Blazor WebAssembly new project template and he’s going to pull out the controlling logic from the view logic. He’s going to use a library called Blazor MVC to implement a model view controller pattern into this application so that, as you move forward, you don’t end up with super huge Blazor component files that have decision logic and code working with data mixed in the same file as HTML code and CSS code, essentially making the screen look like it’s supposed to look.
MVC is a really old pattern and if you’ve never heard of MVC before, do a little bit of research on the history of the model view controller pattern going back to the 1970s. This episode assumes you have some knowledge of the pattern. You will learn how to pull out the logic that works with data and decision tree logic. You will learn how to separate controllers from views and see how that’s implemented using the Blazor MVC open source library that’s available on NuGet.