asp.net - Action requires multiple controllers to execute -


i have usercontroller has destroy function. rather complex function because demands destroy user's data. have action, admin panel deletes data specific set of users.

since don't want replicate code usercontroller, call destroy function usercontroller each user destroy data.

how should proceed?

thanks in advance.

why not move functionality common class method can accessed both controllers needed ?

public class usermanager {   public void destroy(list<int> useridstodestroy)   {     foreach(var userid in useridstodestroy)     {        //execute code destroy     }   } } 

and action methods, can call like

var mgr = new usermanager(); var badusers  = new list<int> { 1,2,3}; mgr.destroy(badusers); 

update badusers variable value needed based on calling it.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -