Example #1
0
        public IHttpActionResult RemoveAuthor([FromBody] JObject request)
        {
            Channel        ch     = request["channel"].ToObject <Channel>();
            Repo <Channel> cr     = new ChannelRepo();
            Account        author = request["author"].ToObject <Account>();

            ch.RemoveAuthor(author);
            cr.Update(ch);
            return(Ok());
        }
Example #2
0
        public ActionResult ViewProfile(int id = 0)
        {
            UserRepo ur = new UserRepo();

            if (id < 1)
            {
                if (Session["user"] != null)
                {
                    User           current   = Session["user"] as User;
                    ChannelRepo    cr        = new ChannelRepo();
                    List <Channel> chsOfUser = cr.GetChannelsByID(current.UserID, false);
                    return(View(Tuple.Create <User, List <Channel> >(current, chsOfUser)));
                }
                else
                {
                    return(RedirectToAction("NotFound", "Home"));
                }
            }
            else
            {
                try
                {
                    User           current   = ur.GetUserByID(Convert.ToInt32(id));
                    ChannelRepo    cr        = new ChannelRepo();
                    List <Channel> chsOfUser = cr.GetChannelsByID(current.UserID, false);
                    return(View(Tuple.Create(current, chsOfUser)));
                }
                catch (FormatException)
                {
                    return(RedirectToAction("NotFound", "Home"));
                }
                catch (NullReferenceException)
                {
                    return(RedirectToAction("NotFound", "Home"));
                }
            }
        }
Example #3
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 ChannelController(IConfiguration configuration)
 {
     ChannelRepo     = new ChannelRepo(configuration);
     _configuration  = configuration;
     auditLogService = new AuditLogService(HttpContext, configuration);
 }