1
00:00:02,010 --> 00:00:07,710
So now we want to improve our calendar, we want it to when we were looking at a given month, if there

2
00:00:07,710 --> 00:00:13,860
is a block, if the owner is closed, the room for, say, these three dates for the generals quarters

3
00:00:13,860 --> 00:00:20,160
for the seventh, eighth and ninth of December, these should show up checked.

4
00:00:20,700 --> 00:00:25,530
And if there's a reservation, say, on the second and third, we shouldn't see checkboxes at all.

5
00:00:25,530 --> 00:00:30,360
We should see some indication that there is a reservation for those dates and clicking on it should

6
00:00:30,360 --> 00:00:31,610
take us to that reservation.

7
00:00:32,160 --> 00:00:32,910
So let's get started.

8
00:00:33,840 --> 00:00:41,030
So right now in our handler over here, let's find our handlers right here.

9
00:00:41,670 --> 00:00:46,920
So I'm inside the handlers file looking at the admin reservations calendar method or function.

10
00:00:47,520 --> 00:00:49,140
And right now I have the rooms.

11
00:00:49,590 --> 00:00:52,350
I have the room stored in this variable rooms.

12
00:00:52,890 --> 00:01:01,590
And what I want to do is to somehow store information about the current blocks and the current reservations

13
00:01:02,370 --> 00:01:08,190
in a data structure that I can pass to my template so I can use that to determine how to render the

14
00:01:08,190 --> 00:01:08,690
calendar.

15
00:01:09,090 --> 00:01:12,270
So if you look back at the calendar, there's a couple of ways you might do this.

16
00:01:12,450 --> 00:01:18,990
You could say write a function and add it to our render package that says every time you're about to

17
00:01:18,990 --> 00:01:24,670
render this particular cell, say, call a function to say, is there a reservation for this date?

18
00:01:24,780 --> 00:01:26,040
If so, do something.

19
00:01:26,250 --> 00:01:32,070
And then if there's not called another function to say, is there a block for this date and if so,

20
00:01:32,070 --> 00:01:35,430
do something, and if not, just display an empty checkbox.

21
00:01:36,270 --> 00:01:43,080
But if you think that through, that would mean since there are 31 days in this month and two rooms,

22
00:01:43,260 --> 00:01:48,360
that's a total of 62 dates to check and two function calls on each of those dates.

23
00:01:48,510 --> 00:01:52,110
So that be two times, 31 times two, which is a big number.

24
00:01:52,110 --> 00:01:54,840
That's an awful lot of database queries to perform.

25
00:01:55,290 --> 00:01:56,930
And it's really not that efficient.

26
00:01:57,540 --> 00:02:03,180
It might be much more useful if we could get all of that information and stored in some data structure,

27
00:02:03,180 --> 00:02:09,750
say, a map, for example, and use that to determine how to render a given cell for a given date,

28
00:02:09,750 --> 00:02:10,590
for a given room.

29
00:02:10,980 --> 00:02:12,920
And I think that's a far more efficient method.

30
00:02:13,200 --> 00:02:14,660
So let's get started doing that.

31
00:02:15,210 --> 00:02:21,090
I'm going to go back here and I'm going to range through this room's variable that I have.

32
00:02:21,090 --> 00:02:25,260
So for and I'm going to ignore the index and just call the variable.

33
00:02:25,260 --> 00:02:28,590
I'm going to look at X range rooms.

34
00:02:29,790 --> 00:02:32,640
And inside of that I'm going to create two maps.

35
00:02:32,640 --> 00:02:40,020
And the very first map I'm going to create is for reservations and the next one will be for the actual

36
00:02:41,970 --> 00:02:42,480
blocks.

37
00:02:42,930 --> 00:02:46,170
So let's create two maps, create maps.

38
00:02:46,500 --> 00:02:55,380
The first one is going to be called reservation map and it will be assigned the value of make map string.

39
00:02:55,380 --> 00:03:00,780
And that's how we'll look it up and I'll just store in there and it and let's duplicate this line and

40
00:03:00,780 --> 00:03:02,220
create a block map.

41
00:03:05,660 --> 00:03:13,190
OK, so now that I have these created, how am I going to get the information for you in this map useful?

42
00:03:13,220 --> 00:03:18,110
Well, the first thing I need to do is make sure that there's one entry for every single day in the

43
00:03:18,110 --> 00:03:22,350
current month in both the reservation map and the block map.

44
00:03:22,370 --> 00:03:26,150
That means I need to somehow loop over all the days of the month.

45
00:03:26,180 --> 00:03:28,910
Well, if you recall, we already know what the first day of the month is.

46
00:03:28,910 --> 00:03:31,280
We have it here and we know what the last day of the month is.

47
00:03:31,280 --> 00:03:32,000
We have it here.

48
00:03:32,450 --> 00:03:38,900
So let's just do a for loop and we'll do this, not looping through INTs, but instead looping through

49
00:03:38,930 --> 00:03:40,600
dates, which we haven't done yet.

50
00:03:40,640 --> 00:03:41,440
But isn't that hurt?

51
00:03:42,170 --> 00:03:46,760
So for my variable will be called D, and that's going to be equal to the first of the month.

52
00:03:48,080 --> 00:03:52,330
And I want to go until I'm not after the last day of the month.

53
00:03:52,940 --> 00:04:00,380
So since it's a date, I can just say dot after and I can use my variable last of month if that's equal

54
00:04:00,380 --> 00:04:00,980
defaults.

55
00:04:01,370 --> 00:04:05,330
While that's while we're not after the last day of the month, keep going.

56
00:04:05,760 --> 00:04:10,100
And every time you iterate through the through the loop, add one to the current day.

57
00:04:11,120 --> 00:04:12,170
Didn't add date.

58
00:04:14,310 --> 00:04:21,780
Zero years, zero months and one day and what I'm going through, this just put a default value in in

59
00:04:21,780 --> 00:04:27,270
both the reservation map, reservation map for the current day.

60
00:04:27,270 --> 00:04:28,860
And I'm going to use this as a string.

61
00:04:28,890 --> 00:04:30,180
This is how we're going to look things up.

62
00:04:30,180 --> 00:04:38,100
So current is D format and my format string will be a four digit year, a two digit month and a one

63
00:04:38,100 --> 00:04:39,360
or two digit day.

64
00:04:39,780 --> 00:04:44,190
And that's going to be equal to zero, which will say this room is available and don't do the same thing

65
00:04:44,670 --> 00:04:45,570
for the block map.

66
00:04:47,580 --> 00:04:54,840
OK, so now I've initialized both of these reservation maps, each of these maps has an entry for every

67
00:04:54,840 --> 00:05:00,930
day of the current month and the value is zero and the lookup is a string.

68
00:05:00,930 --> 00:05:05,280
That would be the four digit year, followed by a hyphen, followed by a two digit month, followed

69
00:05:05,280 --> 00:05:09,050
by a hyphen followed by a one or two digit day.

70
00:05:09,990 --> 00:05:14,910
So that will be how we look things up, which is extremely convenient, because on this calendar, I

71
00:05:14,910 --> 00:05:16,530
know what the current year is.

72
00:05:16,530 --> 00:05:21,060
I have a value that I'm storing in the string map called current year, and I have another one for the

73
00:05:21,060 --> 00:05:27,660
current month so I can actually build the date as I'm iterating through my range.

74
00:05:27,660 --> 00:05:29,630
That gives me this table in the first place.

75
00:05:30,300 --> 00:05:31,680
So that's how we're going to look things up.

76
00:05:32,220 --> 00:05:40,710
Now that we have this done, we need next to get all the restrictions for the current ramp and that

77
00:05:40,710 --> 00:05:46,110
means we need a database function to do that and we don't have one that does that yet, but we can do

78
00:05:46,110 --> 00:05:47,430
it really, really easily.

79
00:05:48,480 --> 00:05:50,610
So let's go over to our postgrads Dongo.

80
00:05:51,270 --> 00:05:57,210
And at the very bottom of this file, I will create a new function, which I will call func.

81
00:05:57,210 --> 00:06:00,450
It'll have the receiver of Postgres DB Repo.

82
00:06:02,910 --> 00:06:11,390
And I'll call it get restrictions for room by day, and it will have to have three parameters.

83
00:06:11,400 --> 00:06:13,970
First of all, what room are we dealing with the remedy?

84
00:06:13,980 --> 00:06:19,740
And that's an end and then the start date we want to look at and the end date we want to look at, both

85
00:06:19,740 --> 00:06:21,720
of those will be of type time, time.

86
00:06:21,960 --> 00:06:26,490
And I'm going to return a slice of model's room restriction.

87
00:06:28,020 --> 00:06:29,190
And potentially an error.

88
00:06:30,260 --> 00:06:36,900
OK, so as I always do, I'm going to copy the context code so I don't have to retype it pasted in here.

89
00:06:37,410 --> 00:06:38,720
And now we need to write the query.

90
00:06:38,970 --> 00:06:41,010
Well, we need some to store the information first.

91
00:06:41,010 --> 00:06:47,810
So let's create a variable called restrictions of type slice models, dot room restriction.

92
00:06:49,050 --> 00:06:50,210
And now let's write our query.

93
00:06:50,220 --> 00:06:51,780
And this is a really easy query.

94
00:06:51,810 --> 00:06:59,040
It's pretty much the same syntax that we've used for other lookups or queries that deal with the reservations

95
00:06:59,040 --> 00:07:01,760
and blocks and so forth, availability queries, in other words.

96
00:07:02,340 --> 00:07:07,500
So I'm going to select I will select ID and then I need the reservation ID.

97
00:07:10,330 --> 00:07:16,080
If it exists and it might be null and I'm going to talk about that in a moment, and we need the restriction

98
00:07:16,090 --> 00:07:24,280
ID and we need the remedy and we need the start date and we need the end date and we're going to get

99
00:07:24,280 --> 00:07:27,250
all of that from room restrictions.

100
00:07:29,640 --> 00:07:37,710
Where and this is the same logic we used before, so our start date is less than the end date and our

101
00:07:37,860 --> 00:07:41,280
end date is greater than or equal to the start date.

102
00:07:44,560 --> 00:07:48,800
And the remedy is equal to whatever we're passing it.

103
00:07:48,850 --> 00:07:49,600
So that's our query.

104
00:07:50,380 --> 00:07:53,770
OK, now let's get our Rose.

105
00:07:53,890 --> 00:08:04,840
Rose Air is a sign the value of IMDB dot query context handed the context and did our query, handed

106
00:08:04,840 --> 00:08:08,170
our start, handed our end and our remedy.

107
00:08:10,480 --> 00:08:18,350
If error is not equal to nil, then just return nil and the error otherwise answer it.

108
00:08:19,030 --> 00:08:20,770
So we've got to defer our rose close here.

109
00:08:25,910 --> 00:08:28,130
And for Rose next.

110
00:08:30,020 --> 00:08:36,680
We create an empty variable to hold the restrictions of our hour is of type models, room restriction.

111
00:08:38,970 --> 00:08:46,980
And scan error is a sign the value of rose dot scan and will scan into that variable we just created

112
00:08:47,430 --> 00:08:53,490
and we're going to put in to the variable error ID and I'll just duplicate this a few times, as I usually

113
00:08:53,490 --> 00:08:53,840
do.

114
00:08:54,540 --> 00:08:56,740
And our second value was the reservation ID.

115
00:08:56,760 --> 00:08:59,690
Now that might be a problem and I'll talk about that in a moment.

116
00:09:01,200 --> 00:09:05,790
And the restriction ID and the remedy.

117
00:09:07,600 --> 00:09:11,320
And the start date and the Endi.

118
00:09:14,020 --> 00:09:22,330
OK, so here's the problem, if you think about what's in the room restrictions table, we don't always

119
00:09:22,330 --> 00:09:23,860
have a value for reservation.

120
00:09:24,700 --> 00:09:28,980
So let me go look at post code and show you what I'm talking about.

121
00:09:28,990 --> 00:09:33,940
So make sure I'm on the right database, go to bookings, look at room restrictions.

122
00:09:34,420 --> 00:09:38,200
And here we have room restrictions.

123
00:09:41,330 --> 00:09:42,170
It's not the right one.

124
00:09:43,100 --> 00:09:50,450
Yes, it is reservation, if you look at this, all of these ones have a null for a value and they should

125
00:09:50,450 --> 00:09:53,050
because they're blocks, they're not actual reservations.

126
00:09:53,090 --> 00:09:59,690
Those are dates and rooms where the property owner has decided not to rent the room for that particular

127
00:09:59,690 --> 00:10:00,310
date range.

128
00:10:00,500 --> 00:10:08,240
So they're all null it back here in my query when I try to get reservation ID, if it's in.

129
00:10:08,240 --> 00:10:14,570
No, I'm trying to store a null value into this very this field of this variable reservation ID of the

130
00:10:14,570 --> 00:10:19,970
variable hour, which is of type models, room restriction and go will not let you do that because a

131
00:10:19,970 --> 00:10:22,940
null is not an int and it wants an int.

132
00:10:23,930 --> 00:10:29,240
So I need to make some determination as to what to do with that null value.

133
00:10:29,270 --> 00:10:30,760
Unfortunately it's really, really easy.

134
00:10:30,770 --> 00:10:32,060
There's a couple of ways of doing it.

135
00:10:32,330 --> 00:10:38,330
Go has a null int type that I can use, but I find that a real pain and tend to avoid it whenever I

136
00:10:38,330 --> 00:10:39,150
possibly can.

137
00:10:39,290 --> 00:10:41,210
I find this approach works really well.

138
00:10:41,510 --> 00:10:44,270
I use one of the built-In features that's available in sequel.

139
00:10:44,270 --> 00:10:45,260
It's called Coalesce.

140
00:10:47,350 --> 00:10:48,370
And what I'm going to do.

141
00:10:50,180 --> 00:10:53,290
Is change my query as follows?

142
00:10:56,560 --> 00:11:03,900
I say, if reservation ID has a value and that value is not null, use it, otherwise use zero.

143
00:11:04,210 --> 00:11:09,430
And that's perfect for my purposes because I can store zero, which is an entry down here.

144
00:11:09,430 --> 00:11:10,110
No problem.

145
00:11:10,540 --> 00:11:12,700
And if it has, he actually has a reservation.

146
00:11:12,700 --> 00:11:17,000
I'll store the ID for that reservation instead and that solves my problem.

147
00:11:17,680 --> 00:11:18,150
All right.

148
00:11:18,160 --> 00:11:19,500
So let's check for an error.

149
00:11:20,100 --> 00:11:23,380
I'll just copy this if areacode paste it here.

150
00:11:23,560 --> 00:11:27,850
If there is no error, I will take, which is are not error.

151
00:11:32,230 --> 00:11:40,150
If I get past that, there's no air, so I can just say restrictions equals append restrictions and

152
00:11:40,150 --> 00:11:40,390
earn.

153
00:11:42,090 --> 00:11:46,830
And that will take care of that and then, of course, as I always do, I'll check to make sure one

154
00:11:46,830 --> 00:11:49,620
last time if error is equal to.

155
00:11:50,990 --> 00:11:53,390
If error equals Rove's error.

156
00:11:55,910 --> 00:11:57,820
And air is not equal to nil.

157
00:11:58,370 --> 00:12:06,950
Then something went wrong, so I'll just return nil and error, otherwise return the data that we just

158
00:12:06,950 --> 00:12:10,700
got, return restrictions and nil.

159
00:12:11,480 --> 00:12:13,420
OK, so I've created this.

160
00:12:13,430 --> 00:12:18,200
Let's give it its comment as it should have, and then add it to the repository and added to our DNA

161
00:12:18,800 --> 00:12:25,940
testing be rebuilt returns, restrictions

162
00:12:28,790 --> 00:12:31,400
for a room by date range.

163
00:12:32,900 --> 00:12:34,190
And let's copy the whole thing.

164
00:12:37,230 --> 00:12:38,730
And open up our test repo.

165
00:12:41,740 --> 00:12:44,220
And paste it in here and make it as simple as possible.

166
00:12:48,580 --> 00:12:50,350
So our application will compile.

167
00:12:53,030 --> 00:12:54,290
Give it the correct receiver.

168
00:12:56,860 --> 00:13:01,090
And now add this entire string to a repository.

169
00:13:02,920 --> 00:13:03,940
Right here.

170
00:13:05,070 --> 00:13:10,600
OK, let's make sure the application compiles so we don't have any typos anywhere and we have X to clear

171
00:13:10,600 --> 00:13:11,350
but not used.

172
00:13:11,380 --> 00:13:17,320
OK, so that's to be expected because we haven't actually done anything with that X yet.

173
00:13:17,320 --> 00:13:20,200
So let's get our restrictions.

174
00:13:20,470 --> 00:13:30,070
Restrictions and potentially an error are equal to IMDB dot get restrictions for room by date are variable

175
00:13:30,070 --> 00:13:32,350
called X, so we get a remedy from X.

176
00:13:32,950 --> 00:13:39,400
We want all the restrictions for this room for the current month so we can use our first month as our

177
00:13:39,400 --> 00:13:42,220
start and our last month as the end.

178
00:13:42,250 --> 00:13:47,950
And that will get me all of the restrictions for this room for the current month, which is exactly

179
00:13:47,950 --> 00:13:48,920
what I need.

180
00:13:49,480 --> 00:13:50,590
So we've got a check for an error.

181
00:13:50,590 --> 00:13:57,760
If error is not equal to nil, we'll just say helper's dot server error W and the error and return.

182
00:13:58,090 --> 00:14:00,950
Otherwise we can now do something with our restrictions.

183
00:14:01,660 --> 00:14:07,750
So what we're going to do is loop through those restrictions one at a time and determine whether it's

184
00:14:07,750 --> 00:14:09,820
a reservation or it's a block.

185
00:14:09,820 --> 00:14:15,070
If it's a reservation, we'll put the appropriate entry in our reservation map if it's a block will

186
00:14:15,070 --> 00:14:17,160
put the appropriate entry in our block map.

187
00:14:18,070 --> 00:14:23,470
So this is pretty straightforward for underscore or ignore the index and I'll use Y, which is a variable

188
00:14:23,470 --> 00:14:26,980
I've not used yet that's going to range through restrictions.

189
00:14:29,390 --> 00:14:32,250
And we just checked to see is it a reservation?

190
00:14:32,330 --> 00:14:33,850
How do I know it's a reservation?

191
00:14:34,100 --> 00:14:39,430
If reservation ID is greater than zero than it's a reservation, otherwise it's a block.

192
00:14:39,620 --> 00:14:45,860
So if we got DOT reservation, it is greater than zero.

193
00:14:47,060 --> 00:14:50,420
It's a reservation otherwise.

194
00:14:52,570 --> 00:15:00,220
It's a block, so reservations can be one day long or they can be ninety nine days long, so we need

195
00:15:00,220 --> 00:15:07,120
to actually loop through the dates for the current reservation and put one entry for each of the dates

196
00:15:07,630 --> 00:15:09,070
into our reservation map.

197
00:15:09,090 --> 00:15:10,280
Unfortunately, that's pretty easy.

198
00:15:10,300 --> 00:15:18,970
We can use exactly the same logic we did up here for D is assigned the value of and the the first index

199
00:15:18,970 --> 00:15:20,770
will be the reservation start date.

200
00:15:21,550 --> 00:15:26,440
So we're going to start at the start date and we want to go until we're not after.

201
00:15:26,920 --> 00:15:34,900
It's not D it's a yes it is after until we're after the end date for the reservation that has to be

202
00:15:34,900 --> 00:15:37,000
equal to faults in order to keep going through the loop.

203
00:15:37,270 --> 00:15:39,370
And we need to add one to the date.

204
00:15:39,370 --> 00:15:42,160
D is equal to dot add date.

205
00:15:43,540 --> 00:15:48,190
No years, no months one day and we're going to loop through that.

206
00:15:48,370 --> 00:15:50,200
So get our parentheses in there.

207
00:15:50,680 --> 00:15:53,650
And what we're going to do is put a value in the reservation map.

208
00:15:53,650 --> 00:16:01,810
So reservation map and here we need to actually build the string appropriately and we're just going

209
00:16:01,810 --> 00:16:04,150
to use the same format we did up here.

210
00:16:04,480 --> 00:16:11,260
DOT format and the layout will be a four digit year, a two digit month and a one or two digit digit

211
00:16:11,260 --> 00:16:11,680
day.

212
00:16:12,490 --> 00:16:15,280
And we don't want that to be equal to zero or one.

213
00:16:15,280 --> 00:16:21,160
We need it to be equal to the reservation ID, reservation ID.

214
00:16:21,610 --> 00:16:28,990
So now our map will have for all of the days of the current reservation and entry that is equal to the

215
00:16:28,990 --> 00:16:32,790
date that the rise that we're dealing with and the reservation ID.

216
00:16:32,830 --> 00:16:35,900
And we can use that to build a link to the reservation in our map.

217
00:16:37,450 --> 00:16:39,970
Now if it's a block, it's even easier.

218
00:16:40,060 --> 00:16:43,510
We just need to put because all blocks are one day long, we can just say block map.

219
00:16:46,260 --> 00:16:49,590
Not or why not start date?

220
00:16:52,330 --> 00:17:00,370
That format and used the same syntax, zero, one two, and that will be equal to and we'll put in the

221
00:17:00,370 --> 00:17:01,120
restriction in.

222
00:17:05,640 --> 00:17:12,210
So that gives me the actual restriction ID itself, the one that I can use to link to the restriction

223
00:17:12,210 --> 00:17:14,260
that I need to close, and that's pretty straightforward.

224
00:17:14,670 --> 00:17:21,150
So as long as it's not zero and it won't be zero, this will be a restriction, a block for that current

225
00:17:21,150 --> 00:17:21,420
date.

226
00:17:22,650 --> 00:17:25,760
So now I have these things built after this for loop is finished.

227
00:17:25,770 --> 00:17:26,910
What am I going to do with them?

228
00:17:26,940 --> 00:17:32,190
Well, I need to put them somewhere so I can pull them out in the template and use them as I need to.

229
00:17:32,200 --> 00:17:33,190
And that's pretty straightforward.

230
00:17:33,390 --> 00:17:39,600
We use our data variable data and I'll give it a look up and I want to be able to look it up for an

231
00:17:39,600 --> 00:17:43,620
individual room, both the reservation map and the block map.

232
00:17:43,620 --> 00:17:47,580
So I'll just give it a meaningful name using format dot as print f.

233
00:17:50,630 --> 00:17:57,830
And I'll call it reservation map, underscore, map, underscore and present deals, and I'll replace

234
00:17:57,830 --> 00:17:59,890
that with the idea of the room.

235
00:18:00,740 --> 00:18:02,920
So that will be Eckstut ID.

236
00:18:04,890 --> 00:18:11,430
And that's going to be equal to my reservation man, and I'll duplicate this and change this to block.

237
00:18:15,220 --> 00:18:23,140
And then I'll store the block map in there, so that gives me one reservation map for every room and

238
00:18:23,140 --> 00:18:30,850
one block map for every room, and the reservation map will have an empty default values of zero if

239
00:18:30,850 --> 00:18:36,970
there is no reservation for for a given day or will have the ID of the reservation for a given day if

240
00:18:36,970 --> 00:18:37,660
one exists.

241
00:18:37,660 --> 00:18:43,500
And the same thing with a block map zero if there's no block and the ID of the block if it does exist.

242
00:18:43,900 --> 00:18:45,520
Now, there's one other thing I'm going to do here.

243
00:18:45,700 --> 00:18:52,160
I'm actually going to store the block map for this room in this session and I'm going to do that for

244
00:18:52,160 --> 00:18:54,130
a reason which may not be immediately apparent.

245
00:18:54,130 --> 00:18:56,140
But let's get it in there and then I'll tell you why I'm doing it.

246
00:18:56,830 --> 00:18:59,320
Amde App Session put.

247
00:19:01,260 --> 00:19:12,180
Our context and I will call this format formatter, sprint f block, underscore, map, underscore D

248
00:19:13,800 --> 00:19:19,500
ID for the substitution and I'm going to store in the block map the current block map for the current

249
00:19:19,500 --> 00:19:19,760
round.

250
00:19:19,770 --> 00:19:24,780
So there will be one entry put in the session for every room that I'm dealing with.

251
00:19:24,780 --> 00:19:27,290
So there'll be two to put in here every time I come through.

252
00:19:27,840 --> 00:19:32,750
And this is important and the reason it's important is not immediately apparent, but will be shortly.

253
00:19:32,760 --> 00:19:35,220
Let me give you the the short version of it.

254
00:19:36,810 --> 00:19:45,180
When the map is when the calendar is first rendered to the screen, I need to store the block map as

255
00:19:45,180 --> 00:19:51,510
it existed at the moment it was rendered and before the user does anything to the reservation calendar.

256
00:19:51,870 --> 00:19:58,350
And the reason is once they post that, my post handler will pull this map out of the session and use

257
00:19:58,350 --> 00:20:02,340
that to compare what we currently have with what we used to have.

258
00:20:02,670 --> 00:20:08,070
So I'll be able to determine things like which blocks am I getting rid of and which ones are new.

259
00:20:08,070 --> 00:20:10,680
And I need to have this information in order to do that.

260
00:20:10,950 --> 00:20:17,310
And the other thing to bear in mind is I just put a map of type string int into the session, but I

261
00:20:17,310 --> 00:20:21,470
haven't actually told my application that I'm going to be storing things like that in the session.

262
00:20:21,690 --> 00:20:28,320
So let's open our mango and do that ghab register right here in the run function on mango.

263
00:20:28,500 --> 00:20:33,930
I need to register a type of map string.

264
00:20:36,150 --> 00:20:36,570
Int.

265
00:20:39,490 --> 00:20:45,760
There, so I've now got this information, let's make sure everything renders the way our runs the way

266
00:20:45,760 --> 00:20:46,130
it should.

267
00:20:46,150 --> 00:20:48,100
So let's try compiling the application.

268
00:20:50,800 --> 00:20:56,170
Let's go back to our screen here and make sure everything works, so look at new reservations and now

269
00:20:56,170 --> 00:20:57,490
look at our reservation calendar.

270
00:20:57,490 --> 00:20:57,990
Perfect.

271
00:20:58,530 --> 00:21:06,040
So at this moment, I have everything I need a pass to my template in one form or another in order to

272
00:21:06,040 --> 00:21:09,250
be able to render the dates appropriately.

273
00:21:09,970 --> 00:21:10,470
I think I do.

274
00:21:10,480 --> 00:21:11,450
Anyway, let's go make sure.

275
00:21:11,740 --> 00:21:13,330
So back in my template.

276
00:21:15,630 --> 00:21:19,500
I'm going to look and make sure that I'm pulling everything out of there, I have the current date,

277
00:21:19,650 --> 00:21:22,470
I have the current rims, I know the days in the month.

278
00:21:22,860 --> 00:21:26,660
Now, there's two other pieces of information that I stored that I need to get here as well.

279
00:21:26,670 --> 00:21:30,210
So let's go back to our handlers and have a look here.

280
00:21:30,960 --> 00:21:34,020
So I stored at some point in the string.

281
00:21:34,020 --> 00:21:40,740
Yes, here I have this month and this year, which I need to be able to have access to in the next lecture.

282
00:21:40,740 --> 00:21:42,360
So let's grab that information right now.

283
00:21:42,550 --> 00:21:45,030
So let's go back here and say.

284
00:21:47,430 --> 00:21:52,150
Per month is a sign the value of index dot, string map.

285
00:21:52,590 --> 00:21:54,600
And what did I call it back in my handlers?

286
00:21:55,500 --> 00:21:57,000
I called it this month.

287
00:22:00,050 --> 00:22:08,510
And then I'll duplicate this line year and Curre year and let's make sure that that still renders appropriately

288
00:22:08,540 --> 00:22:09,510
reservation calendar.

289
00:22:09,530 --> 00:22:10,160
Yes, it does.

290
00:22:10,490 --> 00:22:15,590
OK, so at this point, I know that I have everything I need pass to this template.

291
00:22:15,800 --> 00:22:22,340
I have a total of four maps with respect to restrictions, a block map for generals quarters, a block

292
00:22:22,340 --> 00:22:23,480
map for major suite.

293
00:22:23,690 --> 00:22:28,220
I have a reservation map for generals quarters and a reservation map for four major suite.

294
00:22:28,490 --> 00:22:31,140
And I know the current month and I know the current year.

295
00:22:31,550 --> 00:22:36,860
So this is all the information I need in order to render the information on the screen.

296
00:22:36,860 --> 00:22:39,470
And that's what we'll take care of in the next lecture.
