public ActionResult TVGuide(int?group = null, string time = null, string date = null) { DateTime startTime; if (time == null || !DateTime.TryParse(time, out startTime)) { startTime = DateTime.Now; } DateTime passedDate; if (date != null && DateTime.TryParse(date, out passedDate)) { startTime = new DateTime(passedDate.Year, passedDate.Month, passedDate.Day, startTime.Hour, startTime.Minute, startTime.Second); } var lastHour = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, startTime.Minute >= 30 ? 30 : 0, 0, DateTimeKind.Local); var endOfGuide = lastHour.AddHours(4); var groups = Connections.Current.TAS.GetGroups(); var activeGroup = Connections.Current.TAS.GetGroupById(group != null ? group.Value : Settings.ActiveSettings.DefaultGroup.GetValueOrDefault(groups.First().Id)); if (activeGroup == null) { activeGroup = Connections.Current.TAS.GetGroupById(groups.First().Id); } var model = new TVGuideViewModel(groups, activeGroup, lastHour, endOfGuide); return(View(model)); }