[OutputCache(Duration = 10)] //Cache this request for 10 seconds as it wont chance much if at all public ActionResult Get(int? videoId) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB"); //Get the program data EPGDataModel model = new EPGDataModel(); <<<<<<< HEAD var testPrograms = GenerateTestData(); if(videoId == null) model.Programs.AddRange(testPrograms); else model.Programs.AddRange(testPrograms.Where(p => p.Id ==videoId.Value).ToList()); //Add only where our video id matches model.Success = true; //Return the program JsonResult result = new JsonResult(); result.Data = model; result.JsonRequestBehavior = JsonRequestBehavior.AllowGet; //Return the data return result; }//Get
public ActionResult Get(DateTime? showDate) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB"); //Get the program data EPGDataModel model = new EPGDataModel(); var testPrograms = GenerateTestData(); model.Programs.AddRange(testPrograms); model.Success = true; //Return the program JsonResult result = new JsonResult(); result.Data = model; result.JsonRequestBehavior = JsonRequestBehavior.AllowGet; //Return the data return result; }
public ActionResult Get(DateTime? showDate) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB"); //Get the program data EPGDataModel model = new EPGDataModel(); Program program1 = new Program { Id = 88826414414, Title = "Thor", Description = "Thor Movie", Category = new List<string> { "Action","Sci-Fi" }, Channel = "Sky Movies", StartDateTime = DateTime.Parse("12/08/2012 16:00"), EndDateTime = DateTime.Parse("12/08/2012 18:00"), FirstAirDate = DateTime.Parse("01/01/2011 19:00"), IsFilm = true, IsLiveTv = false, IsPauseable = true, IsTvSeries = false, OtherDetails = string.Empty, PrimaryImage = @"\images\Thor.png", Producer = "Kenneth Branagh", ProductionCompany = "Universal", SecondaryImage = @"\images\Thor.png", StarRating = 5, VideoLocation = @"\videos\1.mp4" }; Program program2 = new Program { Id = 8234236414414, Title = "Hop", Description = "Hop Movie", Category = new List<string> { "Comedy" }, Channel = "Sky Movies", StartDateTime = DateTime.Parse("12/08/2012 18:00"), EndDateTime = DateTime.Parse("12/08/2012 19:30"), FirstAirDate = DateTime.Parse("01/01/2012 19:00"), IsFilm = true, IsLiveTv = false, IsPauseable = true, IsTvSeries = false, OtherDetails = string.Empty, PrimaryImage = @"\images\Hop.png", Producer = "Who Knows", ProductionCompany = "Universal", SecondaryImage = @"\images\Hop.png", StarRating = 3, VideoLocation = @"\videos\2.mp4" }; Program program3 = new Program { Id = 665666414214, Title = "Lost EP1", Description = "Lost TV EP1", Category = new List<string> { "Comedy","TV Drama" }, Channel = "Sky Atlantic", StartDateTime = DateTime.Parse("13/08/2012 07:00"), EndDateTime = DateTime.Parse("13/08/2012 08:00"), FirstAirDate = DateTime.Parse("01/06/2010 19:00"), IsFilm = false, IsLiveTv = false, IsPauseable = true, IsTvSeries = true, OtherDetails = string.Empty, PrimaryImage = @"\images\Lost.png", Producer = "Who Knows", ProductionCompany = "Sky", SecondaryImage = @"\images\Lost.png", StarRating = 4, VideoLocation = @"\videos\3.mp4" }; Program todaysProgram = new Program { Id = 78985275319, Title = "Todays Program", Description = "Todays Program Desc", Category = new List<string> { "Comedy", "TV Drama" }, Channel = "Sky Atlantic", StartDateTime = DateTime.Now, EndDateTime = DateTime.Now.AddDays(1), FirstAirDate = DateTime.Parse("13/08/2011 07:00"), IsFilm = false, IsLiveTv = false, IsPauseable = true, IsTvSeries = true, OtherDetails = string.Empty, PrimaryImage = @"\images\Today.png", Producer = "Lee Howarth", ProductionCompany = "Sky", SecondaryImage = @"\images\Today.png", StarRating = 5, VideoLocation = @"\videos\4.mp4" }; if (showDate != null) { if(showDate.Value.Date == program1.StartDateTime.Date) model.Programs.Add(program1); if (showDate.Value.Date == program2.StartDateTime.Date) model.Programs.Add(program2); if (showDate.Value.Date == program3.StartDateTime.Date) model.Programs.Add(program3); if (showDate.Value.Date == todaysProgram.StartDateTime.Date) model.Programs.Add(todaysProgram); }//if else { model.Programs.Add(program1); model.Programs.Add(program2); model.Programs.Add(program3); model.Programs.Add(todaysProgram); }//else model.Success = true; //Return the program JsonResult result = new JsonResult(); result.Data = model; result.JsonRequestBehavior = JsonRequestBehavior.AllowGet; //Return the data return result; }