mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Shifting widgets and service
The service layer doesn't need query hints anymore
This commit is contained in:
@@ -1,34 +1,51 @@
|
||||
using Orchard.ContentManagement;
|
||||
using System.Globalization;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.FieldStorage.InfosetStorage;
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Orchard.Core.Navigation.Models {
|
||||
public class MenuWidgetPart : ContentPart<MenuWidgetPartRecord> {
|
||||
|
||||
public int StartLevel {
|
||||
get { return Record.StartLevel; }
|
||||
set { Record.StartLevel = value; }
|
||||
get { return int.Parse(this.As<InfosetPart>().Get<MenuWidgetPart>("StartLevel") ?? "0", CultureInfo.InvariantCulture); }
|
||||
set {
|
||||
this.As<InfosetPart>().Set<MenuWidgetPart>("StartLevel", value.ToString(CultureInfo.InvariantCulture));
|
||||
Record.StartLevel = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Levels {
|
||||
get { return Record.Levels; }
|
||||
set { Record.Levels = value; }
|
||||
get { return int.Parse(this.As<InfosetPart>().Get<MenuWidgetPart>("Levels") ?? "0", CultureInfo.InvariantCulture); }
|
||||
set {
|
||||
this.As<InfosetPart>().Set<MenuWidgetPart>("Levels", value.ToString(CultureInfo.InvariantCulture));
|
||||
Record.Levels = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Breadcrumb {
|
||||
get { return Record.Breadcrumb; }
|
||||
set { Record.Breadcrumb = value; }
|
||||
get { return bool.Parse(this.As<InfosetPart>().Get<MenuWidgetPart>("Breadcrumb") ?? "false"); }
|
||||
set {
|
||||
this.As<InfosetPart>().Set<MenuWidgetPart>("Breadcrumb", value.ToString());
|
||||
Record.Breadcrumb = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool AddHomePage {
|
||||
get { return Record.AddHomePage; }
|
||||
set { Record.AddHomePage = value; }
|
||||
get { return bool.Parse(this.As<InfosetPart>().Get<MenuWidgetPart>("AddHomePage") ?? "false"); }
|
||||
set {
|
||||
this.As<InfosetPart>().Set<MenuWidgetPart>("AddHomePage", value.ToString());
|
||||
Record.AddHomePage = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool AddCurrentPage {
|
||||
get { return Record.AddCurrentPage; }
|
||||
set { Record.AddCurrentPage = value; }
|
||||
get { return bool.Parse(this.As<InfosetPart>().Get<MenuWidgetPart>("AddCurrentPage") ?? "false"); }
|
||||
set {
|
||||
this.As<InfosetPart>().Set<MenuWidgetPart>("AddCurrentPage", value.ToString());
|
||||
Record.AddCurrentPage = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ContentItemRecord Menu {
|
||||
get { return Record.Menu; }
|
||||
set { Record.Menu = value; }
|
||||
|
@@ -49,14 +49,12 @@ namespace Orchard.Widgets.Services {
|
||||
public IEnumerable<WidgetPart> GetWidgets() {
|
||||
return _contentManager
|
||||
.Query<WidgetPart, WidgetPartRecord>()
|
||||
.WithQueryHints(new QueryHints().ExpandRecords<CommonPartRecord>()).
|
||||
List();
|
||||
.List();
|
||||
}
|
||||
|
||||
public IEnumerable<WidgetPart> GetOrphanedWidgets() {
|
||||
return _contentManager
|
||||
.Query<WidgetPart, WidgetPartRecord>()
|
||||
.Where<CommonPartRecord>(x => x.Container == null)
|
||||
.List();
|
||||
}
|
||||
|
||||
@@ -64,7 +62,6 @@ namespace Orchard.Widgets.Services {
|
||||
return _contentManager
|
||||
.Query<WidgetPart, WidgetPartRecord>()
|
||||
.Where<CommonPartRecord>(x => x.Container.Id == layerId)
|
||||
.WithQueryHints(new QueryHints().ExpandRecords<CommonPartRecord>())
|
||||
.List();
|
||||
}
|
||||
|
||||
@@ -72,7 +69,6 @@ namespace Orchard.Widgets.Services {
|
||||
return _contentManager
|
||||
.Query<WidgetPart, WidgetPartRecord>()
|
||||
.Where<CommonPartRecord>(x => layerIds.Contains(x.Container.Id))
|
||||
.WithQueryHints(new QueryHints().ExpandRecords<CommonPartRecord>())
|
||||
.List();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user