Created
March 22, 2016 21:24
-
-
Save barryokane/2402e8e5ac3c1b875168 to your computer and use it in GitHub Desktop.
Umbraco package UI-O-Matic examples (https://our.umbraco.org/projects/developer-tools/ui-o-matic/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace OnePageImpactReport.Models | |
{ | |
[UIOMaticAttribute("ImpactOrganisations", "icon-users", "icon-user")] | |
[TableName("ImpactOrganisations")] | |
[PrimaryKey("Id", autoIncrement = true)] | |
[ExplicitColumns] | |
public class ImpactOrganisation : IUIOMaticModel | |
{ | |
[UIOMaticIgnoreField] | |
[Column("id")] | |
[PrimaryKeyColumn(AutoIncrement = true)] | |
public int Id { get; set; } | |
[Required] | |
[Column("OwnerMemberId")] | |
[UIOMaticField("Owner Member", "", View = "pickers.member")] | |
public int OwnerMemberId { get; set; } | |
[Column("OrganisationName")] | |
[Required] | |
public string Name { get; set; } | |
[Column("LogoUrl"), NullSetting(NullSetting = NullSettings.Null)] | |
public string LogoUrl { get; set; } | |
[Column("Summary"), NullSetting(NullSetting = NullSettings.Null)] | |
[AllowHtml] | |
[MaxLength(200)] | |
[UIOMaticField("Summary", "Appears on all reports", View = "textarea")] | |
public string Summary { get; set; } | |
[Column("Email"), NullSetting(NullSetting = NullSettings.Null)] | |
public string Email { get; set; } | |
[Column("Tel"), NullSetting(NullSetting = NullSettings.Null)] | |
public string Tel { get; set; } | |
[Column("Url"), NullSetting(NullSetting = NullSettings.Null)] | |
public string Url { get; set; } | |
[Column("Legal"), NullSetting(NullSetting = NullSettings.Null)] | |
[UIOMaticField("Legal", "Appears in report footer", View = "textarea")] | |
public string Legal { get; set; } | |
public IEnumerable<Exception> Validate() | |
{ | |
var exs = new List<Exception>(); | |
if (string.IsNullOrEmpty(Name)) | |
exs.Add(new Exception("Name is required")); | |
if (OwnerMemberId == 0) | |
exs.Add(new Exception("Owner Member is required")); | |
return exs; | |
} | |
public override string ToString() | |
{ | |
return Name + " (" + OwnerMemberId + ")"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment