Archive for December, 2015

UI-O-Matic Event Model 8

The most recent version of UI-O-Matic (1.4.0 at this moment) introduces a couple of events that allow you to do some interesting stuff. The events are all placed on the PetaPocoObjectController (that’s the controller responsable for handling the crud operations).

Following the Umbraco convention there are before and after events.

BuildingQuery and BuildedQuery

These execute when UI-O-Matic builds the sql query for fetching the list view data. By default UI-O-Matic will fetch all the data from the table but using these events you can limit that by still having control over the query before it is executed.

CreatingObject and CreatedObject

These will execute when UI-O-Matic is inserting an object, so you can use these events to set values.

UpdatingObject and UpdatedObject

These will execute when UI-O-Matic is updating an object


1 public class EventHandlerscs: ApplicationEventHandler 2 { 3 protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) 4 { 5 UIOMatic.Controllers.PetaPocoObjectController.CreatingObject += PetaPocoObjectController_CreatingObject; 6 UIOMatic.Controllers.PetaPocoObjectController.BuildingQuery += PetaPocoObjectController_BuildingQuery; 7 } 8 9 void PetaPocoObjectController_CreatingObject(object sender, UIOMatic.ObjectEventArgs e) 10 { 11 if (e.Object.GetType() == typeof (ccpEvent)) 12 { 13 ccpEvent ob = (ccpEvent) e.Object; 14 ob.IsApproved = true; 15 } 16 } 17 18 void PetaPocoObjectController_BuildingQuery(object sender, UIOMatic.QueryEventArgs e) 19 { 20 if (e.TableName == ccpEvent) 21 e.Query.Where(AREAID = @0, 2); 22 } 23 }

UI-O-Matic 1.1.0 Release 0

Today UI-O-Matoc 1.1.0 is available (get it from nuget), it features 2 new improvements coming from community pull requests! So thanks Tom Fulton and Serena Benny.

Introducing the UIOMaticNameField attribute

With this new attribute you can mark a single property that will be used as the ‘name’ field of your object, in the UI it will now appear at the top (so making it even more consistent with the Umbraco UI).

And if you are using a list view this name property will be the column that will link through to the detail page

Not limited to primary key columns of type int

With this version it’s also possible to have unique identifiers as the type on your primary key columns so now it should be able to handle almost every table

Haven’t given it a go yet? You should since it’s a huge time saver! For full details check out