Added methods HasProperty and HasValue

Added methods to the `Fieldset` object for checking if a property exists and/or if it has a value.
This commit is contained in:
leekelleher
2014-03-17 15:04:52 +00:00
parent 4879230303
commit 504a3b5c04
@@ -35,6 +35,20 @@ namespace Archetype.Umbraco.Models
return property.GetValue<T>();
}
public bool HasProperty(string propertyAlias)
{
return GetProperty(propertyAlias) != null;
}
public bool HasValue(string propertyAlias)
{
var property = GetProperty(propertyAlias);
if (property == null)
return false;
return !string.IsNullOrEmpty(property.Value.ToString());
}
private Property GetProperty(string propertyAlias)
{
return Properties.FirstOrDefault(p => p.Alias.InvariantEquals(propertyAlias));