Example #1
0
        public ActionResult VideoCreate(Video v)
        {
            HttpPostedFileBase videocover = Request.Files["Cover"];
            HttpPostedFileBase videurl    = Request.Files["VideoURL"];

            v.AddTime = System.DateTime.Now;
            try
            {
                if (videocover != null)
                {
                    string filePath     = videocover.FileName;
                    string filename     = filePath.Substring(filePath.LastIndexOf("\\") + 1);
                    string serverpath   = Server.MapPath(@"\Images\Video\") + filename;
                    string relativepath = @"/Images/Video/" + filename;
                    videocover.SaveAs(serverpath);
                    v.Cover = relativepath;
                }
                else
                {
                    return(Content("<script>;alert('请先上传图片!');history.go(-1)</script>"));
                }
                if (videurl != null)
                {
                    string filePath     = videurl.FileName;
                    string filename     = filePath.Substring(filePath.LastIndexOf("\\") + 1);
                    string serverpath   = Server.MapPath(@"\Video\") + filename;
                    string relativepath = @"/Video/" + filename;
                    videurl.SaveAs(serverpath);
                    v.VideoURL = relativepath;
                }
                video.AddVideo(v);

                db.SaveChanges();
                return(RedirectToAction("CiIndex"));
            }
            catch (Exception ex)
            {
                return(Content(ex.Message));
            }
            ViewBag.VideoK_id = new SelectList(db.VideoK, "VideoK_id", "VideoKName", v.VideoK_id);
            return(View("CiCreate", v));
        }
Example #2
0
        public ActionResult UpVideo(Video videor)
        {
            var imgfile   = Request.Files["imgfile"];
            var video1    = Request.Files["video"];
            var title     = Request["title"];
            var intro     = Request["intro"];
            var videopath = Guid.NewGuid().ToString() + video1.FileName;
            var imgpath   = Guid.NewGuid().ToString() + imgfile.FileName;

            video1.SaveAs(Request.MapPath("/Images/video/" + videopath));
            imgfile.SaveAs(Request.MapPath("/Images/videoimg/" + imgpath));

            videor.Adress  = "../video/" + videopath;
            videor.Image   = "../videoimg/" + imgpath;
            videor.Intro   = intro;
            videor.likenum = 0;
            videor.Time    = DateTime.Now;
            videor.Title   = title;
            videor.UserID  = Convert.ToInt32(Session["User_id"]);
            videos.AddVideo(videor);
            return(View());
        }
Example #3
0
        private void ProcessCommand(int input)
        {
            Console.Clear();
            Console.SetCursorPosition(0, 0);
            switch (input)
            {
            case 1:
                Console.WriteLine("Enter the title of the video: ");
                string title = Console.ReadLine();
                Console.WriteLine("Select the genre of the video: ");
                Genre genre = Utility.SelectGenre();

                manager.AddVideo(title, genre);
                break;

            case 2:
                Console.WriteLine("Enter the ID of the video: ");
                int lookId = Utility.ReadNumber();

                Console.WriteLine(manager.FindVideo(lookId));
                break;

            case 3:
                Console.WriteLine("Enter the ID of the video to be updated: ");
                int id = Utility.ReadNumber();

                Console.WriteLine("Enter the title of the video: ");
                string newTitle = Console.ReadLine();
                Console.WriteLine("Select the genre of the video: ");
                Genre newGenre = Utility.SelectGenre();

                if (manager.UpdateVideo(id, newTitle, newGenre))
                {
                    Console.WriteLine("Update successfull!");
                }
                else
                {
                    Console.WriteLine("Update unsuccessfull!");
                }
                break;

            case 4:
                Console.WriteLine("Enter the ID of the video to be deleted: ");
                int deleteId = Utility.ReadNumber();
                if (manager.DeleteVideo(deleteId))
                {
                    Console.WriteLine("Deletion successfull!");
                }
                else
                {
                    Console.WriteLine("Deletion unsuccessfull!");
                }
                break;

            case 5:
                Console.WriteLine(manager.ListVideos());
                break;

            case 6:
                run = false;
                break;

            default:
                Console.WriteLine("Other");
                break;
            }
            Console.WriteLine("Press Enter to continue!");
        }