mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-22 03:37:25 +08:00
Making all of the view models not inherit from BaseViewModel
--HG-- branch : dev
This commit is contained in:
@@ -1,24 +1,24 @@
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.Mvc.Filters;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
using Orchard.Themes.ViewModels;
|
||||
|
||||
namespace Orchard.Themes.Preview {
|
||||
public class PreviewThemeFilter : FilterProvider, IResultFilter {
|
||||
private readonly IThemeService _themeService;
|
||||
private readonly IPreviewTheme _previewTheme;
|
||||
private readonly IWorkContextAccessor _workContextAccessor;
|
||||
private readonly IShapeHelperFactory _shapeHelperFactory;
|
||||
|
||||
public PreviewThemeFilter(IThemeService themeService, IPreviewTheme previewTheme) {
|
||||
public PreviewThemeFilter(IThemeService themeService, IPreviewTheme previewTheme, IWorkContextAccessor workContextAccessor, IShapeHelperFactory shapeHelperFactory) {
|
||||
_themeService = themeService;
|
||||
_previewTheme = previewTheme;
|
||||
_workContextAccessor = workContextAccessor;
|
||||
_shapeHelperFactory = shapeHelperFactory;
|
||||
}
|
||||
|
||||
public void OnResultExecuting(ResultExecutingContext filterContext) {
|
||||
var baseViewModel = BaseViewModel.From(filterContext.Result);
|
||||
if (baseViewModel == null)
|
||||
return;
|
||||
|
||||
var previewThemeName = _previewTheme.GetPreviewTheme();
|
||||
if (string.IsNullOrEmpty(previewThemeName))
|
||||
return;
|
||||
@@ -31,11 +31,11 @@ namespace Orchard.Themes.Preview {
|
||||
Selected = theme.ThemeName == previewThemeName
|
||||
})
|
||||
};
|
||||
baseViewModel.Zones.AddRenderPartial("body:before", "Admin/ThemePreview", model);
|
||||
|
||||
var shape = _shapeHelperFactory.CreateHelper();
|
||||
_workContextAccessor.GetContext(filterContext).CurrentPage.Zones["Body"].Add(shape.ThemePreview(model), ":before");
|
||||
}
|
||||
|
||||
public void OnResultExecuted(ResultExecutedContext filterContext) {
|
||||
|
||||
}
|
||||
public void OnResultExecuted(ResultExecutedContext filterContext) {}
|
||||
}
|
||||
}
|
@@ -1,8 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Themes.ViewModels {
|
||||
public class ThemesIndexViewModel : BaseViewModel {
|
||||
public class ThemesIndexViewModel {
|
||||
public ITheme CurrentTheme { get; set; }
|
||||
public IEnumerable<ITheme> Themes { get; set; }
|
||||
}
|
||||
|
Reference in New Issue
Block a user