10 SportsStore: Administration

 

This chapter covers

  • Building an interactive feature using Blazor
  • Implementing application features with Razor Components
  • Aligning component and service lifecycles
  • Validating data in a Razor Component
  • Performing create, read, update, and delete operations with Blazor

In this chapter, I continue to build the SportsStore application to give the site administrator a way to manage orders and products. In this chapter, I use Blazor to create administration features. Blazor combines client-side JavaScript code with server-side code executed by ASP.NET Core, connected by a persistent HTTP connection. I describe Blazor in detail in chapters 32–35, but it is important to understand that the Blazor model is not suited to all projects. (I use Blazor Server in this chapter, which is a supported part of the ASP.NET Core platform. There is also Blazor WebAssembly, which is, at the time of writing, experimental and runs entirely in the browser. I describe Blazor WebAssembly in chapter 36.)

Tip

You can download the example project for this chapter—and for all the other chapters in this book—from https://github.com/manningbooks/pro-asp.net-core-7. See chapter 1 for how to get help if you have problems running the examples.

10.1 Preparing Blazor Server

The first step is to enable the services and middleware for Blazor, as shown in listing 10.1.

10.1.1 Creating the imports file

10.1.2 Creating the startup Razor Page

10.1.3 Creating the routing and layout components

10.1.4 Creating the Razor Components

10.1.5 Checking the Blazor setup

10.2 Managing orders

10.2.1 Enhancing the model

10.2.2 Displaying orders to the administrator

10.3 Adding catalog management

10.3.1 Expanding the repository

10.3.2 Applying validation attributes to the data model

10.3.3 Creating the list component

10.3.4 Creating the detail component

10.3.5 Creating the editor component

10.3.6 Deleting products

Summary