From 39290cd8d47c6da37c30b24eb0f102fd8bd542af Mon Sep 17 00:00:00 2001 From: David Boike Date: Thu, 31 Oct 2024 13:26:39 -0500 Subject: [PATCH] Update exercise README that contains ViewModelComposition code --- exercises/01-composite-ui/README.md | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/exercises/01-composite-ui/README.md b/exercises/01-composite-ui/README.md index 4ae8eb8f..d42d6b41 100644 --- a/exercises/01-composite-ui/README.md +++ b/exercises/01-composite-ui/README.md @@ -88,27 +88,20 @@ In the `Divergent.Finance.ViewModelComposition` project, add a new class named ` Add the following code to the class ```csharp +using System.Net.Http; using Divergent.Sales.ViewModelComposition.Events; using ITOps.Json; -using ITOps.ViewModelComposition; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using System; -using System.Net.Http; +using Microsoft.AspNetCore.Mvc; +using ServiceComposer.AspNetCore; namespace Divergent.Finance.ViewModelComposition; -public class OrdersLoadedSubscriber : ISubscribeToCompositionEvents +public class OrdersLoadedSubscriber : ICompositionEventsSubscriber { - // Very simple matching for the purpose of the exercise. - public bool Matches(RouteData routeData, string httpMethod) => - HttpMethods.IsGet(httpMethod) - && string.Equals((string)routeData.Values["controller"], "orders", StringComparison.OrdinalIgnoreCase) - && !routeData.Values.ContainsKey("id"); - - public void Subscribe(IPublishCompositionEvents publisher) + [HttpGet("/orders")] + public void Subscribe(ICompositionEventsPublisher publisher) { - publisher.Subscribe(async (pageViewModel, ordersLoaded, routeData, query) => + publisher.Subscribe(async (ordersLoaded, httpRequest) => { var orderIds = string.Join(",", ordersLoaded.OrderViewModelDictionary.Keys);