Refactors IDomain model, simplifies it so that it doesn't contain references, simplifies the domain repository to no longer require lookups of content and languages, updates all other code referencing IDomain and now if a language lookup is required it is made when appropriate.
This commit is contained in:
@@ -64,22 +64,23 @@ namespace umbraco.cms.businesslogic.web
|
||||
|
||||
public Language Language
|
||||
{
|
||||
get { return new Language(DomainEntity.Language); }
|
||||
set { DomainEntity.Language = value.LanguageEntity; }
|
||||
get
|
||||
{
|
||||
if (DomainEntity.LanguageId.HasValue == false) return null;
|
||||
var lang = ApplicationContext.Current.Services.LocalizationService.GetLanguageById(DomainEntity.LanguageId.Value);
|
||||
if (lang == null) throw new InvalidOperationException("No language exists with id " + DomainEntity.LanguageId.Value);
|
||||
return new Language(lang);
|
||||
}
|
||||
set
|
||||
{
|
||||
DomainEntity.LanguageId = value.LanguageEntity.Id;
|
||||
}
|
||||
}
|
||||
|
||||
public int RootNodeId
|
||||
{
|
||||
get { return DomainEntity.RootContent.Id; }
|
||||
set
|
||||
{
|
||||
var content = ApplicationContext.Current.Services.ContentService.GetById(value);
|
||||
if (content == null)
|
||||
{
|
||||
throw new NullReferenceException("No content found with id " + value);
|
||||
}
|
||||
DomainEntity.RootContent = content;
|
||||
}
|
||||
get { return DomainEntity.RootContentId ?? -1; }
|
||||
set { DomainEntity.RootContentId = value; }
|
||||
}
|
||||
|
||||
public int Id
|
||||
@@ -135,7 +136,7 @@ namespace umbraco.cms.businesslogic.web
|
||||
public static int GetRootFromDomain(string DomainName)
|
||||
{
|
||||
var found = ApplicationContext.Current.Services.DomainService.GetByName(DomainName);
|
||||
return found == null ? -1 : found.RootContent.Id;
|
||||
return found == null ? -1 : found.RootContentId ?? -1;
|
||||
}
|
||||
|
||||
public static Domain[] GetDomainsById(int nodeId)
|
||||
@@ -159,15 +160,10 @@ namespace umbraco.cms.businesslogic.web
|
||||
|
||||
public static void MakeNew(string DomainName, int RootNodeId, int LanguageId)
|
||||
{
|
||||
var content = ApplicationContext.Current.Services.ContentService.GetById(RootNodeId);
|
||||
if (content == null) throw new NullReferenceException("No content exists with id " + RootNodeId);
|
||||
var lang = ApplicationContext.Current.Services.LocalizationService.GetLanguageById(LanguageId);
|
||||
if (lang == null) throw new NullReferenceException("No language exists with id " + LanguageId);
|
||||
|
||||
var domain = new UmbracoDomain(DomainName)
|
||||
{
|
||||
RootContent = content,
|
||||
Language = lang
|
||||
RootContentId = RootNodeId,
|
||||
LanguageId = LanguageId
|
||||
};
|
||||
ApplicationContext.Current.Services.DomainService.Save(domain);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user