diff --git a/src/Orchard.Web/Core/Themes/Controllers/AdminController.cs b/src/Orchard.Web/Core/Themes/Controllers/AdminController.cs index 138898c4e..8c7211c10 100644 --- a/src/Orchard.Web/Core/Themes/Controllers/AdminController.cs +++ b/src/Orchard.Web/Core/Themes/Controllers/AdminController.cs @@ -15,17 +15,15 @@ namespace Orchard.Core.Themes.Controllers { public class AdminController : Controller { private readonly IThemeService _themeService; private readonly IPreviewTheme _previewTheme; - private readonly IAuthorizer _authorizer; - private readonly INotifier _notifier; - public AdminController(IThemeService themeService, IPreviewTheme previewTheme, IAuthorizer authorizer, INotifier notifier) { + public AdminController(IOrchardServices services, IThemeService themeService, IPreviewTheme previewTheme, IAuthorizer authorizer, INotifier notifier) { + Services = services; _themeService = themeService; _previewTheme = previewTheme; - _authorizer = authorizer; - _notifier = notifier; T = NullLocalizer.Instance; } + public IOrchardServices Services{ get; set; } public Localizer T { get; set; } public ActionResult Index() { @@ -36,7 +34,7 @@ namespace Orchard.Core.Themes.Controllers { return View(model); } catch (Exception exception) { - _notifier.Error(T("Listing themes failed: " + exception.Message)); + Services.Notifier.Error(T("Listing themes failed: " + exception.Message)); return View(new ThemesIndexViewModel()); } } @@ -44,13 +42,13 @@ namespace Orchard.Core.Themes.Controllers { [HttpPost, FormValueAbsent("submit.Apply"), FormValueAbsent("submit.Cancel")] public ActionResult Preview(string themeName, string returnUrl) { try { - if (!_authorizer.Authorize(Permissions.ApplyTheme, T("Couldn't preview the current theme"))) + if (!Services.Authorizer.Authorize(Permissions.ApplyTheme, T("Couldn't preview the current theme"))) return new HttpUnauthorizedResult(); _previewTheme.SetPreviewTheme(themeName); return Redirect(returnUrl ?? "~/"); } catch (Exception exception) { - _notifier.Error(T("Previewing theme failed: " + exception.Message)); + Services.Notifier.Error(T("Previewing theme failed: " + exception.Message)); return RedirectToAction("Index"); } } @@ -58,14 +56,14 @@ namespace Orchard.Core.Themes.Controllers { [HttpPost, ActionName("Preview"), FormValueRequired("submit.Apply")] public ActionResult ApplyPreview(string themeName, string returnUrl) { try { - if (!_authorizer.Authorize(Permissions.ApplyTheme, T("Couldn't preview the current theme"))) + if (!Services.Authorizer.Authorize(Permissions.ApplyTheme, T("Couldn't preview the current theme"))) return new HttpUnauthorizedResult(); _previewTheme.SetPreviewTheme(null); _themeService.SetSiteTheme(themeName); return RedirectToAction("Index"); } catch (Exception exception) { - _notifier.Error(T("Previewing theme failed: " + exception.Message)); + Services.Notifier.Error(T("Previewing theme failed: " + exception.Message)); return RedirectToAction("Index"); } } @@ -73,13 +71,13 @@ namespace Orchard.Core.Themes.Controllers { [HttpPost, ActionName("Preview"), FormValueRequired("submit.Cancel")] public ActionResult CancelPreview(string returnUrl) { try { - if (!_authorizer.Authorize(Permissions.ApplyTheme, T("Couldn't preview the current theme"))) + if (!Services.Authorizer.Authorize(Permissions.ApplyTheme, T("Couldn't preview the current theme"))) return new HttpUnauthorizedResult(); _previewTheme.SetPreviewTheme(null); return RedirectToAction("Index"); } catch (Exception exception) { - _notifier.Error(T("Previewing theme failed: " + exception.Message)); + Services.Notifier.Error(T("Previewing theme failed: " + exception.Message)); return RedirectToAction("Index"); } } @@ -87,13 +85,13 @@ namespace Orchard.Core.Themes.Controllers { [HttpPost] public ActionResult Activate(string themeName) { try { - if (!_authorizer.Authorize(Permissions.ApplyTheme, T("Couldn't set the current theme"))) + if (!Services.Authorizer.Authorize(Permissions.ApplyTheme, T("Couldn't set the current theme"))) return new HttpUnauthorizedResult(); _themeService.SetSiteTheme(themeName); return RedirectToAction("Index"); } catch (Exception exception) { - _notifier.Error(T("Activating theme failed: " + exception.Message)); + Services.Notifier.Error(T("Activating theme failed: " + exception.Message)); return RedirectToAction("Index"); } } @@ -105,7 +103,7 @@ namespace Orchard.Core.Themes.Controllers { [HttpPost] public ActionResult Install(FormCollection input) { try { - if (!_authorizer.Authorize(Permissions.ManageThemes, T("Couldn't install theme"))) + if (!Services.Authorizer.Authorize(Permissions.ManageThemes, T("Couldn't install theme"))) return new HttpUnauthorizedResult(); foreach (string fileName in Request.Files) { HttpPostedFileBase file = Request.Files[fileName]; @@ -114,7 +112,7 @@ namespace Orchard.Core.Themes.Controllers { return RedirectToAction("Index"); } catch (Exception exception) { - _notifier.Error(T("Installing theme failed: " + exception.Message)); + Services.Notifier.Error(T("Installing theme failed: " + exception.Message)); return RedirectToAction("Index"); } } @@ -122,13 +120,13 @@ namespace Orchard.Core.Themes.Controllers { [HttpPost] public ActionResult Uninstall(string themeName) { try { - if (!_authorizer.Authorize(Permissions.ManageThemes, T("Couldn't uninstall theme"))) + if (!Services.Authorizer.Authorize(Permissions.ManageThemes, T("Couldn't uninstall theme"))) return new HttpUnauthorizedResult(); _themeService.UninstallTheme(themeName); return RedirectToAction("Index"); } catch (Exception exception) { - _notifier.Error(T("Uninstalling theme failed: " + exception.Message)); + Services.Notifier.Error(T("Uninstalling theme failed: " + exception.Message)); return RedirectToAction("Index"); } } diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogAdminController.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogAdminController.cs index aa5cda63c..e2956ed73 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogAdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogAdminController.cs @@ -8,48 +8,40 @@ using Orchard.Blogs.Services; using Orchard.Blogs.ViewModels; using Orchard.ContentManagement; using Orchard.Core.Common.Models; -using Orchard.Data; using Orchard.Localization; using Orchard.Mvc.Results; -using Orchard.Security; using Orchard.Settings; using Orchard.UI.Notify; namespace Orchard.Blogs.Controllers { [ValidateInput(false)] public class BlogAdminController : Controller, IUpdateModel { - private readonly IOrchardServices _services; private readonly IBlogService _blogService; private readonly IBlogPostService _blogPostService; - private readonly ISessionLocator _sessionLocator; - private readonly IAuthorizer _authorizer; - private readonly INotifier _notifier; - public BlogAdminController(IOrchardServices services, IBlogService blogService, IBlogPostService blogPostService, ISessionLocator sessionLocator, IAuthorizer authorizer, INotifier notifier) { - _services = services; + public BlogAdminController(IOrchardServices services, IBlogService blogService, IBlogPostService blogPostService) { + Services = services; _blogService = blogService; _blogPostService = blogPostService; - _sessionLocator = sessionLocator; - _authorizer = authorizer; - _notifier = notifier; T = NullLocalizer.Instance; } private Localizer T { get; set; } protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; } + public IOrchardServices Services { get; set; } public ActionResult Create() { //TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute - if (!_authorizer.Authorize(Permissions.ManageBlogs, T("Not allowed to create blogs"))) + if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Not allowed to create blogs"))) return new HttpUnauthorizedResult(); - Blog blog = _services.ContentManager.New(BlogDriver.ContentType.Name); + Blog blog = Services.ContentManager.New(BlogDriver.ContentType.Name); if (blog == null) return new NotFoundResult(); var model = new CreateBlogViewModel { - Blog = _services.ContentManager.BuildEditorModel(blog) + Blog = Services.ContentManager.BuildEditorModel(blog) }; return View(model); @@ -58,25 +50,25 @@ namespace Orchard.Blogs.Controllers { [HttpPost] public ActionResult Create(CreateBlogViewModel model) { //TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute - if (!_authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't create blog"))) + if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't create blog"))) return new HttpUnauthorizedResult(); - model.Blog = _services.ContentManager.UpdateEditorModel(_services.ContentManager.New(BlogDriver.ContentType.Name), this); + model.Blog = Services.ContentManager.UpdateEditorModel(Services.ContentManager.New(BlogDriver.ContentType.Name), this); if (!ModelState.IsValid) return View(model); - _services.ContentManager.Create(model.Blog.Item.ContentItem); + Services.ContentManager.Create(model.Blog.Item.ContentItem); //TEMP: (erikpo) ensure information has committed for this record - _services.ContentManager.Flush(); + Services.ContentManager.Flush(); return Redirect(Url.BlogForAdmin(model.Blog.Item.As().Slug)); } public ActionResult Edit(string blogSlug) { //TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute - if (!_authorizer.Authorize(Permissions.ManageBlogs, T("Not allowed to edit blog"))) + if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Not allowed to edit blog"))) return new HttpUnauthorizedResult(); //TODO: (erikpo) Move looking up the current blog up into a modelbinder @@ -86,7 +78,7 @@ namespace Orchard.Blogs.Controllers { return new NotFoundResult(); var model = new BlogEditViewModel { - Blog = _services.ContentManager.BuildEditorModel(blog) + Blog = Services.ContentManager.BuildEditorModel(blog) }; return View(model); @@ -94,7 +86,7 @@ namespace Orchard.Blogs.Controllers { [HttpPost] public ActionResult Edit(string blogSlug, FormCollection input) { - if (!_authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't edit blog"))) + if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't edit blog"))) return new HttpUnauthorizedResult(); //TODO: (erikpo) Move looking up the current blog up into a modelbinder @@ -104,7 +96,7 @@ namespace Orchard.Blogs.Controllers { return new NotFoundResult(); var model = new BlogEditViewModel { - Blog = _services.ContentManager.UpdateEditorModel(blog, this), + Blog = Services.ContentManager.UpdateEditorModel(blog, this), }; if (!ModelState.IsValid) @@ -115,14 +107,14 @@ namespace Orchard.Blogs.Controllers { CurrentSite.HomePage = "BlogHomePageProvider;" + model.Blog.Item.Id; } - _notifier.Information(T("Blog information updated")); + Services.Notifier.Information(T("Blog information updated")); return Redirect(Url.BlogsForAdmin()); } [HttpPost] public ActionResult Delete(string blogSlug) { - if (!_authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't delete blog"))) + if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't delete blog"))) return new HttpUnauthorizedResult(); //TODO: (erikpo) Move looking up the current blog up into a modelbinder @@ -133,7 +125,7 @@ namespace Orchard.Blogs.Controllers { _blogService.Delete(blog); - _notifier.Information(T("Blog was successfully deleted")); + Services.Notifier.Information(T("Blog was successfully deleted")); return Redirect(Url.BlogsForAdmin()); } @@ -142,7 +134,7 @@ namespace Orchard.Blogs.Controllers { //TODO: (erikpo) Need to make templatePath be more convention based so if my controller name has "Admin" in it then "Admin/{type}" is assumed var model = new AdminBlogsViewModel { Entries = _blogService.Get() - .Select(b => _services.ContentManager.BuildDisplayModel(b, "SummaryAdmin")) + .Select(b => Services.ContentManager.BuildDisplayModel(b, "SummaryAdmin")) .Select(vm => new AdminBlogEntry { ContentItemViewModel = vm, TotalPostCount = _blogPostService.Get(vm.Item, VersionOptions.Latest).Count()}) }; @@ -158,7 +150,7 @@ namespace Orchard.Blogs.Controllers { //TODO: (erikpo) Need to make templatePath be more convention based so if my controller name has "Admin" in it then "Admin/{type}" is assumed var model = new BlogForAdminViewModel { - Blog = _services.ContentManager.BuildDisplayModel(blog, "DetailAdmin") + Blog = Services.ContentManager.BuildDisplayModel(blog, "DetailAdmin") }; return View(model); diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Comments/Controllers/AdminController.cs index 6ae0c486e..a3d0dcf82 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Comments/Controllers/AdminController.cs @@ -7,7 +7,6 @@ using JetBrains.Annotations; using Orchard.Comments.Models; using Orchard.Localization; using Orchard.Logging; -using Orchard.ContentManagement; using Orchard.Services; using Orchard.Settings; using Orchard.UI.Notify; @@ -19,15 +18,10 @@ namespace Orchard.Comments.Controllers { [ValidateInput(false)] public class AdminController : Controller { private readonly ICommentService _commentService; - private readonly IAuthorizer _authorizer; - private readonly IClock _clock; - private readonly INotifier _notifier; - public AdminController(ICommentService commentService, IContentManager contentManager, INotifier notifier, IAuthorizer authorizer, IClock clock) { + public AdminController(IOrchardServices services, ICommentService commentService) { _commentService = commentService; - _authorizer = authorizer; - _clock = clock; - _notifier = notifier; + Services = services; Logger = NullLogger.Instance; T = NullLocalizer.Instance; } @@ -35,6 +29,7 @@ namespace Orchard.Comments.Controllers { protected virtual IUser CurrentUser { get; [UsedImplicitly] private set; } protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; } + public IOrchardServices Services { get; set; } public ILogger Logger { get; set; } public Localizer T { get; set; } @@ -67,7 +62,7 @@ namespace Orchard.Comments.Controllers { return View(model); } catch (Exception exception) { - _notifier.Error(T("Listing comments failed: " + exception.Message)); + Services.Notifier.Error(T("Listing comments failed: " + exception.Message)); return View(new CommentsIndexViewModel()); } } @@ -84,7 +79,7 @@ namespace Orchard.Comments.Controllers { case CommentIndexBulkAction.None: break; case CommentIndexBulkAction.MarkAsSpam: - if (!_authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment"))) + if (!Services.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment"))) return new HttpUnauthorizedResult(); //TODO: Transaction foreach (CommentEntry entry in checkedEntries) { @@ -92,7 +87,7 @@ namespace Orchard.Comments.Controllers { } break; case CommentIndexBulkAction.Pend: - if (!_authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment"))) + if (!Services.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment"))) return new HttpUnauthorizedResult(); //TODO: Transaction foreach (CommentEntry entry in checkedEntries) { @@ -100,7 +95,7 @@ namespace Orchard.Comments.Controllers { } break; case CommentIndexBulkAction.Approve: - if (!_authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment"))) + if (!Services.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment"))) return new HttpUnauthorizedResult(); //TODO: Transaction foreach (CommentEntry entry in checkedEntries) { @@ -108,7 +103,7 @@ namespace Orchard.Comments.Controllers { } break; case CommentIndexBulkAction.Delete: - if (!_authorizer.Authorize(Permissions.ManageComments, T("Couldn't delete comment"))) + if (!Services.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't delete comment"))) return new HttpUnauthorizedResult(); foreach (CommentEntry entry in checkedEntries) { @@ -121,7 +116,7 @@ namespace Orchard.Comments.Controllers { } } catch (Exception exception) { - _notifier.Error(T("Editing comments failed: " + exception.Message)); + Services.Notifier.Error(T("Editing comments failed: " + exception.Message)); return RedirectToAction("Index", "Admin", new { options = viewModel.Options }); } @@ -163,7 +158,7 @@ namespace Orchard.Comments.Controllers { return View(model); } catch (Exception exception) { - _notifier.Error(T("Listing comments failed: " + exception.Message)); + Services.Notifier.Error(T("Listing comments failed: " + exception.Message)); return RedirectToAction("Index"); } } @@ -180,7 +175,7 @@ namespace Orchard.Comments.Controllers { case CommentDetailsBulkAction.None: break; case CommentDetailsBulkAction.MarkAsSpam: - if (!_authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment"))) + if (!Services.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment"))) return new HttpUnauthorizedResult(); //TODO: Transaction foreach (CommentEntry entry in checkedEntries) { @@ -188,7 +183,7 @@ namespace Orchard.Comments.Controllers { } break; case CommentDetailsBulkAction.Pend: - if (!_authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment"))) + if (!Services.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment"))) return new HttpUnauthorizedResult(); foreach (CommentEntry entry in checkedEntries) { @@ -196,7 +191,7 @@ namespace Orchard.Comments.Controllers { } break; case CommentDetailsBulkAction.Approve: - if (!_authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment"))) + if (!Services.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't moderate comment"))) return new HttpUnauthorizedResult(); foreach (CommentEntry entry in checkedEntries) { @@ -204,7 +199,7 @@ namespace Orchard.Comments.Controllers { } break; case CommentDetailsBulkAction.Delete: - if (!_authorizer.Authorize(Permissions.ManageComments, T("Couldn't delete comment"))) + if (!Services.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't delete comment"))) return new HttpUnauthorizedResult(); foreach (CommentEntry entry in checkedEntries) { @@ -217,7 +212,7 @@ namespace Orchard.Comments.Controllers { } } catch (Exception exception) { - _notifier.Error(T("Editing comments failed: " + exception.Message)); + Services.Notifier.Error(T("Editing comments failed: " + exception.Message)); return Details(viewModel.CommentedItemId, viewModel.Options); } @@ -227,7 +222,7 @@ namespace Orchard.Comments.Controllers { [HttpPost] public ActionResult Close(int commentedItemId, string returnUrl) { try { - if (!_authorizer.Authorize(Permissions.CloseComment, T("Couldn't close comments"))) + if (!Services.Authorizer.Authorize(Permissions.CloseComment, T("Couldn't close comments"))) return new HttpUnauthorizedResult(); _commentService.CloseCommentsForCommentedContent(commentedItemId); if (!String.IsNullOrEmpty(returnUrl)) { @@ -236,7 +231,7 @@ namespace Orchard.Comments.Controllers { return RedirectToAction("Index"); } catch (Exception exception) { - _notifier.Error(T("Closing Comments failed: " + exception.Message)); + Services.Notifier.Error(T("Closing Comments failed: " + exception.Message)); if (!String.IsNullOrEmpty(returnUrl)) { return Redirect(returnUrl); } @@ -247,7 +242,7 @@ namespace Orchard.Comments.Controllers { [HttpPost] public ActionResult Enable(int commentedItemId, string returnUrl) { try { - if (!_authorizer.Authorize(Permissions.EnableComment, T("Couldn't enable comments"))) + if (!Services.Authorizer.Authorize(Permissions.EnableComment, T("Couldn't enable comments"))) return new HttpUnauthorizedResult(); _commentService.EnableCommentsForCommentedContent(commentedItemId); if (!String.IsNullOrEmpty(returnUrl)) { @@ -256,7 +251,7 @@ namespace Orchard.Comments.Controllers { return RedirectToAction("Index"); } catch (Exception exception) { - _notifier.Error(T("Enabling Comments failed: " + exception.Message)); + Services.Notifier.Error(T("Enabling Comments failed: " + exception.Message)); if (!String.IsNullOrEmpty(returnUrl)) { return Redirect(returnUrl); } @@ -279,7 +274,7 @@ namespace Orchard.Comments.Controllers { } catch (Exception exception) { - _notifier.Error(T("Editing comment failed: " + exception.Message)); + Services.Notifier.Error(T("Editing comment failed: " + exception.Message)); return RedirectToAction("Index"); } } @@ -289,14 +284,14 @@ namespace Orchard.Comments.Controllers { var viewModel = new CommentsEditViewModel(); try { UpdateModel(viewModel); - if (!_authorizer.Authorize(Permissions.ManageComments, T("Couldn't edit comment"))) + if (!Services.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't edit comment"))) return new HttpUnauthorizedResult(); _commentService.UpdateComment(viewModel.Id, viewModel.Name, viewModel.Email, viewModel.SiteName, viewModel.CommentText, viewModel.Status); return RedirectToAction("Index"); } catch (Exception exception) { - _notifier.Error(T("Editing Comment failed: " + exception.Message)); + Services.Notifier.Error(T("Editing Comment failed: " + exception.Message)); return View(viewModel); } } @@ -304,7 +299,7 @@ namespace Orchard.Comments.Controllers { [HttpPost] public ActionResult Delete(int id, string returnUrl) { try { - if (!_authorizer.Authorize(Permissions.ManageComments, T("Couldn't delete comment"))) + if (!Services.Authorizer.Authorize(Permissions.ManageComments, T("Couldn't delete comment"))) return new HttpUnauthorizedResult(); int commentedOn = _commentService.GetComment(id).Record.CommentedOn; @@ -316,7 +311,7 @@ namespace Orchard.Comments.Controllers { return RedirectToAction("Details", new { id = commentedOn }); } catch (Exception exception) { - _notifier.Error(T("Deleting comment failed: " + exception.Message)); + Services.Notifier.Error(T("Deleting comment failed: " + exception.Message)); if (!String.IsNullOrEmpty(returnUrl)) { return Redirect(returnUrl); } diff --git a/src/Orchard.Web/Modules/Orchard.Media/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Media/Controllers/AdminController.cs index 16d0a9500..60f1d0dca 100644 --- a/src/Orchard.Web/Modules/Orchard.Media/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Media/Controllers/AdminController.cs @@ -6,23 +6,19 @@ using Orchard.Localization; using Orchard.Media.Models; using Orchard.Media.Services; using Orchard.Media.ViewModels; -using Orchard.Security; using Orchard.UI.Notify; namespace Orchard.Media.Controllers { [ValidateInput(false)] public class AdminController : Controller { private readonly IMediaService _mediaService; - private readonly IAuthorizer _authorizer; - private readonly INotifier _notifier; - public AdminController(IMediaService mediaService, IAuthorizer authorizer, INotifier notifier) { + public AdminController(IOrchardServices services, IMediaService mediaService) { + Services = services; _mediaService = mediaService; - _authorizer = authorizer; - _notifier = notifier; } - + public IOrchardServices Services { get; set;} public Localizer T { get; set; } public ActionResult Index() { @@ -44,7 +40,7 @@ namespace Orchard.Media.Controllers { return RedirectToAction("Index"); } catch (Exception exception) { - _notifier.Error("Deleting Folder failed: " + exception.Message); + Services.Notifier.Error("Deleting Folder failed: " + exception.Message); return View(); } } @@ -58,13 +54,13 @@ namespace Orchard.Media.Controllers { var viewModel = new MediaFolderCreateViewModel(); try { UpdateModel(viewModel); - if (!_authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't create media folder"))) + if (!Services.Authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't create media folder"))) return new HttpUnauthorizedResult(); _mediaService.CreateFolder(viewModel.MediaPath, viewModel.Name); return RedirectToAction("Index"); } catch (Exception exception) { - _notifier.Error("Creating Folder failed: " + exception.Message); + Services.Notifier.Error("Creating Folder failed: " + exception.Message); return View(viewModel); } } @@ -83,14 +79,14 @@ namespace Orchard.Media.Controllers { if (key.StartsWith("Checkbox.File.") && input[key] == "true") { string fileName = key.Substring("Checkbox.File.".Length); string folderName = input[fileName]; - if (!_authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't delete media file"))) + if (!Services.Authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't delete media file"))) return new HttpUnauthorizedResult(); _mediaService.DeleteFile(fileName, folderName); } else if (key.StartsWith("Checkbox.Folder.") && input[key] == "true") { string folderName = key.Substring("Checkbox.Folder.".Length); string folderPath = input[folderName]; - if (!_authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't delete media folder"))) + if (!Services.Authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't delete media folder"))) return new HttpUnauthorizedResult(); _mediaService.DeleteFolder(folderPath); } @@ -98,7 +94,7 @@ namespace Orchard.Media.Controllers { return RedirectToAction("Index"); } catch (Exception exception) { - _notifier.Error("Deleting failed: " + exception.Message); + Services.Notifier.Error("Deleting failed: " + exception.Message); return View(); } } @@ -116,13 +112,13 @@ namespace Orchard.Media.Controllers { //TODO: There may be better ways to do this. // Delete if (!String.IsNullOrEmpty(HttpContext.Request.Form["submit.Delete"])) { - if (!_authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't delete media folder"))) + if (!Services.Authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't delete media folder"))) return new HttpUnauthorizedResult(); _mediaService.DeleteFolder(viewModel.MediaPath); } // Save else { - if (!_authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't rename media folder"))) + if (!Services.Authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't rename media folder"))) return new HttpUnauthorizedResult(); _mediaService.RenameFolder(viewModel.MediaPath, viewModel.Name); } @@ -130,7 +126,7 @@ namespace Orchard.Media.Controllers { return RedirectToAction("Index"); } catch (Exception exception) { - _notifier.Error("Modifying Folder Properties failed: " + exception.Message); + Services.Notifier.Error("Modifying Folder Properties failed: " + exception.Message); return View(viewModel); } } @@ -145,7 +141,7 @@ namespace Orchard.Media.Controllers { var viewModel = new MediaItemAddViewModel(); try { UpdateModel(viewModel); - if (!_authorizer.Authorize(Permissions.UploadMediaFiles, T("Couldn't upload media file"))) + if (!Services.Authorizer.Authorize(Permissions.UploadMediaFiles, T("Couldn't upload media file"))) return new HttpUnauthorizedResult(); foreach (string fileName in Request.Files) { @@ -156,7 +152,7 @@ namespace Orchard.Media.Controllers { return RedirectToAction("Edit", new { name = viewModel.FolderName, mediaPath = viewModel.MediaPath }); } catch (Exception exception) { - _notifier.Error("Uploading media file failed: " + exception.Message); + Services.Notifier.Error("Uploading media file failed: " + exception.Message); return View(viewModel); } } @@ -177,11 +173,11 @@ namespace Orchard.Media.Controllers { var viewModel = new MediaItemEditViewModel(); try { UpdateModel(viewModel); - if (!_authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't modify media file"))) + 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 (!_authorizer.Authorize(Permissions.ManageMediaFiles, T("Couldn't delete media file"))) + 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 }); @@ -205,7 +201,7 @@ namespace Orchard.Media.Controllers { mediaPath = viewModel.MediaPath }); } catch (Exception exception) { - _notifier.Error("Editing media file failed: " + exception.Message); + Services.Notifier.Error("Editing media file failed: " + exception.Message); return View(viewModel); } } diff --git a/src/Orchard.Web/Modules/Orchard.Roles/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Roles/Controllers/AdminController.cs index 779f77404..ceef594a4 100644 --- a/src/Orchard.Web/Modules/Orchard.Roles/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Roles/Controllers/AdminController.cs @@ -16,7 +16,6 @@ namespace Orchard.Roles.Controllers { [ValidateInput(false)] public class AdminController : Controller { private readonly IRoleService _roleService; - private readonly INotifier _notifier; private readonly IAuthorizationService _authorizationService; public AdminController( @@ -26,7 +25,6 @@ namespace Orchard.Roles.Controllers { IAuthorizationService authorizationService) { Services = services; _roleService = roleService; - _notifier = notifier; _authorizationService = authorizationService; } @@ -58,7 +56,7 @@ namespace Orchard.Roles.Controllers { return RedirectToAction("Index"); } catch (Exception exception) { - _notifier.Error("Deleting Role failed: " + exception.Message); + Services.Notifier.Error("Deleting Role failed: " + exception.Message); return View(); } } @@ -90,7 +88,7 @@ namespace Orchard.Roles.Controllers { return RedirectToAction("Index"); } catch (Exception exception) { - _notifier.Error("Creating Role failed: " + exception.Message); + Services.Notifier.Error("Creating Role failed: " + exception.Message); return RedirectToAction("Create"); } } @@ -144,7 +142,7 @@ namespace Orchard.Roles.Controllers { return RedirectToAction("Edit", new { viewModel.Id }); } catch (Exception exception) { - _notifier.Error("Editing Role failed: " + exception.Message); + Services.Notifier.Error("Editing Role failed: " + exception.Message); return RedirectToAction("Edit", viewModel.Id); } } diff --git a/src/Orchard.Web/Modules/Orchard.Users/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Users/Controllers/AdminController.cs index a63a78c93..e8dbce4b7 100644 --- a/src/Orchard.Web/Modules/Orchard.Users/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Users/Controllers/AdminController.cs @@ -10,7 +10,6 @@ using Orchard.Users.ViewModels; namespace Orchard.Users.Controllers { public class AdminController : Controller, IUpdateModel { - private readonly IMembershipService _membershipService; public AdminController(