internal static ItemResultsDTO Query(ItemQuery query, IHandleItemState stateManager) { var item = stateManager.GetItem(query.Id); if (item == null) { return(null); } return(new ItemResultsDTO { Results = new[] { new ItemDTO { Id = item.Id, Data = item.Data } } }); }
public static ItemDTO Execute(CreateItem ci, IHandleItemState stateManager) { // Example of validation if (string.IsNullOrWhiteSpace(ci.Data)) { return(null); } // Remember that the item returned does not have an Id. // We need to persist this to the store before we can get an Id var item = ItemCommandHandlers.CreateItem(ci.Data); var persistedItem = stateManager.InsertItem(new PersistedItem { Id = item.Id, Data = item.Data, ModifiedAt = item.ModifiedAt }); return(new ItemDTO { Id = persistedItem.Id, Data = persistedItem.Data }); }
public Application(IHandleItemState stateManager) =>