1
00:00:01,410 --> 00:00:02,970
So let's look at where we are right now.

2
00:00:03,060 --> 00:00:06,840
I'm going to make sure my application is running and just see what we have to do next.

3
00:00:07,620 --> 00:00:08,880
So I start the application.

4
00:00:08,890 --> 00:00:15,030
I go over to my favorite browser and choose the homepage, which is where I am, and make a reservation,

5
00:00:15,540 --> 00:00:21,450
choose any two dates, because I know that will show me something that's valuable and search.

6
00:00:21,690 --> 00:00:25,710
So we're here and I want this to be clickable.

7
00:00:25,740 --> 00:00:26,940
I want that to be a click.

8
00:00:26,940 --> 00:00:31,950
When I click on Generals' quarters, it takes me off the reservation page and before it shows me the

9
00:00:31,950 --> 00:00:39,360
page, it actually stores the fact that I want to stay in the generals quarters in my social variable

10
00:00:39,360 --> 00:00:41,000
called reservation that we did last time.

11
00:00:41,730 --> 00:00:45,570
So let's go back to the template and create a link.

12
00:00:46,470 --> 00:00:52,710
So I'm going to open up my template, choose room and I maybe will make this an unordered list for right

13
00:00:52,710 --> 00:00:53,070
now.

14
00:00:53,070 --> 00:00:58,530
So I'll wrap this whole thing in a U-Haul tag, which eventually I'll get to be able to typewrite.

15
00:01:01,300 --> 00:01:09,250
Get rid of that and put my closing, you will tag here and inside of here, the room name should be

16
00:01:09,250 --> 00:01:10,480
wrapped in an L.A. tag.

17
00:01:16,110 --> 00:01:19,520
And I want this to be a link, so what do I want this link to be?

18
00:01:19,530 --> 00:01:25,290
It can be anything I want, but I want to make sure that the link includes the ID of the room that is

19
00:01:25,290 --> 00:01:26,160
currently displaying.

20
00:01:26,160 --> 00:01:32,730
And I know I have that in the ID of the individual entries that I see as arranged through Rum's.

21
00:01:33,120 --> 00:01:42,000
So I can just say a F equals and I'll call this Chew's room, followed by the ID, which is Daudt ID

22
00:01:42,540 --> 00:01:48,570
and I just wrap it in my double curly braces so it pulls it out of the current iteration of the room's

23
00:01:48,570 --> 00:01:51,180
variable and ranging through and shows it there.

24
00:01:51,870 --> 00:02:01,320
And then I can just close this, opening a tag and of course close the whole attack right there so that

25
00:02:01,320 --> 00:02:06,570
when I, when I reload this page, if I save this and go back, I might be able to just reload here

26
00:02:06,990 --> 00:02:08,610
and say resend and there it is.

27
00:02:08,610 --> 00:02:09,330
Not quite right.

28
00:02:09,340 --> 00:02:10,820
So I've got a typo in there somewhere.

29
00:02:10,830 --> 00:02:11,810
Yes, there it is.

30
00:02:12,540 --> 00:02:13,850
Let's put that there.

31
00:02:14,550 --> 00:02:16,260
Save this looks right now.

32
00:02:16,260 --> 00:02:20,780
Reload this and I still have an extra tag somewhere.

33
00:02:20,790 --> 00:02:21,450
There it is.

34
00:02:24,590 --> 00:02:31,790
All right, that looks better now that I've created this Eurail choose dash room, followed by a number

35
00:02:32,070 --> 00:02:33,730
I need to create a route for it.

36
00:02:33,740 --> 00:02:37,730
So let's go back to our roots file and see how we're going to do that, because we haven't done this

37
00:02:37,730 --> 00:02:38,020
yet.

38
00:02:38,450 --> 00:02:40,100
So roots, they're there.

39
00:02:41,060 --> 00:02:44,360
I want to create a new route mux.

40
00:02:45,170 --> 00:02:51,170
It's a get route because I'm just clicking on a link to Choose Dasch room, and then I want the idea

41
00:02:51,180 --> 00:02:51,830
to go in there.

42
00:02:51,950 --> 00:02:53,390
And how am I going to do that?

43
00:02:53,420 --> 00:03:00,350
Well, the nice thing about this router, Krutch, the China key router is I can just do this, put

44
00:03:00,350 --> 00:03:04,820
parentheses around the a variable name of my own choosing.

45
00:03:04,820 --> 00:03:07,750
It could be whatever I wanted, but I chose it because it's a remedy.

46
00:03:08,840 --> 00:03:13,850
And what this route will match is choose Dasch room slash anything.

47
00:03:14,240 --> 00:03:17,510
And I want that to go to Handler's repo.

48
00:03:18,020 --> 00:03:24,520
And I'm need to create a new method or new function called Choose Room, which I will do right now.

49
00:03:24,530 --> 00:03:31,340
So let's go over to our handlers and create a new function, which I will call func.

50
00:03:31,340 --> 00:03:36,680
And it's going to have the repository receiver because I'm going to be using that and I'm calling it

51
00:03:36,680 --> 00:03:37,790
to choose room.

52
00:03:38,150 --> 00:03:46,300
And it takes a W, which is an active response writer and a pointer to a request and cdpr dot request.

53
00:03:46,790 --> 00:03:47,870
Now request.

54
00:03:50,020 --> 00:03:54,780
OK, so now I have this function, so my roots shouldn't show an error now, and it does not, what

55
00:03:54,780 --> 00:03:56,790
do I want to do in this function?

56
00:03:57,390 --> 00:04:04,050
Well, the very first thing I want to do is to get this part of the URL, the ID right here.

57
00:04:04,080 --> 00:04:09,700
I want to read that from the actual Eurail and receiving and store it as my remedy.

58
00:04:09,900 --> 00:04:11,820
That's the room that I'm currently choosing.

59
00:04:12,450 --> 00:04:18,990
So if this shows the general's quarters with an ID of one and somebody clicks on the link, I want to

60
00:04:18,990 --> 00:04:19,640
get the one.

61
00:04:19,830 --> 00:04:24,450
If they click on the major suite, which is an idea of two, this will be a two.

62
00:04:24,450 --> 00:04:26,270
When I click on it, I want to get the two.

63
00:04:26,940 --> 00:04:28,920
So let's go back to our handlers and see how we do that.

64
00:04:29,490 --> 00:04:33,330
Now, the nice thing about Chey is it has some helper methods that allows us to do this.

65
00:04:33,600 --> 00:04:36,390
So I'll say room ID, which is what I'm going to call the variable.

66
00:04:36,810 --> 00:04:41,870
And potentially an error is equal to sturgeons.

67
00:04:42,480 --> 00:04:46,500
We're going to convert a string from a into an integer, a two high.

68
00:04:47,520 --> 00:04:51,420
And inside of that, I'm going to call the helper function built into the router.

69
00:04:51,660 --> 00:04:54,510
So Chey dot Eurail Perram.

70
00:04:54,720 --> 00:04:56,400
You are L Perram.

71
00:04:56,880 --> 00:04:57,390
There it is.

72
00:04:57,390 --> 00:04:59,420
And that requires two arguments.

73
00:04:59,430 --> 00:05:05,790
It requires our request, which I have, and it requires the key, which is exactly what I called it

74
00:05:05,790 --> 00:05:07,190
in the Roots file.

75
00:05:07,530 --> 00:05:15,230
So I chose ID here because over in Roots it's ID inside those curly braces.

76
00:05:16,440 --> 00:05:19,440
So now I have the remedy that I need to check for an error.

77
00:05:19,500 --> 00:05:29,220
If error is not equal to nil, I'll just display a server error helper's server error W and then error

78
00:05:29,730 --> 00:05:30,280
and return.

79
00:05:31,230 --> 00:05:34,600
OK, so now I have my remedy and what am I going to do with that.

80
00:05:34,620 --> 00:05:42,060
Well I need to get that reservation variable I stored in the session somewhere in this function.

81
00:05:42,060 --> 00:05:43,500
I need to pull it out of the session.

82
00:05:43,500 --> 00:05:46,860
I need to update room ID which has a default value of zero.

83
00:05:47,040 --> 00:05:54,020
Stick the room ID in that correct place in that variable and then put the reservation back in session.

84
00:05:54,360 --> 00:06:01,440
So let's get the reservation rez and let's just see what we have, what are what we're going to return

85
00:06:01,440 --> 00:06:02,220
values our first.

86
00:06:02,220 --> 00:06:04,290
So I'll say Emden app.

87
00:06:06,400 --> 00:06:15,730
Dort session doget, and it requires the context, ARGT context, as usual, and it requires the key

88
00:06:15,970 --> 00:06:21,140
and the key I'm looking for is reservation and I'm pulling that out of there.

89
00:06:21,190 --> 00:06:22,300
Is that enough?

90
00:06:22,330 --> 00:06:24,310
Well, let's look at this jet function again.

91
00:06:24,320 --> 00:06:28,480
We haven't done this in a while, so it might be worthwhile looking at, again, get returns, the value

92
00:06:28,480 --> 00:06:30,340
for a given key from the session data.

93
00:06:30,610 --> 00:06:32,610
The return value has the type interface.

94
00:06:32,620 --> 00:06:33,390
Well, that's not good.

95
00:06:33,400 --> 00:06:35,590
I needed to be of type models, stock reservation.

96
00:06:35,950 --> 00:06:38,500
So we usually need to be type asserted before you can use it.

97
00:06:38,500 --> 00:06:44,980
For example, let's copy this example, OK, and go back to our handler and just paste it right below

98
00:06:44,980 --> 00:06:46,770
this and then modify it as necessary.

99
00:06:46,780 --> 00:06:51,520
First of all, let's get rid of the comments and format everything.

100
00:06:52,060 --> 00:06:55,180
And I will call this rez for reservation.

101
00:06:55,690 --> 00:06:57,400
And it's not coming out of session.

102
00:06:57,400 --> 00:07:00,490
It's coming out of Emden app dot session.

103
00:07:01,960 --> 00:07:03,820
And I'm not casting it to a string.

104
00:07:04,060 --> 00:07:08,770
I'm casting it to a model's reservation that are spell models.

105
00:07:08,770 --> 00:07:09,040
Right.

106
00:07:10,180 --> 00:07:10,960
Reservation.

107
00:07:11,590 --> 00:07:15,760
And it's not just ah, I need to get the context from our context.

108
00:07:16,710 --> 00:07:21,250
So now I've actually built this up and I have my reservation variable stored.

109
00:07:21,250 --> 00:07:25,210
I'm not using it yet and I have a not OK and not OK here.

110
00:07:25,240 --> 00:07:26,890
I can just do a server error.

111
00:07:27,100 --> 00:07:29,440
Something went wrong that's sufficient for right now.

112
00:07:30,430 --> 00:07:32,770
Now that I have this reservation, what do I want to do with it?

113
00:07:32,770 --> 00:07:37,000
I want to update the room ID to this variable remedy.

114
00:07:37,060 --> 00:07:45,400
I just do that by saying resort remedy equals ridi and then I put it back in the session and I can do

115
00:07:45,400 --> 00:07:47,050
that the same way I did up here.

116
00:07:47,200 --> 00:07:50,470
I can just up in one of the functions above.

117
00:07:50,470 --> 00:07:51,190
I'll just type it out.

118
00:07:51,400 --> 00:08:00,610
MoCap app session put and it requires the context, art context and it requires the key which I have

119
00:08:00,610 --> 00:08:03,040
to make exactly the same as I used before.

120
00:08:03,340 --> 00:08:04,570
And the value is Rets.

121
00:08:05,620 --> 00:08:07,120
Now I've put that back in session.

122
00:08:07,120 --> 00:08:11,080
So once they've clicked on this, what do I want to do next?

123
00:08:11,080 --> 00:08:16,690
At this point, I want to display the Make Reservation page so I can do that really easily.

124
00:08:16,690 --> 00:08:21,910
Let's find out how we display that reservation page, which is right up.

125
00:08:21,910 --> 00:08:24,160
Well, we'll do from the Roots files faster to get it that way.

126
00:08:24,400 --> 00:08:25,360
Make reservation.

127
00:08:25,360 --> 00:08:30,070
It's this page I want it to want to show so I can just redirect them to that page at this point.

128
00:08:30,100 --> 00:08:32,680
OK, so I'm going to copy that.

129
00:08:32,680 --> 00:08:40,720
You orl go back to choose room in my handlers, which is right here, the very bottom and paste.

130
00:08:40,720 --> 00:08:41,200
Oh sorry.

131
00:08:41,530 --> 00:08:46,210
Put in htp dot redirect which is right here.

132
00:08:48,140 --> 00:08:55,130
And it requires the W, the R, the Eurail, which I'll paste in and the code HDB dot status C other

133
00:08:55,130 --> 00:08:58,220
because it's in 300 range and that's a nice useful one.

134
00:08:58,460 --> 00:09:02,150
All the other 300 ranges probably are inappropriate, and that's all I have to do.

135
00:09:02,610 --> 00:09:03,200
I think.

136
00:09:03,500 --> 00:09:04,820
Let's start our application.

137
00:09:05,210 --> 00:09:06,020
So stop it.

138
00:09:06,170 --> 00:09:06,710
Start it.

139
00:09:09,600 --> 00:09:10,320
Did it compile?

140
00:09:11,260 --> 00:09:16,930
Yeah, it compiled let's go back to our Web browser and let's go back to the home page and start this

141
00:09:16,930 --> 00:09:18,190
process right from the beginning.

142
00:09:18,340 --> 00:09:19,420
Make a reservation now.

143
00:09:20,440 --> 00:09:22,650
So I'm searching for any two dates.

144
00:09:23,110 --> 00:09:27,340
Doesn't matter what they are in this case, because everything's available except for that little range

145
00:09:27,340 --> 00:09:28,040
in February.

146
00:09:28,090 --> 00:09:31,020
So I searched for it and then I click on Generals' quarters.

147
00:09:31,660 --> 00:09:32,080
All right.

148
00:09:32,200 --> 00:09:33,590
Didn't quite work.

149
00:09:33,730 --> 00:09:35,170
What went wrong?

150
00:09:35,200 --> 00:09:35,990
Well, let's find out.

151
00:09:37,810 --> 00:09:40,000
So I get this.

152
00:09:40,330 --> 00:09:41,920
Are there anything is there anything in the log file?

153
00:09:41,920 --> 00:09:42,430
There is.

154
00:09:42,430 --> 00:09:43,690
There is an error there.

155
00:09:43,810 --> 00:09:44,290
All right.

156
00:09:44,290 --> 00:09:52,990
The error is invalid memory address or nil pointer dereference in here from internal helpers, from

157
00:09:52,990 --> 00:09:53,530
handlers.

158
00:09:53,530 --> 00:09:53,960
Dok go.

159
00:09:53,980 --> 00:09:54,970
Let's see what that line is.

160
00:09:55,740 --> 00:09:56,860
Ah OK.

161
00:09:57,520 --> 00:09:58,930
Here I made a mistake.

162
00:09:58,930 --> 00:10:00,070
I left Fux in there.

163
00:10:00,070 --> 00:10:02,500
I'm not getting a reservation out of the session.

164
00:10:02,890 --> 00:10:05,320
I'm saying results.

165
00:10:05,320 --> 00:10:12,460
OK is reser invasion and then this line gets deleted altogether.

166
00:10:12,670 --> 00:10:13,930
So that was my mistake.

167
00:10:14,290 --> 00:10:15,340
Happens sometimes.

168
00:10:15,820 --> 00:10:18,460
Let's clear the screen and run it again.

169
00:10:20,730 --> 00:10:27,630
And try again, so we'll go back one screen, back one screen, reload this page, put in two dates

170
00:10:27,630 --> 00:10:31,440
just to make sure that it's getting the values and search.

171
00:10:31,440 --> 00:10:33,480
And this time I click on Major Sweep.

172
00:10:33,540 --> 00:10:34,930
That looks better.

173
00:10:35,070 --> 00:10:37,470
So now I need to fix this screen up.

174
00:10:37,830 --> 00:10:42,990
What I want to display next is I want to get rid of start date, end date and the hidden field that

175
00:10:42,990 --> 00:10:43,910
I have down here.

176
00:10:44,460 --> 00:10:48,690
Well, I might I shall leave that hidden field, but I'll probably have to work on it a little bit up

177
00:10:48,690 --> 00:10:51,690
at the top underneath where it says reservation details.

178
00:10:51,690 --> 00:10:56,760
I want to put start date and date and the room names and then ask for their first name, last name,

179
00:10:56,760 --> 00:10:57,720
email and phone.

180
00:10:57,930 --> 00:10:58,350
All right.

181
00:10:58,440 --> 00:11:01,080
We'll take care of that in the next lecture.
