1 00:00:00,960 --> 00:00:03,150 We've now successfully purchased our first ticket. 2 00:00:03,300 --> 00:00:06,900 So for me personally, I have purchased first client ticket right here. 3 00:00:07,410 --> 00:00:11,520 If I view that ticket and try to purchase it again, I am told ticket is already reserved. 4 00:00:12,000 --> 00:00:16,500 So as I mentioned at the end of last video, we should probably try to filter this list right here and 5 00:00:16,500 --> 00:00:18,810 only show tickets that are still available for purchase. 6 00:00:19,440 --> 00:00:24,450 So to do so, we can open up our ticket service, find the route handler that is serving up a list of 7 00:00:24,450 --> 00:00:29,640 tickets and probably alter the query that we are making inside there so that we only return tickets 8 00:00:29,640 --> 00:00:30,780 that are still available. 9 00:00:32,150 --> 00:00:34,580 Back inside my editor, I'm going to find the ticket service. 10 00:00:35,600 --> 00:00:38,810 Inside there, I'll find the Roots folder and then index to yes. 11 00:00:39,530 --> 00:00:44,330 So this is the root handler that we are making a request to you whenever we get that big list of tickets. 12 00:00:44,810 --> 00:00:46,700 And this is the query that we are actually issuing. 13 00:00:47,770 --> 00:00:54,020 So you might recall from our models ticket to yes, file are different ticket documents, might have 14 00:00:54,050 --> 00:00:55,270 an order I.D. property. 15 00:00:55,590 --> 00:01:00,290 It is the presence of that order I.D. property that indicates that a ticket is currently reserved and 16 00:01:00,290 --> 00:01:01,190 cannot be ordered. 17 00:01:02,110 --> 00:01:06,410 So when we write out the query back inside of our root handler to find a list of all of the different 18 00:01:06,410 --> 00:01:10,850 tickets, we can add on a little filter or a little bit of criteria for the query. 19 00:01:11,240 --> 00:01:16,790 We could say only give us tickets where the order I.D. property is undefined or essentially not set. 20 00:01:17,880 --> 00:01:23,640 Inside that object, I'm going to put in order I.D. on defined find all the tickets that don't have 21 00:01:23,640 --> 00:01:24,570 a corresponding order. 22 00:01:25,700 --> 00:01:26,290 Let's save that. 23 00:01:27,250 --> 00:01:33,110 And now if I look back over, refresh the page, I'll see only the ticket remaining that I've not created 24 00:01:33,130 --> 00:01:33,840 an order for. 25 00:01:34,690 --> 00:01:39,730 If I now view that ticket book on purchase, I have created an order for that. 26 00:01:40,420 --> 00:01:44,410 And if I go back over to my big list of tickets now, that big list is empty. 27 00:01:45,370 --> 00:01:46,900 As soon as that order expires. 28 00:01:46,960 --> 00:01:47,980 So I'm not going to pay for it. 29 00:01:48,190 --> 00:01:50,750 I'm going to let it expire and as soon as it expires. 30 00:01:50,770 --> 00:01:54,970 If I then refresh this page, I should see that ticket up here, back on this list. 31 00:01:56,220 --> 00:01:57,910 That was a pretty straightforward solution. 32 00:01:59,200 --> 00:02:03,700 Now, we still have a little bit of stuff to take care of inside of our app, for example, I would 33 00:02:03,730 --> 00:02:08,770 really like to have some links inside the header, so maybe a link right here to create a new ticket. 34 00:02:08,800 --> 00:02:10,860 That's really the goal of this sell tickets link. 35 00:02:11,480 --> 00:02:16,030 We should probably also list out all the different orders that the user has successfully created and 36 00:02:16,030 --> 00:02:16,540 paid for. 37 00:02:17,540 --> 00:02:22,340 So will it create one last page to handle a listing of my orders or orders that correspond to a very 38 00:02:22,340 --> 00:02:24,650 particular user was still a little bit left? 39 00:02:24,860 --> 00:02:26,510 Let's continue in just a moment.