Fixed to use alias instead of hardcoded id.
Added mapper for TaskType.
This commit is contained in:
39
src/Umbraco.Core/Persistence/Mappers/TaskTypeMapper.cs
Normal file
39
src/Umbraco.Core/Persistence/Mappers/TaskTypeMapper.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="TaskType"/> to DTO mapper used to translate the properties of the public api
|
||||
/// implementation to that of the database's DTO as sql: [tableName].[columnName].
|
||||
/// </summary>
|
||||
//[MapperFor(typeof(ITaskType))]
|
||||
[MapperFor(typeof(TaskType))]
|
||||
public sealed class TaskTypeMapper : BaseMapper
|
||||
{
|
||||
private static readonly ConcurrentDictionary<string, DtoMapModel> PropertyInfoCacheInstance = new ConcurrentDictionary<string, DtoMapModel>();
|
||||
|
||||
//NOTE: its an internal class but the ctor must be public since we're using Activator.CreateInstance to create it
|
||||
// otherwise that would fail because there is no public constructor.
|
||||
public TaskTypeMapper()
|
||||
{
|
||||
BuildMap();
|
||||
}
|
||||
|
||||
#region Overrides of BaseMapper
|
||||
|
||||
internal override ConcurrentDictionary<string, DtoMapModel> PropertyInfoCache
|
||||
{
|
||||
get { return PropertyInfoCacheInstance; }
|
||||
}
|
||||
|
||||
internal override void BuildMap()
|
||||
{
|
||||
CacheMap<TaskType, TaskTypeDto>(src => src.Id, dto => dto.Id);
|
||||
CacheMap<TaskType, TaskTypeDto>(src => src.Alias, dto => dto.Alias);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -404,6 +404,7 @@
|
||||
<Compile Include="Persistence\Mappers\AccessMapper.cs" />
|
||||
<Compile Include="Persistence\Mappers\DomainMapper.cs" />
|
||||
<Compile Include="Persistence\Mappers\MigrationEntryMapper.cs" />
|
||||
<Compile Include="Persistence\Mappers\TaskTypeMapper.cs" />
|
||||
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenThreeTwo\EnsureMigrationsTableIdentityIsCorrect.cs" />
|
||||
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenThreeZero\AddExternalLoginsTable.cs" />
|
||||
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenThreeZero\AddForeignKeysForLanguageAndDictionaryTables.cs" />
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace umbraco.cms.businesslogic.translation
|
||||
bool IncludeSubpages, bool SendEmail)
|
||||
{
|
||||
// Get translation taskType for obsolete task constructor
|
||||
var taskType = ApplicationContext.Current.Services.TaskService.GetTaskTypeById(1);
|
||||
var taskType = ApplicationContext.Current.Services.TaskService.GetTaskTypeByAlias("toTranslate");
|
||||
|
||||
// Create pending task
|
||||
Task t = new Task(new Umbraco.Core.Models.Task(taskType));
|
||||
|
||||
Reference in New Issue
Block a user