コード例 #1
0
        // Delete file from the server
        private void DeleteFile(HttpContext context)
        {
            if (context.Request["f"] == null)
            {
                return;
            }

            var filePath = StorageRoot + context.Request["f"];

            GerenciarMidia.DeletarMidiaDirectory(filePath);

            var idMidia = int.Parse(Path.GetFileNameWithoutExtension(filePath).Split('_').Last());

            GerenciarMidia.DeletarMidia(idMidia);
        }
コード例 #2
0
        public ActionResult Edit([Bind(Include = "Id,IdEmpresa,Status,Nome,Extensao,Tamanho")] Midia midia)
        {
            if (ModelState.IsValid)
            {
                var midiaOld = _midiaDao.Get(midia.Id);
                GerenciarMidia.RenameMidiaDirectory(midia.IdEmpresa, midiaOld.Nome + midiaOld.Extensao, midia.Nome + midia.Extensao);

                midiaOld.Status = midia.Status;
                midiaOld.Nome   = midia.Nome;

                _midiaDao.Save(midiaOld);

                return(RedirectToAction("Index"));
            }
            return(View(midia));
        }
コード例 #3
0
        // Upload entire file
        private void UploadWholeFile(HttpContext context, List <FilesStatus> statuses)
        {
            for (int i = 0; i < context.Request.Files.Count; i++)
            {
                var file = context.Request.Files[i];

                var midia    = GerenciarMidia.SalvarMidia(file, Empresa);
                var fileName = string.Format("{0}{1}", midia.Nome, midia.Extensao);

                var fullPath = StorageRoot + Path.GetFileName(fileName);

                file.SaveAs(fullPath);

                string fullName = Path.GetFileName(fileName);
                statuses.Add(new FilesStatus(fullName, file.ContentLength, fullPath));
            }
        }
コード例 #4
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Midia midia = _midiaDao.Get((int)id);

            if (midia == null)
            {
                return(HttpNotFound());
            }
            _midiaDao.Delete(midia);

            GerenciarMidia.DeletarMidiaDirectory(string.Format("{0}{1}", midia.Nome, midia.Extensao), midia.IdEmpresa);

            return(RedirectToAction("Index"));
        }