public static RouteScheduleViewModel ConfigureScheduleView(TrolleyTrackerContext db, bool calculateEffectiveSchedule) { var vm = new RouteScheduleViewModel(); var routeSchedules = from rs in db.RouteSchedules.Include(rs => rs.Route) orderby rs.DayOfWeek, rs.StartTime ascending select rs; vm.RouteSchedules = (System.Data.Entity.Infrastructure.DbQuery<RouteSchedule>)routeSchedules; if (calculateEffectiveSchedule) { var routeScheduleOverrideList = (from rso in db.RouteScheduleOverrides.Include(rso => rso.NewRoute) orderby rso.OverrideDate, rso.StartTime, rso.NewRoute.ShortName select rso).ToList<RouteScheduleOverride>(); var routeScheduleList = routeSchedules.ToList<RouteSchedule>(); vm.EffectiveRouteSchedules = BuildEffectiveRouteSchedule(routeScheduleList, routeScheduleOverrideList); } vm.Options = new MvcScheduleGeneralOptions { Layout = LayoutEnum.Horizontal, SeparateDateHeader = false, FullTimeScale = true, TimeScaleInterval = 60, StartOfTimeScale = new TimeSpan(6, 0, 0), EndOfTimeScale = new TimeSpan(23, 59, 59), IncludeEndValue = false, ShowValueMarks = true, ItemCss = "normal", AlternatingItemCss = "normal2", RangeHeaderCss = "heading", TitleCss = "heading", AutoSortTitles = false, BackgroundCss = "empty" }; return vm; }
// GET: RouteSchedules public ActionResult Index() { //var routeSchedules = db.RouteSchedules.Include(r => r.Route); var routeSchedules = from rs in db.RouteSchedules.Include(rs => rs.Route) orderby rs.DayOfWeek, rs.StartTime ascending select rs; ViewBag.DaysOfWeek = daysOfWeek; ViewBag.CssFile = Url.Content("~/Content/RouteScheduleSummary.css"); var vm = new RouteScheduleViewModel(); vm.RouteSchedules = (System.Data.Entity.Infrastructure.DbQuery<RouteSchedule>) routeSchedules; vm.Options = new MvcScheduleGeneralOptions { Layout = LayoutEnum.Horizontal, SeparateDateHeader = false, FullTimeScale = true, TimeScaleInterval = 60, StartOfTimeScale = new TimeSpan(6, 0, 0), EndOfTimeScale = new TimeSpan(23, 59, 59), IncludeEndValue = false, ShowValueMarks = true, ItemCss = "normal", AlternatingItemCss = "normal2", RangeHeaderCss = "heading", TitleCss = "heading", AutoSortTitles = false, BackgroundCss = "empty" }; return View(vm); //return View(routeSchedules.ToList()); }