public ChannelProgramResponce Update(int id, ChannelProgram channelProgram) { var existingProgram = _unitOfWork.channelProgramRepository.GetById(id); if (existingProgram == null) { return(new ChannelProgramResponce("program not found.")); } existingProgram.StartTime = channelProgram.StartTime; existingProgram.EndTime = channelProgram.EndTime; try { _unitOfWork.channelProgramRepository.Update(existingProgram); _unitOfWork.Commit(); return(new ChannelProgramResponce(existingProgram)); } catch (Exception ex) { //TODO some logging stuff here return(new ChannelProgramResponce($"An error occurred when updating the Programs Scheduling Time: {ex.Message}")); } }
public ChannelProgramResponce Save(ChannelProgram channelProgram) { try { _unitOfWork.channelProgramRepository.Add(channelProgram); _unitOfWork.Commit(); return(new ChannelProgramResponce(channelProgram)); } catch (Exception ex) { Console.WriteLine(ex); return(new ChannelProgramResponce($"An error occurred when saving the program: {ex.Message}")); } }
public ActionResult AddProgram(ChannelProgram model) { DateTime start = model.StartTime; var id = Url.RequestContext.RouteData.Values["id"].ToString(); _channelProgramService.AddProgram(id, start); IEnumerable <ChannelProgram> channelPrograms = _channelProgramService.GetAll().OrderBy(x => x.StartTime); IEnumerable <VideoContent> videoContents = _contentService.GetAll(); ChannelPageViewModel channelPageViewModel = new ChannelPageViewModel { ChannelPrograms = channelPrograms, VideoContents = videoContents }; return(RedirectToAction("Index", channelPageViewModel)); }
public bool AddProgram(string videoId, DateTime starTime) { var status = false; // if startTime is earlier than DateTime.Now ?? if (GetAll().Any(x => x.StartTime.TrimSeconds() < starTime.TrimSeconds() && x.EndTime.TrimSeconds() > starTime.TrimSeconds())) { return(status); } else { VideoContent currentContent = _contentService.GetAll().Where(v => v.VideoId == videoId).SingleOrDefault(); ChannelProgram cp = new ChannelProgram { StartTime = starTime, EndTime = starTime.AddMilliseconds(currentContent.Duration), AppUserId = UserSession.CurrentUser.Id, VideoContentVideoId = videoId }; try { HttpClient client = new HttpClient(); //client.BaseAddress = new Uri("https://localhost:44384/Api/"); client.BaseAddress = new Uri("https://ettv.azurewebsites.net/api/"); //client.BaseAddress = new Uri("http://localhost:5000/api/"); string JsonString = JsonConvert.SerializeObject(cp); StringContent content = new StringContent(JsonString, Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync("channelprogram/", content).Result; if (response.IsSuccessStatusCode) { status = true; } return(status); } catch (Exception ex) { Console.WriteLine(ex); return(false); } } }
static void Main(string[] args) { Uri url = new Uri("http://www.ntv.com.tr/tv/yayin-akisi/"); WebClient webclient = new WebClient(); webclient.Encoding = Encoding.UTF8; string html = webclient.DownloadString(url); var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html); var programList = htmlDocument.DocumentNode.Descendants("ul") .Single(d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Equals("programmes")) .SelectNodes("li"); var channel = new Channel(); channel.Name = "NTV"; foreach (var program in programList) { var channelProgram = new ChannelProgram(); channelProgram.Time = program.SelectSingleNode("a").Descendants("span") .Single(d => d.Attributes.Contains("class") && d.Attributes["class"] .Value.Equals("tv-hour")).InnerText; channelProgram.Name = program.SelectSingleNode("a").Descendants("span") .Single(d => d.Attributes.Contains("class") && d.Attributes["class"] .Value.Equals("programmeTitle")).InnerText.Replace("\r", ""); channel.Programs.Add(channelProgram); } foreach (var item in channel.Programs) { Console.WriteLine(item.Name + " " + item.Time); } Console.ReadKey(); }
public ChannelProgramView(ChannelProgram program) { _program = program; _upcomingProgramId = program.GetUniqueUpcomingProgramId(); }
public ChannelProgramResponce(bool success, string message, ChannelProgram channelProgram) : base(success, message) { ChannelProgram = channelProgram; }
public ChannelProgramResponce(ChannelProgram channelProgram) : this(true, string.Empty, channelProgram) { }