From the course: ASP.NET MVC: Building for Productivity and Maintainability
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Creating the handler
From the course: ASP.NET MVC: Building for Productivity and Maintainability
Creating the handler
- [Narrator] In the previous video, I showed you how to configure the MediatR library. In this video, I'll show you how to modify the service class from last chapter so that the MediatR library can call it to process requests. The MediatR library defines a common interface that any service must implement in order to be able to handle mediated requests. It's appropriately name MediatR.IRequestHandler. (keyboard typing) And it has a few different variations, depending on how the service behaves. The first variation accepts a single type which indicates the type of the request that this service handles. In our case, that would be the UpdateProductRequest type. This is the variation you use for a handler that simply reacts to a request and doesn't return a response. However, since the inventory controller that calls this expects a response from the product service, we'll use the second variation which looks like this. (keyboard typing) This variation has a second type parameter that…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.