B3.01 Security: Authorization (AdminUsers and AdminRoles Features) (Wpf) - chempkovsky/CS2WPF-and-CS2XAMARIN GitHub Wiki
Instead of adding all security components into Navbar we define a pair of Features with security components as a child.
AdminRoles Feature
- Create
asp\AdminRoles\UserControls
-subfolder underFeatureServicesPrismModule
-project - Create
asp\AdminRoles\ViewModels
-subfolder underFeatureServicesPrismModule
-project - Right click
asp\AdminRoles\UserControls
-folder - Open FeatureScripts Wizard
- On the first page click "Next"-button
- On the second page
- select aspnetchckdbcontext-DBcontext
- click Next-button
- On the third page
- click Add-button
- Feature-dialog will be shown
- In Feature-dialog
- Type AdminUsers
- check
- aspnetdashboardView (01598-LformUserControl.xaml)
- aspnetmodelView (01598-LformUserControl.xaml)
- aspnetroleView (01598-LformUserControl.xaml)
- aspnetroleView (02122-O2mMaskUserControl.xaml)
- aspnetrolemaskView (01598-LformUserControl.xaml)
- click Save button
- You are On the third page again
- click Next-button
- On the fourth page
- Select "30100-FtrUserControl.xaml.cs"
- Click Next-button
- On the fifth page
- Select "FtrUserControl.xaml.cs.t4"
- Click "Next"-button
- On the sixth page
- Click "Save"-button
- Click "Next"-button
- You are On the third page again
- click Next-button
- On the fourth page
- Select "30102-FtrUserControl.xaml"
- Click Next-button
- On the fifth page
- Select "FtrUserControl.xaml.t4"
- Click "Next"-button
- On the sixth page
- Click "Save"-button
- close the dialog
- Right click
asp\AdminRoles\ViewModels
-folder - Open FeatureScripts Wizard
- On the first page click "Next"-button
- On the third page
- select "AdminRoles"
- click Next-button
- On the fourth page
- Select "30104-FtrViewModel.cs"
- Click Next-button
- On the fifth page
- Select "FtrViewModel.cs.t4"
- Click "Next"-button
- On the sixth page
- Click "Save"-button
- Close the dialog
open "AdminRolesFtrViewModel.cs"-file and follow the instructions
As a result, the following lines of code will be added to the body of "RegisterTypes"-method of "FeatureServicesPrismModuleModule.cs"-file
public void RegisterTypes(IContainerRegistry containerRegistry)
{
...
// According to requirements of the "AdminRolesFtrViewModel.cs"-file of "FeatureServicesPrismModule"-project.
containerRegistry.RegisterForNavigation<AdminRolesFtrUserControl, AdminRolesFtrViewModel>("AdminRolesFtrUserControl");
}
- Open "MainWindowViewModel.cs"-file and add one line to the definition of "_MainMenu"-var
IEnumerable<IWebServiceFilterMenuInterface> _MainMenu = new ObservableCollection<IWebServiceFilterMenuInterface>()
{
...
new WebServiceFilterMenuViewModel() { Id = "001", Caption = "AdminRoles Feature", IconName = "TableRefresh", IconColor = "Primary", Data = "AdminRolesFtrUserControl", Command = RoutedCommandExt.MainMenuCommand},
}
- run Dm04WebApp-app
- run PrismDemoApp-app
- click "AdminRoles Feature"-navigation menu
- here is a result
AdminUsers Feature
- Create
asp\AdminUsers\UserControls
-subfolder underFeatureServicesPrismModule
-project - Create
asp\AdminUsers\ViewModels
-subfolder underFeatureServicesPrismModule
-project - Repeat the steps described above to create AdminUsers Feature
- Include in the list of the AdminUsers Feature:
- aspnetroleView (01598-LformUserControl.xaml)
- aspnetuserView (01598-LformUserControl.xaml)
- aspnetuserView (02122-O2mMaskUserControl.xaml)
- aspnetuserView (01698-O2mUserControl.xaml)
- aspnetuserrolesView (01598-LformUserControl.xaml)
open "AdminUsersFtrViewModel.cs"-file and follow the instructions
As a result, the following lines of code will be added to the body of "RegisterTypes"-method of "FeatureServicesPrismModuleModule.cs"-file
public void RegisterTypes(IContainerRegistry containerRegistry)
{
...
// According to requirements of the "AdminUsersFtrViewModel.cs"-file of "FeatureServicesPrismModule"-project.
containerRegistry.RegisterForNavigation<AdminUsersFtrUserControl, AdminUsersFtrViewModel>("AdminUsersFtrUserControl");
}
- Open "MainWindowViewModel.cs"-file and add one line to the definition of "_MainMenu"-var
IEnumerable<IWebServiceFilterMenuInterface> _MainMenu = new ObservableCollection<IWebServiceFilterMenuInterface>()
{
...
new WebServiceFilterMenuViewModel() { Id = "001", Caption = "AdminUsers Feature", IconName = "TableRefresh", IconColor = "Primary", Data = "AdminUsersFtrUserControl", Command = RoutedCommandExt.MainMenuCommand},
}
- run Dm04WebApp-app
- run PrismDemoApp-app
- click "AdminUsers Feature"-navigation menu
- here is a result