Merge with 6.0.0-LegacyApi-Refactor

This commit is contained in:
Sebastiaan Janssen
2012-12-28 08:45:40 -01:00
82 changed files with 1945 additions and 1777 deletions

View File

@@ -102,10 +102,10 @@ namespace Umbraco.Core.Models
if(Trashed)
return ContentStatus.Trashed;
if(ExpireDate.HasValue && DateTime.UtcNow > ExpireDate.Value)
if(ExpireDate.HasValue && ExpireDate.Value > DateTime.MinValue && DateTime.UtcNow > ExpireDate.Value)
return ContentStatus.Expired;
if(ReleaseDate.HasValue && ReleaseDate.Value > DateTime.UtcNow)
if(ReleaseDate.HasValue && ReleaseDate.Value > DateTime.MinValue && ReleaseDate.Value > DateTime.UtcNow)
return ContentStatus.AwaitingRelease;
if(Published)
@@ -156,11 +156,12 @@ namespace Umbraco.Core.Models
get { return _releaseDate; }
set
{
if(value.HasValue && value.Value > DateTime.UtcNow && Published)
//Thought this type of check would be clever, but it only seems to cause problems
/*if(value.HasValue && value.Value > DateTime.UtcNow && Published)
_published = false;
if (value.HasValue && value.Value < DateTime.UtcNow && !Published)
_published = true;
_published = true;*/
_releaseDate = value;
OnPropertyChanged(ReleaseDateSelector);
@@ -176,8 +177,9 @@ namespace Umbraco.Core.Models
get { return _expireDate; }
set
{
if(value.HasValue && DateTime.UtcNow > value.Value && Published)
_published = false;
//Thought this type of check would be clever, but it only seems to cause problems
/*if(value.HasValue && DateTime.UtcNow > value.Value && Published)
_published = false;*/
_expireDate = value;
OnPropertyChanged(ExpireDateSelector);
@@ -311,10 +313,10 @@ namespace Umbraco.Core.Models
public override bool IsPropertyDirty(string propertyName)
{
bool existsInEntity = base.IsPropertyDirty(propertyName);
if (existsInEntity)
return true;
bool anyDirtyProperties = Properties.Any(x => x.IsPropertyDirty(propertyName));
return existsInEntity || anyDirtyProperties;
return Properties.Any(x => x.IsPropertyDirty(propertyName));
}
/// <summary>

View File

@@ -12,6 +12,7 @@ using Umbraco.Core.IO;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.UnitOfWork;
using Umbraco.Core.Services;
namespace Umbraco.Core.Models
{
@@ -369,6 +370,18 @@ namespace Umbraco.Core.Models
}
}
/// <summary>
/// Checks whether an <see cref="IContent"/> item has any published versions
/// </summary>
/// <param name="content"></param>
/// <returns>True if the content has any published versiom otherwise False</returns>
public static bool HasPublishedVersion(this IContent content)
{
if (content.HasIdentity == false)
return false;
return ApplicationContext.Current.Services.ContentService.HasPublishedVersion(content.Id);
}
/// <summary>
/// Creates the xml representation for the <see cref="IContent"/> object

View File

@@ -7,7 +7,7 @@ using System.Runtime.Serialization;
namespace Umbraco.Core.Models
{
/// <summary>
/// Represents the contnet type that a <see cref="Content"/> object is based on
/// Represents the content type that a <see cref="Content"/> object is based on
/// </summary>
[Serializable]
[DataContract(IsReference = true)]
@@ -81,6 +81,24 @@ namespace Umbraco.Core.Models
}
}
/// <summary>
/// Removes a template from the list of allowed templates
/// </summary>
/// <param name="template"><see cref="ITemplate"/> to remove</param>
/// <returns>True if template was removed, otherwise False</returns>
public bool RemoveTemplate(ITemplate template)
{
if (DefaultTemplateId == template.Id)
DefaultTemplateId = default(int);
var templates = AllowedTemplates.ToList();
var remove = templates.FirstOrDefault(x => x.Id == template.Id);
var result = templates.Remove(remove);
AllowedTemplates = templates;
return result;
}
/// <summary>
/// Indicates whether a specific property on the current <see cref="IContent"/> entity is dirty.
/// </summary>

View File

@@ -149,7 +149,7 @@ namespace Umbraco.Core.Models
get { return _alias; }
set
{
_alias = value;
_alias = value.ToUmbracoAlias(StringAliasCaseType.CamelCase, true);
OnPropertyChanged(AliasSelector);
}
}

View File

@@ -1,5 +1,4 @@
using System;
using System.Runtime.Serialization;
namespace Umbraco.Core.Models
{

View File

@@ -22,5 +22,12 @@ namespace Umbraco.Core.Models
/// </summary>
/// <param name="template">Default <see cref="ITemplate"/></param>
void SetDefaultTemplate(ITemplate template);
/// <summary>
/// Removes a template from the list of allowed templates
/// </summary>
/// <param name="template"><see cref="ITemplate"/> to remove</param>
/// <returns>True if template was removed, otherwise False</returns>
bool RemoveTemplate(ITemplate template);
}
}

View File

@@ -75,7 +75,7 @@ namespace Umbraco.Core.Models.Rdbms
return Text;
}
return null;
return string.Empty;
}
}
}