Exemplo n.º 1
0
        public ActionResult VideoUpload(HttpPostedFileBase denemeDosyasi)
        {
            string uploadedVideo  = GenFunx.VideoUpload(denemeDosyasi, "~/Content/Videos/Temporary", out bool isUploaded);
            string relocatedVideo = GenFunx.RelocateVideo(uploadedVideo, out bool isCopied);

            if (isCopied)
            {
                ViewBag.Sonuc = relocatedVideo;
            }
            else
            {
                ViewBag.Sonuc = "Bir sorun oluştu: " + uploadedVideo + " " + relocatedVideo;
            }
            return(View());
        }
Exemplo n.º 2
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());
        }