public async Task <ResultDTO> AddVideoToMovie([FromBody] VideoDTO model, [FromRoute] int id) { try { var movie = await _context.movies .SingleOrDefaultAsync(t => t.Id == id); movie.Video = _mapper.Map <VideoDTO, Video>(model); await _context.SaveChangesAsync(); return(new ResultDTO { Status = 200, Message = "Posted" }); } catch (Exception ex) { return(new ResultErrorDTO { Status = 500, Message = ex.Message }); } }
public async Task <ResponseDTO <VideoDTO> > GetNextOrderPublicVideoAsync(int order = 0) { if (order < 1) { return(new ResponseDTO <VideoDTO> { code = -1, success = false, responseMessage = "no video id" }); } var publicVideo = (from pb in dbContext.PublicCrawled where pb.Order > order orderby pb.Order select pb).Include(x => x.Crawled).FirstOrDefault(); if (publicVideo == null) { return(new ResponseDTO <VideoDTO> { code = 0, success = false, responseMessage = "end of videos" }); } VideoDTO videoDTO = VideoDTO.CrawledToVideoDTO(publicVideo); return(new ResponseDTO <VideoDTO> { success = true, data = videoDTO }); }
public List <VideoDTO> GetVideoByChannel(RequestBase request) { List <VideoDTO> videos = new List <VideoDTO>(); var searchListRequest = _Service.Search.List("snippet"); searchListRequest.RegionCode = request.RegionCode; // Replace with your search term. searchListRequest.ChannelId = request.channelId; searchListRequest.MaxResults = request.MaxResults; searchListRequest.Order = SearchResource.ListRequest.OrderEnum.VideoCount; searchListRequest.Type = "video"; // Call the search.list method to retrieve results matching the specified query term. var searchListResponse = searchListRequest.Execute(); foreach (var searchResult in searchListResponse.Items) { var row = new VideoDTO() { title = searchResult.Snippet.Title, videoId = searchResult.Id.VideoId, chanelTitle = searchResult.Snippet.ChannelTitle, imgUrl = searchResult.Snippet.Thumbnails.Medium.Url, chanelId = searchResult.Snippet.ChannelId, publishDated = searchResult.Snippet.PublishedAt, }; videos.Add(row); } return(videos); }
public ActionResult <Video> Put(int id, VideoDTO DTO) { try { Video a = _videoRepository.GetBy(id); if (a == null) { return(BadRequest("De video die u wenst te wijzigen bestaat niet")); } Lesmateriaal lesMateriaal = _lesmateriaalRepository.GetBy(DTO.LesMateriaalId); if (lesMateriaal == null) { return(BadRequest("Het opgegeven lesmateriaal bestaat niet!")); } a.LesmateriaalId = DTO.LesMateriaalId; a.Adres = DTO.Adres; _videoRepository.Update(a); _videoRepository.SaveChanges(); return(a); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult VideoPage(long?id) { if (id == null) { return(View("Error")); } Video currentVideo = _videosRepository.GetVideoById(id); if (currentVideo == null) { return(View("Error")); } if (currentVideo.Blocked == true || currentVideo.User.Blocked == true || currentVideo.VideoType == "PRIVATE") { if (!(UsersHelper.LoggedInUserIsAdmin(Session) && !UsersHelper.LoggedInUserIsBlocked(Session)) && !UsersHelper.LoggedInUserIsOnHisPage(Session, currentVideo.VideoOwner)) { return(View("Error")); } } currentVideo.ViewsCount += 1; _videosRepository.UpdateVideo(currentVideo); if (UsersHelper.LoggedInUserUsername(Session) != null) { bool exists = CheckIfSubbed(currentVideo.VideoOwner); VideoRating rating = GetVideoRatingForVideo(id); ViewBag.Subbed = exists; ViewBag.Rating = rating?.IsLike; } var video = VideoDTO.ConvertVideoToDTO(currentVideo); return(View(video)); }
public async Task <IActionResult> Post(UploadVideoViewModel model) { int result = 0; if (ModelState.IsValid) { model.Categories = model.Categories[0] .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .ToArray(); var pathInfo = this.fileQueries.GenerateVideoPath( this.ExtractFileExtension(model.Video.FileName)); var dto = new VideoDTO() { Title = model.Title, Description = model.Description, Path = pathInfo.Path, FileName = pathInfo.FileName, AuthorUserId = this.userManager.GetUserId(HttpContext.User), Categories = model.Categories }; result = await this.videoWriteService.Save(dto, model.Video); } return(result > 0 ? this.Ok() : this.StatusCode(500)); }
protected void btnSua_Click(object sender, EventArgs e) { VideoDTO vd = VideoBUS.LayThongTinVideo(txtMaVideo.Text); vd.MaVideo = txtMaVideo.Text; if (txtTenVideo.Text != "") { vd.TenVideo = txtTenVideo.Text; } vd.ThongTin = txtThongTin.Text; vd.MaLoaiVideo = dropMaLoaiVideo.Text; vd.NgayDang = DateTime.Parse(txtNgayDang.Text); vd.TenTaiKhoan = txtTaiKhoanDang.Text; vd.DuongDanVideo = txtDuongDan.Text; vd.TrangThai = chkTrangThai.Checked; if (VideoBUS.SuaVideo(vd)) { XoaForm(); LoadDSVideo(); GiaoDienThem(true); Response.Write("<script>alert('Sửa thành công');</script>"); } else { Response.Write("<script>alert('Sửa thất bại');</script>"); } }
public async Task <IActionResult> CadastrarVideo(Guid serverId, [FromForm] VideoDTO video) { string videoBase = ""; string caminho = ""; if (video.File != null) { if (!Directory.Exists(_environment.WebRootPath + "\\videos\\")) { Directory.CreateDirectory(_environment.WebRootPath + "\\videos\\"); } using (FileStream filestream = System.IO.File.Create(_environment.WebRootPath + "\\videos\\" + video.File.FileName)) { await video.File.CopyToAsync(filestream); filestream.Flush(); caminho = "\\videos\\" + video.File.FileName; } } videoBase = VideoConversions.RetornarVideoBase64(caminho); if (!string.IsNullOrEmpty(caminho.Trim())) { System.IO.File.Delete(caminho); } _video.CadastrarVideo(serverId, video, videoBase); return(Ok("Vídeo inserido com sucesso!")); }
public async Task <VideoDTO> UpdateVideoAsync(VideoDTO videoDto) { var video = _mapper.Map <Video>(videoDto); var result = await _repository.UpdateAsync(video); return(_mapper.Map <VideoDTO>(result)); }
public ActionResult UpdateVideo(int id) { VideoDTO model = new VideoDTO(); model = bll.GetVideoById(id); return(View(model)); }
public ActionResult UpdateVideo(VideoDTO model) { if (ModelState.IsValid) { string path = model.OriginalVideoPath.Substring(32); string mergeLink = "https://www.youtube.com/embed/"; mergeLink += path; model.VideoPath = string.Format(@"<iframe width=""300"" height=""200"" src=""{0}"" frameborder=""0"" allowfullscreen></iframe>", mergeLink); if (bll.UpdateVideo(model)) { ViewBag.ProcessState = General.Messages.UpdateSuccess; ModelState.Clear(); } else { ViewBag.ProcessState = General.Messages.GeneralError; } } else { ViewBag.ProcessState = General.Messages.EmptyArea; } return(View(model)); }
public ActionResult AddVideo(VideoDTO model) { //<iframe width="560" height="315" src="https://www.youtube.com/embed/E7Voso411Vs" frameborder="0" allowfullscreen></iframe> //https://www.youtube.com/watch?v=E7Voso411Vs&ab_channel=ProgrammingwithMosh if (ModelState.IsValid) { string path = model.OriginalVideoPath.Substring(32); string mergeLink = "https://www.youtube.com/embed/"; mergeLink += path; model.VideoPath = string.Format(@"<iframe width=""300"" height=""200"" src=""{0}"" frameborder=""0"" allowfullscreen></iframe>", mergeLink); if (bll.AddVideo(model)) { ViewBag.ProcessState = General.Messages.AddSuccess; ModelState.Clear(); model = new VideoDTO(); } else { ViewBag.ProcessState = General.Messages.GeneralError; } } else { ViewBag.ProcessState = General.Messages.EmptyArea; } return(View(model)); }
public async Task <OperationDetails> UpdateVideo(VideoDTO videoDto) { if (videoDto == null) { throw new ArgumentNullException("Can't update video with null value."); } Video video = Database.Videos.GetAll().Where(v => v.Path == videoDto.Path).FirstOrDefault(); if (video != null) { video.Name = videoDto.Name; video.PlaylistId = videoDto.PlaylistId; video.IsDeleted = videoDto.IsDeleted; video.Description = videoDto.Description; Database.Videos.Update(video); await Database.SaveAsync(); return(new OperationDetails(true, "Updated successfully.", "")); } else { return(new OperationDetails(false, "Such video doesn't exist", "Path")); } }
public VideoDTO GetVideo(int videoId) { Video video = Database.Videos.Get(videoId); if (video != null) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <Video, VideoDTO>(); cfg.CreateMap <ApplicationUser, UserDTO>() .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.ClientProfile.Name)) .ForMember(dest => dest.Address, opt => opt.MapFrom(src => src.ClientProfile.Address)); }); var mapper = config.CreateMapper(); if (video.IsDeleted) { return(null); } VideoDTO videoDto = new VideoDTO(); videoDto = mapper.Map <Video, VideoDTO>(video); return(videoDto); } else { return(null); } }
public virtual VideoDTO ConvertToVideoDTO(Video video) { VideoDTO videoDto = new VideoDTO(); videoDto.ID = video.ID; videoDto.Guid = video.Guid; videoDto.StatusID = video.StatusID; videoDto.Duracao = video.Duracao; videoDto.Tema = video.Tema; videoDto.Descricao = video.Descricao; videoDto.KeyVideo = video.KeyVideo; videoDto.Ativo = video.Ativo; videoDto.Nome = video.Nome; videoDto.Thumb = video.Thumb; videoDto.Url = video.Url; videoDto.QuestaoDoVideo = video.QuestaoDoVideo; videoDto.ExerciciosVideo = video.ExerciciosVideo; videoDto.Tamanho = video.Tamanho; videoDto.UnixCriacao = video.UnixCriacao; videoDto.ExisteAmazon = video.ExisteAmazon; videoDto.DataModificacao = video.DataModificacao; videoDto.DteDataModificacao = video.DteDataModificacao; videoDto.VimeoId = video.VimeoId; videoDto.VideoId = video.VideoId; videoDto.UpVote = video.UpVote; videoDto.DownVote = video.DownVote; videoDto.VotadoUpvote = video.VotadoUpvote; videoDto.VotadoDownvote = video.VotadoDownvote; videoDto.Links = video.Links; return(videoDto); }
public IActionResult BlockVideo(int id) { var contentType = Request.ContentType; Video video = _videoData.GetById(id); if (video == null) { return(NotFound()); } if (video.Blocked == true) { return(BadRequest()); } video.Blocked = true; video = _videoData.Update(video); video.Owner = _userData.GetById(video.OwnerId); VideoDTO videoDTO = VideoDTO.ConvertVideoToDTO(video); if (contentType != null) { if (contentType.Equals("application/json")) { return(Json(videoDTO)); } return(StatusCode(415)); } return(Json("Success")); }
public ActionResult AddVideo(VideoDTO model) { // VideoPath: < iframe width = "560" height = "315" src = "https://www.youtube.com/embed/DUg2SWWK18I" title = "YouTube video player" frameborder = "0" allow = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen ></ iframe > // OriginalVideoPath: https://www.youtube.com/watch?v=DUg2SWWK18I if (ModelState.IsValid) { string path = model.OriginalVideoPath.Substring(32); // DUg2SWWK18I string mergeLink = "https://www.youtube.com/embed/"; mergeLink += path; model.VideoPath = String.Format(@"<iframe width = ""350"" height = ""200"" src = ""{0}"" frameborder = ""0"" allowfullscreen ></iframe>", mergeLink); if (bll.AddVideo(model)) { ViewBag.ProcessState = General.Messages.AddSuccess; ModelState.Clear(); model = new VideoDTO(); } else { ViewBag.ProcessState = General.Messages.GeneralError; } } else { ViewBag.ProcessState = General.Messages.EmptyArea; } return(View(model)); }
public IActionResult GetAllVideos() { IEnumerable <Video> videos = new List <Video>(); List <VideoDTO> videosDTO = new List <VideoDTO>(); videos = _videoData.GetAllForAdmin(); if (videos.Count() <= 0) { return(NoContent()); } foreach (var v in videos) { v.Owner = _userData.GetById(v.OwnerId); v.Owner.UserVideos = null; VideoDTO videoDTO = VideoDTO.ConvertVideoToDTO(v); videosDTO.Add(videoDTO); } var contentType = Request.ContentType; if (contentType != null) { if (contentType.Equals("application/json")) { return(Json(videosDTO)); } else if (contentType.Equals("text/html")) { return(View("Videos", videosDTO)); } return(StatusCode(415)); } return(Json(videosDTO)); }
public ActionResult VideoConcrete(int videoId) { using (IVideoService videoService = ServiceCreator.CreateVideoService(Connection)) { VideoDTO videoDto = videoService.GetVideo(videoId); if (videoDto != null) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <VideoDTO, VideoViewModel>(); }); var mapper = config.CreateMapper(); VideoViewModel videoVM = new VideoViewModel(); videoVM = mapper.Map <VideoDTO, VideoViewModel>(videoDto); UserDTO user = videoDto.UsersLiked.Where(u => u.UserName == User.Identity.Name).FirstOrDefault(); if (user != null) { videoVM.Liked = true; } else { videoVM.Liked = false; } videoVM.LikesCount = videoDto.UsersLiked.Count(); return(View(videoVM)); } } return(HttpNotFound()); }
public IActionResult UnblockVideo(int id) { var contentType = Request.ContentType; Video video = _videoData.GetById(id); if (video == null) { return(NotFound()); } if (video.Blocked == false) { return(BadRequest()); } video.Blocked = false; video = _videoData.Update(video); video.Owner = _userData.GetById(video.OwnerId); VideoDTO videoDTO = VideoDTO.ConvertVideoToDTO(video); if (contentType != null) { if (contentType.Equals("application/json")) { return(Json(videoDTO)); } else if (contentType.Equals("text/html")) { //return RedirectToAction(nameof(GetVideoById), video.Id); } return(StatusCode(415)); } return(Json("Success")); }
public void CadastrarVideo(Guid idServidor, VideoDTO video, string videobBase) { try { if (_unitOfWork.ServidorRepository.RetornarDadosServidor(idServidor).Count() == 0) { throw new Exception("Esse servidor não é válido"); } else { var videoModel = new Video() { IdServidor = idServidor, Descricao = video.Descricao, Binario = videobBase, DataCadastro = DateTime.Now }; _unitOfWork.VideoRepository.InserirVideo(videoModel); _unitOfWork.Commit(Commom.BancoDados.SqlServer); } } catch (Exception ex) { _unitOfWork.Rollback(Commom.BancoDados.SqlServer); throw new Exception(ex.Message); } }
public IActionResult Salvar(VideoDTO videoTemporario) { if (ModelState.IsValid) { Video video = new Video(); if (videoTemporario.Id == 0) { video.Nome = videoTemporario.Nome; video.LinkVideo = videoTemporario.LinkVideo; video.Descricao = videoTemporario.Descricao; video.Curso = database.Curso.First(video => video.Id == videoTemporario.CursoID); database.Video.Add(video); } else { Video videoDoBanco = database.Video.First(registro => registro.Id == videoTemporario.Id); videoDoBanco.Nome = videoTemporario.Nome; videoDoBanco.LinkVideo = videoTemporario.LinkVideo; videoDoBanco.Descricao = videoTemporario.Descricao; } database.SaveChanges(); return(RedirectToAction("Index", "Curso")); } else { ViewData["aux1"] = videoTemporario.Id; ViewData["idCursoVideo"] = videoTemporario.CursoID; return(View("../Video/CadastrarVideo")); } }
public async Task <IActionResult> Edit(int id, VideoDTO videoDto) { if (id != videoDto.Id) { return(NotFound()); } if (ModelState.IsValid) { try { var edited = await _apiService.UpdateAsync <Video, VideoDTO>(videoDto); } catch { } return(RedirectToAction(nameof(Index))); } var moduleDto = await _apiService.GetAsync <Module, ModuleDTO>(true); ViewData["ModuleId"] = new SelectList(moduleDto, "Id", "ModuleTitle"); var courseDto = await _apiService.GetAsync <Course, CourseDTO>(true); ViewData["CourseId"] = new SelectList(courseDto, "Id", "CourseTitle"); return(View(videoDto)); }
public VideoDTO addChannelVideo(string accessToken, int channelID, VideoDTO video) { User loggedInUser = getValidatedUser(accessToken); if (video.title == null || video.title == "" || video.source == null || video.source == "") { throw new InvalidParametersException("video title or source not defined"); } if (_videoMapper.getChannelById(channelID) == null) { throw new AppObjectNotFoundException("no channel found with this id"); } Video newVid = new Video(); newVid.channelId = channelID; newVid.creator = loggedInUser.id; newVid.source = video.source; newVid.title = video.title; int vidId = _videoMapper.addVideo(newVid); video.channelId = channelID; video.creator = loggedInUser.id; video.id = vidId; return video; }
public List <VideoDTO> GetTrendingVideo(RequestBase request) { try { var searchListRequest = _Service.Videos.List("snippet,contentDetails,statistics"); searchListRequest.RegionCode = request.RegionCode; // Replace with your search term. searchListRequest.Chart = VideosResource.ListRequest.ChartEnum.MostPopular; searchListRequest.MaxResults = 24; // Call the search.list method to retrieve results matching the specified query term. var searchListResponse = searchListRequest.Execute(); List <VideoDTO> videos = new List <VideoDTO>(); // Add each result to the appropriate list, and then display the lists of // matching videos, channels, and playlists. if (searchListResponse.Items == null || searchListResponse.Items.Count <= 0) { return(null); } foreach (var searchResult in searchListResponse.Items) { var row = new VideoDTO() { title = searchResult.Snippet.Title, videoId = searchResult.Id, chanelTitle = searchResult.Snippet.ChannelTitle, imgUrl = searchResult.Snippet.Thumbnails.Medium.Url, chanelId = searchResult.Snippet.ChannelId, tags = searchResult.Snippet.Tags, publishDated = searchResult.Snippet.PublishedAt, duration = searchResult.ContentDetails.Duration, viewcount = searchResult.Statistics.ViewCount }; videos.Add(row); } return(videos); } catch (Google.GoogleApiException ex) { log.Error("GetTrendingVideo ex: " + ex); log.Info("RegionCode: " + request.RegionCode); if (ex.HttpStatusCode != System.Net.HttpStatusCode.BadRequest) { _keyservice.SetOverLimit(); _keyservice.GetDefaultKey(); InitService(); return(GetTrendingVideo(request)); } else { return(null); } } }
public VoteDTO GetVote(VideoDTO video, string username) { var vote = this.context.Votes.SingleOrDefault(like => like.TubeUserName == username && like.VideoId == video.Id); var voteDto = this.mapper.Map <VoteDTO>(vote); return(voteDto);; }
public static bool KTVideoTonTai(VideoDTO vd) { string query = "SELECT COUNT(*) FROM Video WHERE MaVideo = @MaVideo"; SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@MaVideo", vd.MaVideo); return(Convert.ToInt32(DataProvider.ExecuteSelectQuery(query, param).Rows[0][0]) == 1); }
public static DataRow LayTenVideo(VideoDTO vd) { string query = "SELECT TenVideo FROM Video WHERE MaVideo = @MaVideo"; SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@MaVideo", vd.MaVideo); return(DataProvider.ExecuteSelectQuery(query, param).Rows[0]); }
public List <VideoDTO> LiveVideo(RequestBase request) { try { var searchListRequest = _Service.PlaylistItems.List("snippet,ContentDetails"); searchListRequest.PlaylistId = "PLU12uITxBEPGILPLxvkCc4L_iL7aHf4J2"; // Replace with your search term. searchListRequest.MaxResults = 50; // Call the search.list method to retrieve results matching the specified query term. var searchListResponse = searchListRequest.Execute(); List <VideoDTO> videos = new List <VideoDTO>(); if (searchListResponse.Items == null || searchListResponse.Items.Count <= 0) { return(null); } // Add each result to the appropriate list, and then display the lists of // matching videos, channels, and playlists. foreach (var searchResult in searchListResponse.Items) { var row = new VideoDTO() { title = searchResult.Snippet.Title, videoId = searchResult.ContentDetails.VideoId, chanelTitle = searchResult.Snippet.ChannelTitle, imgUrl = searchResult.Snippet.Thumbnails.Medium.Url, chanelId = searchResult.Snippet.ChannelId, isLive = true // publishDated = searchResult.ContentDetails.Start, }; videos.Add(row); } return(videos); } catch (Google.GoogleApiException ex) { log.Error("LiveVideo ex: " + ex); if (ex.HttpStatusCode != System.Net.HttpStatusCode.BadRequest) { _keyservice.SetOverLimit(); _keyservice.GetDefaultKey(); InitService(); var result = LiveVideo(request); return(result); } else { return(null); } } }
public void UnLike(VideoDTO video, string username) { var isVoted = this.voteService.IsVoted(video, username); if (isVoted) { this.voteService.UnVote(video, username); } }
public static async Task<List<YouTubeDTO>> SearchYouTube(string searchTerm) { List<YouTubeDTO> DTOs = null; try { var youtubeService = new YouTubeService(new BaseClientService.Initializer() { ApiKey = "<ApiKey goes here>", ApplicationName = "YouTube.Utils.YouTubeUtils" }); string youTubeSearchTerm = searchTerm; int maxResults = 25; var searchListRequest = youtubeService.Search.List("snippet"); searchListRequest.Q = youTubeSearchTerm; searchListRequest.MaxResults = maxResults; // Call the search.list method to retrieve results matching the specified query term. var searchListResponse = await searchListRequest.ExecuteAsync(); YouTubeDTO y = new VideoDTO(); DTOs = new List<YouTubeDTO>(); // Add each result to the appropriate list, and then display the lists of // matching videos, channels, and playlists. foreach (var searchResult in searchListResponse.Items) { if (searchResult.Id.Kind == "youtube#video") { switch (searchResult.Id.Kind) { case "youtube#video": DTOs.Add(new VideoDTO { Title = searchResult.Snippet.Title, Id = searchResult.Id.VideoId }); break; case "youtube#channel": DTOs.Add(new ChannelDTO { Title = searchResult.Snippet.Title, Id = searchResult.Id.ChannelId }); break; case "youtube#playlist": DTOs.Add(new PlayListDTO { Title = searchResult.Snippet.Title, Id = searchResult.Id.PlaylistId }); break; } } } // http://stackoverflow.com/questions/3163922/sort-a-custom-class-listt //DTOs.Sort((a, b) => a.Title.CompareTo(b.Title)); //videoDTOs.Sort(delegate(VideoDTO v1, VideoDTO v2) { return v1.Title.CompareTo(v2.Title); }); } catch (Exception x) { string msg = x.Message; } return DTOs; }