public ActionResult Link(Video video)
        {
            if (video.SavedContentId > 0)
            {
                DisplayMonkey.Models.Content content = db.Contents.Find(video.SavedContentId);
                video = db.Frames.Find(video.FrameId) as Video;
                video.Contents.Add(content);
                db.SaveChanges();

                return(this.RestoreReferrer() ?? RedirectToAction("Details", new { id = video.FrameId }));
            }

            if (video.FrameId > 0)
            {
                return(RedirectToAction("Uplink", new { id = video.FrameId }));
            }

            return(RedirectToAction("Index", "Frame"));
        }
示例#2
0
        public ActionResult Edit(Content content)
        {
            if (ModelState.IsValid)
            {
                content.Data = new byte[] { 0 };    // trick EF, this is a required field
                db.Contents.Attach(content);
                db.Entry(content).Property(m => m.Name).IsModified = true;
                db.SaveChanges();

                return this.RestoreReferrer() ?? RedirectToAction("Index");
            }

            return View(content);
        }
示例#3
0
        public ActionResult Upload(IEnumerable<HttpPostedFileBase> files)
        {
            // TODO: EditorFor

            bool hasFiles = false, addedFiles = false;
            foreach (HttpPostedFileBase file in files)
            {
                if (file != null && file.ContentLength > 0)
                {
                    string ext = Path.GetExtension(file.FileName).Replace(".", "").ToUpper();
                    bool isPicture = Picture.SupportedFormats.Contains(ext);
                    bool isVideo = Video.SupportedFormats.Contains(ext);
                        
                    if (isPicture || isVideo)
                    {
                        byte[] buffer = null;
                        using (BinaryReader reader = new BinaryReader(file.InputStream))
                        {
                            buffer = reader.ReadBytes(file.ContentLength);
                        }

                        Content content = new Content {
                            Type = isPicture ? ContentTypes.ContentType_Picture : ContentTypes.ContentType_Video,
                            Name = Path.GetFileName(file.FileName),
                            Data = buffer,
                        };

                        db.Contents.Add(content);

                        addedFiles = true;
                    }

                    hasFiles = true;
                }
            }

            if (addedFiles)
            {
                db.SaveChanges();

                return this.RestoreReferrer() ?? RedirectToAction("Index");
            }

            else if (hasFiles)
            {
                // TODO: validator for wrong file types
            }

            return View();
        }
        public ActionResult Upload(Video video, Frame frame, IEnumerable<HttpPostedFileBase> files)
        {
            video.Frame = frame;
            
            // TODO: EditorFor

            bool hasFiles = false, addedFiles = false;
            foreach (HttpPostedFileBase file in files)
            {
                if (file != null && file.ContentLength > 0)
                {
                    string ext = Path.GetExtension(file.FileName).Replace(".", "").ToUpper();
                    bool isVideo = Video.SupportedFormats.Contains(ext);

                    if (isVideo)
                    {
                        byte[] buffer = null;
                        using (BinaryReader reader = new BinaryReader(file.InputStream))
                        {
                            buffer = reader.ReadBytes(file.ContentLength);
                        }

                        Content content = new Content
                        {
                            Type = ContentTypes.ContentType_Video,
                            Name = Path.GetFileName(file.FileName),
                            Data = buffer,
                        };

                        video.Contents.Add(content);

                        addedFiles = true;
                    }

                    hasFiles = true;
                }
            }

            if (addedFiles)
            {
                db.Videos.Add(video);
                db.SaveChanges();

                return this.RestoreReferrer() ?? RedirectToAction("Index", "Frame");
            }

            else if (hasFiles)
            {
                // TODO: validator for wrong file types
            }

            this.FillTemplatesSelectList(db, FrameTypes.Video, video.Frame.TemplateId);
            FillVideosSelectList();
            ViewBag.MaxVideoSize = Setting.GetSetting(db, Setting.Keys.MaxVideoSize).IntValuePositive;

            return View(video);
        }