Exemplo n.º 1
0
        public ActionResult EditMedia(FormCollection input) {
            if (!Services.Authorizer.Authorize(Permissions.ManageMedia, T("Couldn't modify media file")))
                return new HttpUnauthorizedResult();

            var viewModel = new MediaItemEditViewModel();
            UpdateModel(viewModel);
            string viewModelName = viewModel.Name;

            // Rename
            if (!String.Equals(viewModel.Name, input["NewName"], StringComparison.OrdinalIgnoreCase)) {
                try {
                    _mediaService.RenameFile(viewModel.MediaPath, viewModel.Name, input["NewName"]);
                }
                catch (ArgumentException) {
                    Services.Notifier.Error(T("Editing media file failed."));
                    return EditMedia(viewModel);
                }
                viewModelName = input["NewName"];
            }

            Services.Notifier.Information(T("Media information updated"));
            return RedirectToAction("EditMedia", new { name = viewModelName, 
                                                        caption = viewModel.Caption, 
                                                        lastUpdated = viewModel.LastUpdated, 
                                                        size = viewModel.Size,
                                                        folderName = viewModel.FolderName,
                                                        mediaPath = viewModel.MediaPath });
        }
Exemplo n.º 2
0
        public ActionResult EditMediaDeletePOST(FormCollection input) {
            if (!Services.Authorizer.Authorize(Permissions.ManageMedia, T("Couldn't delete media file")))
                return new HttpUnauthorizedResult();

            var viewModel = new MediaItemEditViewModel();
            UpdateModel(viewModel);
            try {
                _mediaService.DeleteFile(viewModel.Name, viewModel.MediaPath);
                Services.Notifier.Information(T("Media deleted"));
            }
            catch (ArgumentException argumentException) {
                Services.Notifier.Error(T("Removing media file failed: {0}", argumentException.Message));
                return View(viewModel);
            }

            return RedirectToAction("Edit", new { name = viewModel.FolderName, mediaPath = viewModel.MediaPath });
        }
Exemplo n.º 3
0
 public ActionResult EditMedia(FormCollection input) {
     var viewModel = new MediaItemEditViewModel();
     try {
         UpdateModel(viewModel);
         if (!Services.Authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't modify media file")))
             return new HttpUnauthorizedResult();
         // Delete
         if (!String.IsNullOrEmpty(HttpContext.Request.Form["submit.Delete"])) {
             if (!Services.Authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't delete media file")))
                 return new HttpUnauthorizedResult();
             _mediaService.DeleteFile(viewModel.Name, viewModel.MediaPath);
             return RedirectToAction("Edit", new { name = viewModel.FolderName, mediaPath = viewModel.MediaPath });
         }
         // Save and Rename
         if (!String.Equals(viewModel.Name, input["NewName"], StringComparison.OrdinalIgnoreCase)) {
             _mediaService.RenameFile(viewModel.Name, input["NewName"], viewModel.MediaPath);
             return RedirectToAction("EditMedia", new { name = input["NewName"],
                                                        caption = viewModel.Caption,
                                                        lastUpdated = viewModel.LastUpdated,
                                                        size = viewModel.Size,
                                                        folderName = viewModel.FolderName,
                                                        mediaPath = viewModel.MediaPath });
         }
         // Save
         return RedirectToAction("EditMedia", new { name = viewModel.Name, 
                                                    caption = viewModel.Caption, 
                                                    lastUpdated = viewModel.LastUpdated, 
                                                    size = viewModel.Size,
                                                    folderName = viewModel.FolderName,
                                                    mediaPath = viewModel.MediaPath });
     }
     catch (Exception exception) {
         Services.Notifier.Error("Editing media file failed: " + exception.Message);
         return View(viewModel);
     }
 }
Exemplo n.º 4
0
 public ActionResult EditMedia(MediaItemEditViewModel model) {
     model.PublicUrl = _mediaService.GetMediaPublicUrl(model.MediaPath, model.Name);
     return View(model);
 }
Exemplo n.º 5
0
 public ActionResult EditMedia(string name, string caption, DateTime lastUpdated, long size, string folderName, string mediaPath) {
     var model = new MediaItemEditViewModel();
     model.Name = name;
     model.Caption = caption ?? String.Empty;
     model.LastUpdated = lastUpdated;
     model.Size = size;
     model.FolderName = folderName;
     model.MediaPath = mediaPath;
     model.PublicUrl = _mediaService.GetPublicUrl(Path.Combine(mediaPath, name));
     return View(model);
 }