1 00:00:01,510 --> 00:00:04,470 In this video we're going to move over to our delete root handler. 2 00:00:04,510 --> 00:00:08,470 Remember that is going to be in charge of cancelling a new order. 3 00:00:08,470 --> 00:00:10,300 We're going to go through the same process over there. 4 00:00:10,390 --> 00:00:14,590 But rather than publishing an order created event we're going to publish an order cancel the events. 5 00:00:14,650 --> 00:00:15,710 So over inside of delete. 6 00:00:15,730 --> 00:00:16,320 Yes. 7 00:00:16,420 --> 00:00:26,760 At the very top we will import our order canceled publisher from up one directory events publishers 8 00:00:26,820 --> 00:00:33,450 order canceled the publisher will then also get our Nats wrapper from up one directory Nats wrapper 9 00:00:36,510 --> 00:00:38,880 do table check your spelling on order canceled right there. 10 00:00:38,880 --> 00:00:41,450 Easy place to make a typo. 11 00:00:41,560 --> 00:00:46,940 Once we got those imports together we'll go down to the comment we had left inside of here we'll create 12 00:00:46,940 --> 00:00:50,720 a new instance of the order canceled. 13 00:00:50,840 --> 00:00:58,320 Publisher and will pass into Nats client which is available through Nats rapper DCS client will then 14 00:00:58,320 --> 00:01:00,660 call publish on the publisher. 15 00:01:00,660 --> 00:01:04,650 And now on this object right here we have provide some information for the event's data. 16 00:01:05,100 --> 00:01:09,630 So we need to give the orders I.T. and the tickets I.D. as well. 17 00:01:09,750 --> 00:01:11,310 Well the orders idea is easy enough. 18 00:01:11,340 --> 00:01:18,510 So the I.T. order dot I.T. will then give the ticket property and there must be an I.D. inside there. 19 00:01:18,510 --> 00:01:20,400 Now this is going to be just a little bit tricky. 20 00:01:21,940 --> 00:01:25,990 If we look at the rest of this route handler you'll notice that we don't actually have a reference to 21 00:01:25,990 --> 00:01:28,190 the ticket that is associated with this order. 22 00:01:28,190 --> 00:01:31,330 And we do not even load it up when we fetch this order from the database. 23 00:01:31,540 --> 00:01:35,710 So we don't really know the idea that ticket to put inside of you right now. 24 00:01:35,710 --> 00:01:39,580 So to fix that up we're going to find where we make a query on the database to get some information 25 00:01:39,580 --> 00:01:46,500 about this order and we're going to make sure that we populate that ticket property so that when we 26 00:01:46,500 --> 00:01:50,260 fetch the order we will also get the associated ticket along with it. 27 00:01:50,700 --> 00:01:54,930 So now if we wanted to we could access order a ticket that would give us the ticket that we are looking 28 00:01:54,930 --> 00:01:55,430 for. 29 00:01:55,440 --> 00:02:00,810 And so in theory we could get the I.D. of that ticket by doing ticket dot I.D. 30 00:02:04,040 --> 00:02:05,760 gate so down inside this object right here. 31 00:02:05,810 --> 00:02:11,690 We'll put in order that ticket that I.D. case that should be it. 32 00:02:11,840 --> 00:02:17,460 Let's say this and now that we've got all this stuff put together we need to take a look at how we're 33 00:02:17,460 --> 00:02:19,710 going to get our tests running around these. 34 00:02:19,710 --> 00:02:24,420 So we should probably have some tests to make sure that we are publishing this event correctly and to 35 00:02:24,420 --> 00:02:27,140 make sure that we're publishing the order created event as well. 36 00:02:27,240 --> 00:02:32,550 Whenever we either create a new order or cancel in order let's start to fix up some tests in the next 37 00:02:32,550 --> 00:02:32,900 video.