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 under FeatureServicesPrismModule-project
  • Create asp\AdminRoles\ViewModels-subfolder under FeatureServicesPrismModule-project
  • Right click asp\AdminRoles\UserControls-folder
  • Open FeatureScripts Wizard

DB structure

  • On the first page click "Next"-button

DB structure

  • On the second page
    • select aspnetchckdbcontext-DBcontext
    • click Next-button

DB structure

  • On the third page
    • click Add-button
    • Feature-dialog will be shown

DB structure

  • 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

DB structure

  • You are On the third page again
    • click Next-button

DB structure

  • On the fourth page
    • Select "30100-FtrUserControl.xaml.cs"
    • Click Next-button

DB structure

  • On the fifth page
    • Select "FtrUserControl.xaml.cs.t4"
    • Click "Next"-button

DB structure

  • On the sixth page
    • Click "Save"-button
    • Click "Next"-button

DB structure

  • You are On the third page again
    • click Next-button

DB structure

  • On the fourth page
    • Select "30102-FtrUserControl.xaml"
    • Click Next-button

DB structure

  • On the fifth page
    • Select "FtrUserControl.xaml.t4"
    • Click "Next"-button

DB structure

  • On the sixth page
    • Click "Save"-button
    • close the dialog

DB structure

  • Right click asp\AdminRoles\ViewModels-folder
  • Open FeatureScripts Wizard

DB structure

  • On the first page click "Next"-button

DB structure

  • On the third page
    • select "AdminRoles"
    • click Next-button

DB structure

  • On the fourth page
    • Select "30104-FtrViewModel.cs"
    • Click Next-button

DB structure

  • On the fifth page
    • Select "FtrViewModel.cs.t4"
    • Click "Next"-button

DB structure

  • On the sixth page
    • Click "Save"-button
    • Close the dialog

DB structure

open "AdminRolesFtrViewModel.cs"-file and follow the instructions

DB structure

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 under FeatureServicesPrismModule-project
  • Create asp\AdminUsers\ViewModels-subfolder under FeatureServicesPrismModule-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)

DB structure

open "AdminUsersFtrViewModel.cs"-file and follow the instructions

DB structure

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

DB structure