コード例 #1
0
        public ActionResult ImageUpload(HttpPostedFileBase denemeDosyasi)
        {
            bool   isUploaded       = false;
            string uploadedFilePath = GenFunx.ImageUpload(denemeDosyasi, "ProfilePictures", out isUploaded);

            if (isUploaded)
            {
                isUploaded = false;
                Image thumb = GenFunx.ResizeImage(uploadedFilePath, new Size()
                {
                    Height = 100, Width = 100
                });
                string uploadedThumbPath = GenFunx.ImageUpload(thumb, "Thumbnails", uploadedFilePath.Split('/').Last(), out isUploaded);
                if (isUploaded)
                {
                    ViewBag.Resim = uploadedFilePath;
                    ViewBag.Thumb = uploadedThumbPath;
                }
                else
                {
                    ViewBag.Sonuc = uploadedThumbPath;
                }
            }
            else
            {
                ViewBag.Sonuc = uploadedFilePath;
            }

            return(View());
        }
コード例 #2
0
ファイル: ChannelController.cs プロジェクト: aducat5/BooTube
        public ActionResult NewChannel(Channel newChannel, HttpPostedFileBase imgChannelProfilePicture, HttpPostedFileBase imgChannelCoverPicture)
        {
            if (imgChannelProfilePicture != null)
            {
                bool isUploaded = false;

                string uploadedFilePath = GenFunx.ImageUpload(imgChannelProfilePicture, "~/Content/Images/ChannelPictures", out isUploaded);

                if (isUploaded)
                {
                    isUploaded = false;

                    Image thumbImage = GenFunx.ResizeImage(uploadedFilePath, new Size()
                    {
                        Height = 200, Width = 200
                    });
                    string uploadedThumbPath = GenFunx.ImageUpload(thumbImage, "~/Content/Images/Thumbnails", uploadedFilePath.Split('/').Last(), out isUploaded);

                    if (isUploaded)
                    {
                        newChannel.ChannelProfilePicture = uploadedFilePath.Split('/').Last();
                    }
                }
            }

            if (imgChannelCoverPicture != null)
            {
                bool isUploaded = false;

                string uploadedCoverPath = GenFunx.ImageUpload(imgChannelCoverPicture, "~/Content/Images/ChannelCovers", out isUploaded);

                if (isUploaded)
                {
                    isUploaded = false;

                    Image thumbCover = GenFunx.ResizeImage(uploadedCoverPath, new Size()
                    {
                        Height = 200, Width = 256
                    });
                    string uploadedThumbPath = GenFunx.ImageUpload(thumbCover, "~/Content/Images/Thumbnails", uploadedCoverPath.Split('/').Last(), out isUploaded);

                    if (isUploaded)
                    {
                        newChannel.ChannelCoverPicture = uploadedCoverPath.Split('/').Last();
                    }
                }
            }

            if (cr.InsertChannel(newChannel, out string islemSonucu))
            {
                return(RedirectToAction("ViewChannels"));
            }
            else
            {
                ViewBag.Hata = islemSonucu;
                return(View());
            }
        }
コード例 #3
0
ファイル: ChannelController.cs プロジェクト: aducat5/BooTube
        public ActionResult EditChannel(Channel chToUp, HttpPostedFileBase imgChannelProfilePicture, HttpPostedFileBase imgChannelCoverPicture)
        {
            chToUp.CreateTime = DateTime.Now;
            chToUp.User       = Session["user"] as User;
            if (imgChannelProfilePicture != null)
            {
                bool isUploaded = false;

                string uploadedFilePath = GenFunx.ImageUpload(imgChannelProfilePicture, "~/Content/Images/ChannelPictures", out isUploaded);

                if (isUploaded)
                {
                    isUploaded = false;

                    Image thumbImage = GenFunx.ResizeImage(uploadedFilePath, new Size()
                    {
                        Height = 200, Width = 200
                    });

                    string uploadedThumbPath = GenFunx.ImageUpload(thumbImage, "~/Content/Images/Thumbnails", uploadedFilePath.Split('/').Last(), out isUploaded);

                    if (isUploaded)
                    {
                        chToUp.ChannelProfilePicture = uploadedFilePath.Split('/').Last();
                    }
                }
                else
                {
                    ViewBag.Hata = "Profil resmi karşıya yüklenemedi";
                    return(View());
                }
            }

            if (imgChannelCoverPicture != null)
            {
                bool isUploaded = false;

                string uploadedCoverPath = GenFunx.ImageUpload(imgChannelCoverPicture, "~/Content/Images/ChannelCovers", out isUploaded);

                if (isUploaded)
                {
                    isUploaded = false;

                    Image thumbCover = GenFunx.ResizeImage(uploadedCoverPath, new Size()
                    {
                        Height = 200, Width = 256
                    });

                    string uploadedThumbPath = GenFunx.ImageUpload(thumbCover, "~/Content/Images/Thumbnails", uploadedCoverPath.Split('/').Last(), out isUploaded);

                    if (isUploaded)
                    {
                        chToUp.ChannelCoverPicture = uploadedCoverPath.Split('/').Last();
                    }
                }
                else
                {
                    ViewBag.Hata = "Kapak resmi karşıya yüklenemedi";
                    return(View());
                }
            }

            if (cr.EditChannel(chToUp, out string islemSonucu))
            {
                return(RedirectToAction("ViewChannels"));
            }
            else
            {
                ViewBag.Hata = islemSonucu;
                return(View(chToUp));
            }
        }