Ejemplo n.º 1
0
        //
        // GET: /Default1/Edit/5

        public ActionResult Edit(long id)
        {
            UploadRepository.CreateUploadGUID(HttpContext);
            Medium medium = _db.Media.Single(m => m.MediaID == id);

            if (medium.Duration == null)
            {
                medium.Duration = TimeSpan.Zero;
            }
            medium.Updated = DateTime.Now;
            bool shouldCalculatenewHash = false;

            if (medium.Hash == null || medium.Size == 0)
            {
                shouldCalculatenewHash = true;
            }

            // Calculate new hash/size
            if (shouldCalculatenewHash)
            {
                using (var fs = new FileStream(Server.MapPath("~/" + medium.Location), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    medium.Hash = Hashes.MD5(fs);
                    medium.Size = new FileInfo(Server.MapPath("~/" + medium.Location)).Length;
                }
            }

            return(View(medium));
        }
Ejemplo n.º 2
0
        //
        // GET: /Default1/Create

        public ActionResult Create()
        {
            UploadRepository.CreateUploadGUID(HttpContext);
            Medium medium = new Medium();

            medium.Duration = TimeSpan.Zero;

            return(View(medium));
        }
Ejemplo n.º 3
0
        //
        // GET: /Default1/Create

        public ActionResult Create()
        {
            UploadRepository.CreateUploadGUID(HttpContext);
            var medium = new Medium {
                Duration = TimeSpan.Zero
            };

            ViewBag.MediaType = new SelectList(_types.Distinct().ToList(), "", "");
            return(View(medium));
        }
Ejemplo n.º 4
0
        //rendering the dialog box
        public static void Render(string name, string action, string legend, string label, string onComplete)
        {
            var insideView = ((System.Web.Mvc.WebViewPage)WebPageContext.Current.Page);

            UploadRepository.CreateUploadGUID(insideView.Context);
            var uploadid = UploadIDTag + Guid.NewGuid().ToString();

            insideView.Html.RenderPartial(
                "FileUpload",
                new FileUpload()
            {
                Name        = name,
                OnComplete  = onComplete,
                Action      = action,
                Title       = legend,
                Label       = label,
                UploadID    = uploadid,
                MaxFileSize = PrettyPrinter.FormatByteCount((ulong)((HttpRuntimeSection)ConfigurationManager.GetSection("system.web/httpRuntime")).MaxRequestLength * 100)
            });
        }