Fixes member data indexing to ensure it includes the unique key, fixes the EntityService search to return IEnumerable<EntityBasic>, not search results so the data returned is limited to non-sensitive data, adds AdditionalData to EntityBasic so we can add additional values like URL to outgoing entities, Fixes up the searchService, searchControllers to use new structure.
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AutoMapper;
|
||||
using Examine;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Mapping;
|
||||
@@ -12,6 +16,39 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
config.CreateMap<UmbracoEntity, EntityBasic>()
|
||||
.ForMember(basic => basic.Icon, expression => expression.MapFrom(entity => entity.ContentTypeIcon));
|
||||
|
||||
config.CreateMap<SearchResult, EntityBasic>()
|
||||
//default to document icon
|
||||
.ForMember(x => x.Icon, expression => expression.UseValue("icon-document"))
|
||||
.ForMember(x => x.Id, expression => expression.MapFrom(result => result.Id))
|
||||
.AfterMap((result, basic) =>
|
||||
{
|
||||
basic.Name = result.Fields.ContainsKey("nodeName") ? result.Fields["nodeName"] : "[no name]";
|
||||
if (result.Fields.ContainsKey("__NodeKey"))
|
||||
{
|
||||
Guid key;
|
||||
if (Guid.TryParse(result.Fields["__NodeKey"], out key))
|
||||
{
|
||||
basic.Key = key;
|
||||
}
|
||||
}
|
||||
if (result.Fields.ContainsKey("ParentID"))
|
||||
{
|
||||
int parentId;
|
||||
if (int.TryParse(result.Fields["ParentID"], out parentId))
|
||||
{
|
||||
basic.ParentId = parentId;
|
||||
}
|
||||
else
|
||||
{
|
||||
basic.ParentId = -1;
|
||||
}
|
||||
}
|
||||
basic.Path = result.Fields.ContainsKey("__Path") ? result.Fields["__Path"] : "";
|
||||
});
|
||||
|
||||
config.CreateMap<ISearchResults, IEnumerable<EntityBasic>>()
|
||||
.ConvertUsing(results => results.Select(Mapper.Map<EntityBasic>).ToList());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user