private void InitializeCommands() { SaveCommand = new RelayCommand((data) => { if (Mode == DetailMode.Creating) { var id = GenericManager.Create(Entity.LogicalName, Values); var newData = GenericManager.Retrieve(Entity.LogicalName, id); Id = id; Values = newData.Values; Mode = DetailMode.Updating; BusinessEventManager.RaiseOnCreatedEntity(Entity, newData.Values); } else if (Mode == DetailMode.Updating) { GenericManager.Update(Entity.LogicalName, Id, Values); BusinessEventManager.RaiseOnUpdatedEntity(Entity, Id, Values); } }, (data) => { return(IsCompleted); }); DeleteCommand = new RelayCommand((data) => { var dialog = new OkCancelMessageBox("Confirm the delete? This operation cannot be undone", "Delete operation"); dialog.ShowDialog(); if (dialog.Response == OkCancelMessageBox.InputTextBoxResponse.OK) { GenericManager.Delete(Entity.LogicalName, Id); BusinessEventManager.RaiseOnDeletedEntity(Entity, Id); } }, (data) => { return(Mode == DetailMode.Updating); }); RegisterCommand(SaveCommand); RegisterCommand(DeleteCommand); }