2018-01-15 11:32:30 +01:00
|
|
|
|
using Umbraco.Core.Models.Entities;
|
2014-01-23 10:41:57 +11:00
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Core.Models
|
|
|
|
|
|
{
|
|
|
|
|
|
public static class EntityExtensions
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns true if this entity has just been created and persisted to the data store
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="entity"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// This is useful when handling events to determine if an entity is a brand new entity or was
|
|
|
|
|
|
/// already existing.
|
|
|
|
|
|
/// </remarks>
|
2018-01-15 11:32:30 +01:00
|
|
|
|
public static bool IsNewEntity(this IRememberBeingDirty entity)
|
2014-01-23 10:41:57 +11:00
|
|
|
|
{
|
2018-01-15 11:32:30 +01:00
|
|
|
|
return entity.WasPropertyDirty("Id");
|
2014-01-23 10:41:57 +11:00
|
|
|
|
}
|
2018-01-15 13:44:49 +01:00
|
|
|
|
|
|
|
|
|
|
// fixme - MOVE!
|
|
|
|
|
|
public static object GetAdditionalDataValueIgnoreCase(this IMember entity, string key, object defaultVal)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (entity.AdditionalData.ContainsKeyIgnoreCase(key) == false) return defaultVal;
|
|
|
|
|
|
return entity.AdditionalData.GetValueIgnoreCase(key, defaultVal);
|
|
|
|
|
|
}
|
2014-08-13 09:38:40 +02:00
|
|
|
|
}
|
2017-07-20 11:21:28 +02:00
|
|
|
|
}
|