Fixed to use alias instead of hardcoded id.

Added mapper for TaskType.
This commit is contained in:
Claus
2015-11-11 12:02:12 +01:00
parent de6e7dd28d
commit 5d97a94dcb
3 changed files with 41 additions and 1 deletions

View 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
}
}

View File

@@ -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" />

View File

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