Making all of the view models not inherit from BaseViewModel

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-09-01 15:33:31 -07:00
parent b85a6ed122
commit 026764544a
26 changed files with 40 additions and 65 deletions

View File

@@ -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) {}
}
}

View File

@@ -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; }
}