V10: fix build warnings infrastructure (#12369)
* Run code cleanup * Run dotnet format * Start manual fixes * Manual fixing of warnings * Fix nullability in columnalias * Fix tests * Fix up after merge * Start updating after review * Update editorconfig to contain new static & const rules * Fix up editorconfig to not contain duplicate rules * Fix up static member names * Fix up according to review * Update src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.DistributedCache.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.Repositories.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.Repositories.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Examine/ContentIndexPopulator.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Examine/ContentIndexPopulator.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Examine/ContentValueSetValidator.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Examine/ContentValueSetValidator.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Examine/ContentValueSetValidator.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Examine/ExamineUmbracoIndexingHandler.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Examine/PublishedContentIndexPopulator.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Extensions/InstanceIdentifiableExtensions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/HostedServices/RecurringHostedServiceBase.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/HostedServices/ReportSiteTask.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Logging/Serilog/LoggerConfigExtensions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Logging/Serilog/LoggerConfigExtensions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Macros/MacroTagParser.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Macros/MacroTagParser.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Macros/MacroTagParser.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Migrations/Expressions/Alter/Table/IAlterTableColumnOptionBuilder.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Migrations/Upgrade/V_10_0_0/AddMemberPropertiesAsColumns.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/ModelsBuilder/Building/TextBuilder.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/ModelsBuilder/Building/TextBuilder.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/ModelsBuilder/Building/TextBuilder.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/ModelsBuilder/Building/TextBuilder.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/ModelsBuilder/Building/TextBuilder.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/ModelsBuilder/Building/TextBuilder.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/ModelsBuilder/Building/TextBuilder.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Persistence/Dtos/ExternalLoginDto.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Persistence/Mappers/AccessMapper.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Persistence/Mappers/AuditEntryMapper.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Persistence/Mappers/MediaMapper.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Persistence/Mappers/MemberMapper.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Persistence/Mappers/PropertyGroupMapper.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Persistence/Mappers/PropertyGroupMapper.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Persistence/Mappers/PropertyTypeMapper.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Persistence/Mappers/PropertyTypeMapper.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Persistence/Mappers/RelationTypeMapper.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Persistence/Mappers/RelationTypeMapper.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Persistence/NPocoMapperCollectionBuilder.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Persistence/Querying/ExpressionVisitorBase.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ExternalLoginRepository.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Fix [..] to substring * Fix after merge with 10/dev * Fox ContentValueSetValidator.cs * Update LoggerConfigExtensions Co-authored-by: Nikolaj Geisle <niko737@edu.ucl.dk> Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NPoco;
|
||||
using Umbraco.Cms.Core;
|
||||
@@ -9,199 +6,218 @@ using Umbraco.Cms.Core.Cache;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Persistence.Querying;
|
||||
using Umbraco.Cms.Core.Persistence.Repositories;
|
||||
using Umbraco.Cms.Core.Scoping;
|
||||
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
|
||||
using Umbraco.Cms.Infrastructure.Scoping;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
|
||||
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement;
|
||||
|
||||
// TODO: We need to get a readonly ISO code for the domain assigned
|
||||
internal class DomainRepository : EntityRepositoryBase<int, IDomain>, IDomainRepository
|
||||
{
|
||||
// TODO: We need to get a readonly ISO code for the domain assigned
|
||||
|
||||
internal class DomainRepository : EntityRepositoryBase<int, IDomain>, IDomainRepository
|
||||
public DomainRepository(IScopeAccessor scopeAccessor, AppCaches cache, ILogger<DomainRepository> logger)
|
||||
: base(scopeAccessor, cache, logger)
|
||||
{
|
||||
public DomainRepository(IScopeAccessor scopeAccessor, AppCaches cache, ILogger<DomainRepository> logger)
|
||||
: base(scopeAccessor, cache, logger)
|
||||
{ }
|
||||
}
|
||||
|
||||
protected override IRepositoryCachePolicy<IDomain, int> CreateCachePolicy()
|
||||
public IDomain? GetByName(string domainName) =>
|
||||
GetMany().FirstOrDefault(x => x.DomainName.InvariantEquals(domainName));
|
||||
|
||||
public bool Exists(string domainName) => GetMany().Any(x => x.DomainName.InvariantEquals(domainName));
|
||||
|
||||
public IEnumerable<IDomain> GetAll(bool includeWildcards) =>
|
||||
GetMany().Where(x => includeWildcards || x.IsWildcard == false);
|
||||
|
||||
public IEnumerable<IDomain> GetAssignedDomains(int contentId, bool includeWildcards) =>
|
||||
GetMany()
|
||||
.Where(x => x.RootContentId == contentId)
|
||||
.Where(x => includeWildcards || x.IsWildcard == false);
|
||||
|
||||
protected override IRepositoryCachePolicy<IDomain, int> CreateCachePolicy() =>
|
||||
new FullDataSetRepositoryCachePolicy<IDomain, int>(GlobalIsolatedCache, ScopeAccessor, GetEntityId, /*expires:*/
|
||||
false);
|
||||
|
||||
protected override IDomain? PerformGet(int id) =>
|
||||
|
||||
// use the underlying GetAll which will force cache all domains
|
||||
GetMany().FirstOrDefault(x => x.Id == id);
|
||||
|
||||
protected override IEnumerable<IDomain> PerformGetAll(params int[]? ids)
|
||||
{
|
||||
Sql<ISqlContext> sql = GetBaseQuery(false).Where<DomainDto>(x => x.Id > 0);
|
||||
if (ids?.Any() ?? false)
|
||||
{
|
||||
return new FullDataSetRepositoryCachePolicy<IDomain, int>(GlobalIsolatedCache, ScopeAccessor, GetEntityId, /*expires:*/ false);
|
||||
sql.WhereIn<DomainDto>(x => x.Id, ids);
|
||||
}
|
||||
|
||||
protected override IDomain? PerformGet(int id)
|
||||
return Database.Fetch<DomainDto>(sql).Select(ConvertFromDto);
|
||||
}
|
||||
|
||||
protected override IEnumerable<IDomain> PerformGetByQuery(IQuery<IDomain> query) =>
|
||||
throw new NotSupportedException("This repository does not support this method");
|
||||
|
||||
protected override Sql<ISqlContext> GetBaseQuery(bool isCount)
|
||||
{
|
||||
Sql<ISqlContext> sql = Sql();
|
||||
if (isCount)
|
||||
{
|
||||
//use the underlying GetAll which will force cache all domains
|
||||
return GetMany()?.FirstOrDefault(x => x.Id == id);
|
||||
sql.SelectCount().From<DomainDto>();
|
||||
}
|
||||
else
|
||||
{
|
||||
sql.Select("umbracoDomain.*, umbracoLanguage.languageISOCode")
|
||||
.From<DomainDto>()
|
||||
.LeftJoin<LanguageDto>()
|
||||
.On<DomainDto, LanguageDto>(dto => dto.DefaultLanguage, dto => dto.Id);
|
||||
}
|
||||
|
||||
protected override IEnumerable<IDomain> PerformGetAll(params int[]? ids)
|
||||
return sql;
|
||||
}
|
||||
|
||||
protected override string GetBaseWhereClause() => $"{Constants.DatabaseSchema.Tables.Domain}.id = @id";
|
||||
|
||||
protected override IEnumerable<string> GetDeleteClauses()
|
||||
{
|
||||
var list = new List<string> { "DELETE FROM umbracoDomain WHERE id = @id" };
|
||||
return list;
|
||||
}
|
||||
|
||||
protected override void PersistNewItem(IDomain entity)
|
||||
{
|
||||
var exists = Database.ExecuteScalar<int>(
|
||||
"SELECT COUNT(*) FROM umbracoDomain WHERE domainName = @domainName",
|
||||
new { domainName = entity.DomainName });
|
||||
if (exists > 0)
|
||||
{
|
||||
var sql = GetBaseQuery(false).Where<DomainDto>(x => x.Id > 0);
|
||||
if (ids?.Any() ?? false)
|
||||
throw new DuplicateNameException(
|
||||
string.Format("The domain name {0} is already assigned", entity.DomainName));
|
||||
}
|
||||
|
||||
if (entity.RootContentId.HasValue)
|
||||
{
|
||||
var contentExists = Database.ExecuteScalar<int>(
|
||||
$"SELECT COUNT(*) FROM {Constants.DatabaseSchema.Tables.Content} WHERE nodeId = @id",
|
||||
new { id = entity.RootContentId.Value });
|
||||
if (contentExists == 0)
|
||||
{
|
||||
sql.WhereIn<DomainDto>(x => x.Id, ids);
|
||||
throw new NullReferenceException("No content exists with id " + entity.RootContentId.Value);
|
||||
}
|
||||
|
||||
return Database.Fetch<DomainDto>(sql).Select(ConvertFromDto);
|
||||
}
|
||||
|
||||
protected override IEnumerable<IDomain> PerformGetByQuery(IQuery<IDomain> query)
|
||||
if (entity.LanguageId.HasValue)
|
||||
{
|
||||
throw new NotSupportedException("This repository does not support this method");
|
||||
}
|
||||
|
||||
protected override Sql<ISqlContext> GetBaseQuery(bool isCount)
|
||||
{
|
||||
var sql = Sql();
|
||||
if (isCount)
|
||||
var languageExists = Database.ExecuteScalar<int>(
|
||||
"SELECT COUNT(*) FROM umbracoLanguage WHERE id = @id",
|
||||
new { id = entity.LanguageId.Value });
|
||||
if (languageExists == 0)
|
||||
{
|
||||
sql.SelectCount().From<DomainDto>();
|
||||
throw new NullReferenceException("No language exists with id " + entity.LanguageId.Value);
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
entity.AddingEntity();
|
||||
|
||||
var factory = new DomainModelFactory();
|
||||
DomainDto dto = factory.BuildDto(entity);
|
||||
|
||||
var id = Convert.ToInt32(Database.Insert(dto));
|
||||
entity.Id = id;
|
||||
|
||||
// if the language changed, we need to resolve the ISO code!
|
||||
if (entity.LanguageId.HasValue)
|
||||
{
|
||||
((UmbracoDomain)entity).LanguageIsoCode = Database.ExecuteScalar<string>(
|
||||
"SELECT languageISOCode FROM umbracoLanguage WHERE id=@langId", new { langId = entity.LanguageId });
|
||||
}
|
||||
|
||||
entity.ResetDirtyProperties();
|
||||
}
|
||||
|
||||
protected override void PersistUpdatedItem(IDomain entity)
|
||||
{
|
||||
entity.UpdatingEntity();
|
||||
|
||||
var exists = Database.ExecuteScalar<int>(
|
||||
"SELECT COUNT(*) FROM umbracoDomain WHERE domainName = @domainName AND umbracoDomain.id <> @id",
|
||||
new { domainName = entity.DomainName, id = entity.Id });
|
||||
|
||||
// ensure there is no other domain with the same name on another entity
|
||||
if (exists > 0)
|
||||
{
|
||||
throw new DuplicateNameException(
|
||||
string.Format("The domain name {0} is already assigned", entity.DomainName));
|
||||
}
|
||||
|
||||
if (entity.RootContentId.HasValue)
|
||||
{
|
||||
var contentExists = Database.ExecuteScalar<int>(
|
||||
$"SELECT COUNT(*) FROM {Constants.DatabaseSchema.Tables.Content} WHERE nodeId = @id",
|
||||
new { id = entity.RootContentId.Value });
|
||||
if (contentExists == 0)
|
||||
{
|
||||
sql.Select("umbracoDomain.*, umbracoLanguage.languageISOCode")
|
||||
.From<DomainDto>()
|
||||
.LeftJoin<LanguageDto>()
|
||||
.On<DomainDto, LanguageDto>(dto => dto.DefaultLanguage, dto => dto.Id);
|
||||
throw new NullReferenceException("No content exists with id " + entity.RootContentId.Value);
|
||||
}
|
||||
|
||||
return sql;
|
||||
}
|
||||
|
||||
protected override string GetBaseWhereClause()
|
||||
if (entity.LanguageId.HasValue)
|
||||
{
|
||||
return $"{Constants.DatabaseSchema.Tables.Domain}.id = @id";
|
||||
}
|
||||
|
||||
protected override IEnumerable<string> GetDeleteClauses()
|
||||
{
|
||||
var list = new List<string>
|
||||
{
|
||||
"DELETE FROM umbracoDomain WHERE id = @id"
|
||||
};
|
||||
return list;
|
||||
}
|
||||
|
||||
protected override void PersistNewItem(IDomain entity)
|
||||
{
|
||||
var exists = Database.ExecuteScalar<int>("SELECT COUNT(*) FROM umbracoDomain WHERE domainName = @domainName", new { domainName = entity.DomainName });
|
||||
if (exists > 0) throw new DuplicateNameException(string.Format("The domain name {0} is already assigned", entity.DomainName));
|
||||
|
||||
if (entity.RootContentId.HasValue)
|
||||
var languageExists = Database.ExecuteScalar<int>(
|
||||
"SELECT COUNT(*) FROM umbracoLanguage WHERE id = @id",
|
||||
new { id = entity.LanguageId.Value });
|
||||
if (languageExists == 0)
|
||||
{
|
||||
var contentExists = Database.ExecuteScalar<int>($"SELECT COUNT(*) FROM {Cms.Core.Constants.DatabaseSchema.Tables.Content} WHERE nodeId = @id", new { id = entity.RootContentId.Value });
|
||||
if (contentExists == 0) throw new NullReferenceException("No content exists with id " + entity.RootContentId.Value);
|
||||
throw new NullReferenceException("No language exists with id " + entity.LanguageId.Value);
|
||||
}
|
||||
|
||||
if (entity.LanguageId.HasValue)
|
||||
{
|
||||
var languageExists = Database.ExecuteScalar<int>("SELECT COUNT(*) FROM umbracoLanguage WHERE id = @id", new { id = entity.LanguageId.Value });
|
||||
if (languageExists == 0) throw new NullReferenceException("No language exists with id " + entity.LanguageId.Value);
|
||||
}
|
||||
|
||||
entity.AddingEntity();
|
||||
|
||||
var factory = new DomainModelFactory();
|
||||
var dto = factory.BuildDto(entity);
|
||||
|
||||
var id = Convert.ToInt32(Database.Insert(dto));
|
||||
entity.Id = id;
|
||||
|
||||
//if the language changed, we need to resolve the ISO code!
|
||||
if (entity.LanguageId.HasValue)
|
||||
{
|
||||
((UmbracoDomain)entity).LanguageIsoCode = Database.ExecuteScalar<string>("SELECT languageISOCode FROM umbracoLanguage WHERE id=@langId", new { langId = entity.LanguageId });
|
||||
}
|
||||
|
||||
entity.ResetDirtyProperties();
|
||||
}
|
||||
|
||||
protected override void PersistUpdatedItem(IDomain entity)
|
||||
var factory = new DomainModelFactory();
|
||||
DomainDto dto = factory.BuildDto(entity);
|
||||
|
||||
Database.Update(dto);
|
||||
|
||||
// if the language changed, we need to resolve the ISO code!
|
||||
if (entity.WasPropertyDirty("LanguageId"))
|
||||
{
|
||||
entity.UpdatingEntity();
|
||||
((UmbracoDomain)entity).LanguageIsoCode = Database.ExecuteScalar<string>(
|
||||
"SELECT languageISOCode FROM umbracoLanguage WHERE id=@langId", new { langId = entity.LanguageId });
|
||||
}
|
||||
|
||||
var exists = Database.ExecuteScalar<int>("SELECT COUNT(*) FROM umbracoDomain WHERE domainName = @domainName AND umbracoDomain.id <> @id",
|
||||
new { domainName = entity.DomainName, id = entity.Id });
|
||||
//ensure there is no other domain with the same name on another entity
|
||||
if (exists > 0) throw new DuplicateNameException(string.Format("The domain name {0} is already assigned", entity.DomainName));
|
||||
entity.ResetDirtyProperties();
|
||||
}
|
||||
|
||||
if (entity.RootContentId.HasValue)
|
||||
private IDomain ConvertFromDto(DomainDto dto)
|
||||
{
|
||||
var factory = new DomainModelFactory();
|
||||
IDomain entity = factory.BuildEntity(dto);
|
||||
return entity;
|
||||
}
|
||||
|
||||
internal class DomainModelFactory
|
||||
{
|
||||
public IDomain BuildEntity(DomainDto dto)
|
||||
{
|
||||
var domain = new UmbracoDomain(dto.DomainName, dto.IsoCode)
|
||||
{
|
||||
var contentExists = Database.ExecuteScalar<int>($"SELECT COUNT(*) FROM {Cms.Core.Constants.DatabaseSchema.Tables.Content} WHERE nodeId = @id", new { id = entity.RootContentId.Value });
|
||||
if (contentExists == 0) throw new NullReferenceException("No content exists with id " + entity.RootContentId.Value);
|
||||
}
|
||||
Id = dto.Id,
|
||||
LanguageId = dto.DefaultLanguage,
|
||||
RootContentId = dto.RootStructureId,
|
||||
};
|
||||
|
||||
if (entity.LanguageId.HasValue)
|
||||
// reset dirty initial properties (U4-1946)
|
||||
domain.ResetDirtyProperties(false);
|
||||
return domain;
|
||||
}
|
||||
|
||||
public DomainDto BuildDto(IDomain entity)
|
||||
{
|
||||
var dto = new DomainDto
|
||||
{
|
||||
var languageExists = Database.ExecuteScalar<int>("SELECT COUNT(*) FROM umbracoLanguage WHERE id = @id", new { id = entity.LanguageId.Value });
|
||||
if (languageExists == 0) throw new NullReferenceException("No language exists with id " + entity.LanguageId.Value);
|
||||
}
|
||||
|
||||
var factory = new DomainModelFactory();
|
||||
var dto = factory.BuildDto(entity);
|
||||
|
||||
Database.Update(dto);
|
||||
|
||||
//if the language changed, we need to resolve the ISO code!
|
||||
if (entity.WasPropertyDirty("LanguageId"))
|
||||
{
|
||||
((UmbracoDomain)entity).LanguageIsoCode = Database.ExecuteScalar<string>("SELECT languageISOCode FROM umbracoLanguage WHERE id=@langId", new {langId = entity.LanguageId});
|
||||
}
|
||||
|
||||
entity.ResetDirtyProperties();
|
||||
}
|
||||
|
||||
public IDomain? GetByName(string domainName)
|
||||
{
|
||||
return GetMany()?.FirstOrDefault(x => x.DomainName.InvariantEquals(domainName));
|
||||
}
|
||||
|
||||
public bool Exists(string domainName)
|
||||
{
|
||||
return GetMany()?.Any(x => x.DomainName.InvariantEquals(domainName)) ?? false;
|
||||
}
|
||||
|
||||
public IEnumerable<IDomain> GetAll(bool includeWildcards)
|
||||
{
|
||||
return GetMany().Where(x => includeWildcards || x.IsWildcard == false);
|
||||
}
|
||||
|
||||
public IEnumerable<IDomain> GetAssignedDomains(int contentId, bool includeWildcards)
|
||||
{
|
||||
return GetMany()
|
||||
.Where(x => x.RootContentId == contentId)
|
||||
.Where(x => includeWildcards || x.IsWildcard == false);
|
||||
}
|
||||
|
||||
private IDomain ConvertFromDto(DomainDto dto)
|
||||
{
|
||||
var factory = new DomainModelFactory();
|
||||
var entity = factory.BuildEntity(dto);
|
||||
return entity;
|
||||
}
|
||||
|
||||
internal class DomainModelFactory
|
||||
{
|
||||
|
||||
public IDomain BuildEntity(DomainDto dto)
|
||||
{
|
||||
var domain = new UmbracoDomain(dto.DomainName, dto.IsoCode)
|
||||
{
|
||||
Id = dto.Id,
|
||||
LanguageId = dto.DefaultLanguage,
|
||||
RootContentId = dto.RootStructureId
|
||||
};
|
||||
// reset dirty initial properties (U4-1946)
|
||||
domain.ResetDirtyProperties(false);
|
||||
return domain;
|
||||
}
|
||||
|
||||
public DomainDto BuildDto(IDomain entity)
|
||||
{
|
||||
var dto = new DomainDto { DefaultLanguage = entity.LanguageId, DomainName = entity.DomainName, Id = entity.Id, RootStructureId = entity.RootContentId };
|
||||
return dto;
|
||||
}
|
||||
DefaultLanguage = entity.LanguageId,
|
||||
DomainName = entity.DomainName,
|
||||
Id = entity.Id,
|
||||
RootStructureId = entity.RootContentId,
|
||||
};
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user