public IEnumerable <Video> GetAllVideos(SQLiteConnection scope)
        {
            if (scope == null)
            {
                throw new ArgumentNullException(nameof(scope));
            }

            return(VideoRepo.GetAllVideos(scope));
        }
        public IActionResult GetCategoryAndVideo(Guid categoryId, Guid videoId)
        {
            var category = VideoRepo.FindVideo(categoryId, videoId);

            if (category == null || category.Videos.Count == 0)
            {
                return(NotFound($"Category with ID '{categoryId}' or Video with ID '{videoId}' not found."));
            }

            return(Ok(category));
        }
        public IActionResult GetCategory(Guid categoryId)
        {
            var category = VideoRepo.FindCategoryVideos(categoryId);

            if (category == null)
            {
                return(NotFound($"Category with ID '{categoryId}' not found."));
            }

            return(Ok(category));
        }
        public IActionResult GetAllVideos()
        {
            var videos = VideoRepo.FindAllVideos();

            return(Ok(videos));
        }
Beispiel #5
0
        public ActionResult NewPost(HttpPostedFileBase video, Post newPost, int channelID, string postTags)
        {
            try
            {
                ChannelRepo cr          = new ChannelRepo();
                PostRepo    pr          = new PostRepo();
                VideoRepo   vr          = new VideoRepo();
                User        currentUser = Session["user"] as User;

                if (cr.IsUserOwnerOfChannel(currentUser.UserID, channelID))
                {
                    if (newPost != null && !(string.IsNullOrEmpty(newPost.PostTitle)) && video != null)
                    {
                        string uploadedVideo = GenFunx.VideoUpload(video, "~/Content/Videos/Temporary", out bool isUploaded);
                        if (isUploaded)
                        {
                            string relocatedVideo = GenFunx.RelocateVideo(uploadedVideo, out bool isCopied);
                            if (isCopied)
                            {
                                string thumbnailPath = GenFunx.GetThumbnailFromVideo(relocatedVideo, out bool isDone);
                                if (isDone)
                                {
                                    newPost.ChannelID         = channelID;
                                    newPost.PostThumbnailPath = thumbnailPath.Split('/').Last();

                                    bool sonuc = pr.InsertPost(newPost, out string islemSonucu);

                                    if (sonuc)
                                    {
                                        Video newVideo = GenFunx.GetVideoFromMediaFile(relocatedVideo);
                                        //TODO: Farklı boyutlara convert etme işlemi burada olacak. relocatedVideo işle işlem yapılacak.
                                        //TODO: Transaction yapısı include edilecek
                                        newVideo.PostID = newPost.PostID;
                                        bool vidOK = vr.InsertVideo(newVideo, out islemSonucu);
                                        if (vidOK)
                                        {
                                            ViewBag.Sonuc = "Yeni video başarıyla yüklendi";
                                            pr.AddTagsToPost(postTags, newPost);
                                        }
                                        else
                                        {
                                            ViewBag.Sonuc = "Video yüklenirken hata oldu: " + islemSonucu;
                                        }
                                    }
                                    else
                                    {
                                        ViewBag.Sonuc = "Kayıt sırasında bir hata meydana geldi: " + islemSonucu;
                                    }
                                }
                                else
                                {
                                    ViewBag.Sonuc = "Küçük resim alındamadı: " + thumbnailPath;
                                }
                            }
                            else
                            {
                                ViewBag.Sonuc = "Yükleme sırasında bir hata oluştu: " + relocatedVideo;
                            }
                        }
                        else
                        {
                            ViewBag.Sonuc = "Yükleme sırasında bir hata oluştu: " + uploadedVideo;
                        }
                    }
                    else
                    {
                        ViewBag.Sonuc = "Video nesnesi veya başlığı boş bırakılamaz";
                    }
                }
                else
                {
                    ViewBag.Sonuc = "Bu kanalı kullanarak video yükleyemezsiniz";
                }
            }
            catch (Exception ex)
            {
                ViewBag.Sonuc = ex.Message;
            }

            return(View());
        }
 public void Delete(SQLiteConnection connection, Video video)
 {
     VideoRepo.Delete(connection, video);
 }
 public void Update(SQLiteConnection connection, Video video)
 {
     VideoRepo.Update(connection, video);
 }
 public void Add(SQLiteConnection connection, Video video)
 {
     VideoRepo.Add(connection, video);
 }
 public Video Get(SQLiteConnection connection, int id)
 {
     return(VideoRepo.Get(connection, id));
 }
Beispiel #10
0
 public IList <Video> GetAll(SQLiteConnection connection)
 {
     connection.InsertAll(videos, typeof(Video));
     return(VideoRepo.GetAll(connection).ToList());
 }
Beispiel #11
0
 public VideoService(IRestClient client, VideoRepo repo, ILoginStateService loginState)
 {
     this.client     = client;
     this.repo       = repo;
     this.loginState = loginState;
 }