IsActive and CanActivate, CanDeactivate

IsActive and CanActivate, CanDeactivate

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


DeHaynes posted on Tuesday, September 12, 2006

   I asked this before but I didn't get much of a response, so I will ask again to see if maybe everyone was on vacation.  :)

 

   I want to add some functionality to the base framework.  Specifically the ability to remove records from showing up without deleting them.  My thoughts are that I add a bit field to every table in my SQL 2005 datbase that is called IsActive.  Then I go modify all my stored procedures to take in a parameter to define which records to retrieve, Active only, Inactive only or both.  The default condition would be Active only.

   In addition I want to add authorization methods of CanActivate() and CanDeactivate.  So I can use the existing authorization system to control this.

   What I am looking for is has anyone else done anything like this?  If so, can you give me some direction on where to go?

 

Thanks you.

            Tim

   

Brian Criswell replied on Tuesday, September 12, 2006

 Hi Tim,

There is no need to modify CSLA to do what you are describing.  This can all be done through the existing framework by modifying your tables, stored procedures and objects.

In your application, should separate roles be able to activate vs. deactivate an object?

DeHaynes replied on Tuesday, September 12, 2006

Yes.  I want to allow users the ability to de-activate but only admin can re-activate and actually delete objects.

Brian Criswell replied on Tuesday, September 12, 2006

Then I would suggest using the built in permissions system with two permissions call CanActivate and CanDeactivate.  Have your methods call CanWriteProperty("CanActivate", true); to throw an exception if the UI tries to allow the user to do something they are not allowed to do.

For retrieving groups of objects, I would suggest overloading your factory methods.  ObjectList.GetObjectList() would get all objects and ObjectList.GetObjectList(bool active) would get only active or inactive ones.  This is only one way you could set up your factory methods to tell the stored procedure which objects you want; there are several other ways you could communicate that information from the UI, through your factory methods and on to your stored procedures.

DeHaynes replied on Tuesday, September 12, 2006

Thanks very much Brian

DeHaynes replied on Tuesday, September 12, 2006

   When you typed that up to me, I was halfway through modifying the framework.  So I went ahead and finished it.  It works, the only thing I have to do now is figure out some mechanism so that objects see Active Only, Inactive Only or All Records.

 

Copyright (c) Marimer LLC