I have list of items contained in viewbag ViewBag.RoomBookings
As an example:
I want all the Roombookings with ViewBag.RoomBookings.RoomNo = 6 AND ViewBag.RoomBookings.Time < DateTime.Now AND ViewBag.RoomBookings.Time < DateTime.Now + 3600
Looping through is a NO.
And it must be done on the view, as I also need access to all the other roombookings too to populate a timetable.
Alternatively, Im thinking of Hash lists? Where I could list it with RoomNo, and Time and access it that way. But I cant find any good documentation on this if its even possible.
Ive tried a few things (just to test a method that works (these wont follow the same critera as above)):
var RoomBookingsTemp = ViewBag.RoomBookings;
var newlist = (from RoomOcc in RoomBookingsTemp where RoomOcc.EndDateTime < DateTime.Now select RoomOcc.RoomNo);
var bookings = RoomBookingsTemp.Where(roombooking => DateCheckStart < roombooking.EndDateTime && DateCheckEnd > roombooking.StartDateTime && roombooking.RoomNo == RoomNo);
var newlist = RoomBookingsTemp.Select(m => m["RentalNo"]);
But none are valid.
I have list of items contained in viewbagandAnd it must be done on the view. Using ViewData/ViewBag, and writing complex code in the view which would otherwise belong to a view model are two very bad practices for me.