Sunday 15 April 2018

Smart asp.net mvc wizard part 2

Smart asp.net mvc wizard part 2

Object Model

Click here to see online asp.net mvc wizard demo



Check Part 1 for smart asp.net mvc wizard to understand this article.
In this article i will explain each class in wizard object model with source code and properties for each class.



BaseWizard : Abstract class for any wizard contains list of navigation commands and collection of steps and list of bookmarks.




WizardStep: represent a step in the wizard where each step has Id , title , dictionary to store extra data and IsCompleted to check if the step is completed or not.



WizardStepCollection: KeyedCollection of steps where each wizard has collection of steps , we used KeyedCollection because checking the key already don for you (Each step must has unique id , otherwise you will receive an exception) for more info about KeyedCollection check click here


Bookmark : Represent the bookmark for the wizard where each bookmark has state (Active, Disabled, In Active) , id , text , GoTo Method where user will be taken when clicked and the step that related to the bookmark.


BookmarkState: enum represent the state for for bookmark .




NavigationCommand: Represent the bottom command for next , previous , skip and finish ... in the wizard where each command has set of properties like : (Id , text , visible , OnExecute() , Enabled).
for examples: when user in the fist step the Previous command will be invisible, when user in last step the Finish command will be visible and next command will be invisible.



WizardNavigator: is the driver for for the wizard  when you click on any command or any bookmark the navigator will chick that you can move forward or backward based on the Boolean value of  of the step (completed or not completed) and will update the activestepindex accordingly. for example when wizard first time loaded it will check if  the there is any saved wizard state in database.

for example when you click on next command the navigator will check if current step is completed if yes then you will be taken to next step and active step index will be updated to the new step index and wizard state will be saved as JSON file in database.

when wizard first time loaded it will check if there is a JSON file in database and infer the wizard steps and move user automatically to last active step index (Check the demo and see the JSON data).



WizardState: contains  last ActiveStepId and the collection of steps for wizard , the main benefits of this class to store the wizard state in database and keep track of the active step for the user.
each time user click on navigation command or bookmark the navigator will save wizard state as JSON file in database like below sample:
 
   "WizardSteps": 
       
         "Id":"1",
         "Title":"Step 1",
         "IsCompleted":true
      },
       
         "Id":"2",
         "Title":"Step 2",
         "IsCompleted":true
      },
       
         "Id":"3",
         "Title":"Step 3",
         "IsCompleted":true
      },
       
         "Id":"4",
         "Title":"Step 4",
         "IsCompleted":true
      },
       
         "Id":"5",
         "Title":"Step 5",
         "IsCompleted":false
      }
   ],
   "ActiveStepId":"5"
}



IWizardNavigatorService : the interface for the any service that want store the WizardState, it will load , clear and save the wizard state in any data store .... later on the this series of articles i will store the wizard state in MS SQL database.
you can implement the service to store the service in any data store (Flat file , Oracle ...) 






















No comments:

Post a Comment