public static ShowDayViewModel PrepareModel(DateTime DateRequired) { int SessionCount = _Repository.MaxSessions(); List <GetBookingsForDay_Result> rec = _Repository.SessionDetailsForDay(DateRequired); ShowDayViewModel sdm = new ShowDayViewModel(DateRequired); for (int i = 1; i <= SessionCount; i++) { Session ses = new Session(i); var units = from r in rec where r.SessionId == i select new RinkUnit { Rink = r.Rink.ToString(), DiaryRef = r.DiaryId, Description = r.Description, HomeRef = r.HomeRef.ToString(), HomeName = r.HomeName, AwayRef = r.AwayRef.ToString(), AwayName = r.AwayName }; foreach (RinkUnit unit in units) { ses.session.Add(unit); } sdm.SessionList.Add(ses); } return(sdm); }
public JsonResult AjaxShowBookingForm(string RequestedDate) { ShowDayViewModel sdv = BookingUtilities.PrepareModel(DateTime.Parse(RequestedDate)); return(Json(sdv)); }