How to Execute (Can Delete Command) CommandBase from VIEWMODEL SL client

How to Execute (Can Delete Command) CommandBase from VIEWMODEL SL client

Old forum URL: forums.lhotka.net/forums/t/9676.aspx


emadalsous posted on Monday, October 25, 2010

Hello all, iam using CSLA with SL application and MVVM pattern

How Can i Execute Command from my  viewmodel to check if i can delete

the object because the object has foreign key related to it

 

emadalsous replied on Monday, October 25, 2010

Hello , Sorry ihave got it all ihad  to do is calling method DataPorta.BeginExecute through factory method

in my business and here is what i did:

in my Business Object i add the following method :

 

 

 

 

 

public static void CanDeleteAccount( Guid id,EventHandler<DataPortalResult<CanBeDeletedCommand>> callback)

{var item = new DataPortal<CanBeDeletedCommand>();

item.ExecuteCompleted += callback;

item.BeginExecute(

 

new CanBeDeletedCommand(id,"",true));}

and in my viewmodel i did the following code

 

 

Account.CanDeleteObject(Selected.CurrentAccount.Id, (o, e) => {

 

 

bool ttt = e.Object.Canbedeleted;

});

i have just put the code may another person face the same issue thanks all

Copyright (c) Marimer LLC