Beispiel #1
0
        public ActionResult RegisterVideo(VIDEO video2, HttpPostedFileBase UserPhoto, HttpPostedFileBase fileupload)
        {
            if (fileupload != null)
            {
                string fileName = Path.GetFileName(fileupload.FileName);
                int    fileSize = fileupload.ContentLength;
                int    Size     = fileSize / 1000;
                fileupload.SaveAs(Server.MapPath("~/Controllers/VideoFileUpload/" + fileName));

                VIDEO video = new VIDEO();
                video.Name           = video2.Name;
                video.FileSize       = fileSize;
                video.FilePath       = "~/Controllers/VideoFileUpload/" + fileName;
                video.UploadDateTime = DateTime.Now;
                video.Owner          = video2.Owner;
                video.ViewCount      = 0;
                ent.VIDEOs.Add(video);

                if (UserPhoto != null)
                {
                    MemoryStream target = new MemoryStream();
                    UserPhoto.InputStream.CopyTo(target);
                    byte[] data = target.ToArray();
                    video.CoverImage = data;
                }


                ent.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public ActionResult UploadVideo(HttpPostedFileBase fileupload)
        {
            if (fileupload != null)
            {
                string fileName = Path.GetFileName(fileupload.FileName);
                int    fileSize = fileupload.ContentLength;
                int    Size     = fileSize / 1000;
                fileupload.SaveAs(Server.MapPath("~/Controllers/VideoFileUpload/" + fileName));

                VIDEO video = new VIDEO();
                video.Name           = fileName;
                video.FileSize       = fileSize;
                video.FilePath       = "~/Controllers/VideoFileUpload/" + fileName;
                video.UploadDateTime = DateTime.Now;
                video.Owner          = fileName;
                ent.VIDEOs.Add(video);
                ent.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
Beispiel #3
0
        public ActionResult EditVideo(VIDEO video2, HttpPostedFileBase UserPhoto, HttpPostedFileBase fileupload)
        {
            var whichVideo = ent.VIDEOs.FirstOrDefault(x => x.ID == video2.ID);

            whichVideo.Name = video2.Name;
            ent.SaveChanges();

            whichVideo.UploadDateTime = DateTime.Now;
            ent.SaveChanges();

            whichVideo.Owner = video2.Owner;
            ent.SaveChanges();

            if (fileupload != null)
            {
                string fileName = Path.GetFileName(fileupload.FileName);
                int    fileSize = fileupload.ContentLength;
                int    Size     = fileSize / 1000;
                fileupload.SaveAs(Server.MapPath("~/Controllers/VideoFileUpload/" + fileName));

                whichVideo.FileSize = fileSize;
                whichVideo.FilePath = "~/Controllers/VideoFileUpload/" + fileName;



                if (UserPhoto != null)
                {
                    MemoryStream target = new MemoryStream();
                    UserPhoto.InputStream.CopyTo(target);
                    byte[] data = target.ToArray();
                    whichVideo.CoverImage = data;
                }

                ent.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }