> That is a good point about the ordering of roles. > That is definitely flaky. > > But I will still be left with the inline if statements. > > Can I somehow abstract them away from the method?
You could do it like: businessFunctions = CommonService.GetAll<BusinessFunction>( "Deleted", SecurityManager.CanPerformAction( Actions.GetAllBusinessFunctions, user)); or something like that, so you move the decision what to do to the actual routine who performs the action. You can also move the security check to GetAll, but I think that's abit shaky, as the service is a resource you're using in a different context C which has the security rules of C, but another context C' has perhaps different rules. FB > > > > > Date: Wed, 21 Nov 2007 09:49:15 +0100> From: [EMAIL PROTECTED]> Subject: > Re: [ADVANCED-DOTNET] Code review> To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM> > > > I am writing an ASP.NET application that is heavily influenced by users and> > > roles. I am findin > g my code becoming increasing cluttered with the> following> > type of thing:> > > IList<BusinessFunction> businessFunctions;> > if > (CurrentUser.RoleIsAbove(Role.BusinessUnitAdmin))> > {> > if > (CurrentUser.IsSystemAdmin)> > businessFunctions => CommonServ > ice.GetAll<BusinessFunction>("Deleted");> > else> > businessFunctions => > CommonService.GetAll<BusinessFunction>("Deleted",> > false);> > }> > The > things I am unhappy about seeing is, CurrentUser.RoleIsAbove etc.> > It is > making the code messy.> > I woul > d like a way of somehow abstracting this security outside of the> > method.Can > anyone think how I could raise the abstraction level somehow.> > I could use > custom attributes perhaps but I have 2 if staements checking> user> > roles.> > > Can this be tidie > d up?> > > _________________________________________________________________ > Celeb spotting - Play CelebMashup and win cool prizes > https://www.celebmashup.com > =================================== > This list is hosted by DevelopMentorR http://www.develop.com > > View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com