Guides/MVC-Integration/Phase-II-Draft.md
... ...
@@ -311,4 +311,36 @@ namespace Sample_MVCApp.Controllers {
311 311
```
312 312
### Step 7. Add user role model
313 313
314
-
... ...
\ No newline at end of file
0
+Add
1
+
2
+
3
+```csharp
4
+//Sample User Role Model
5
+ //Namespace Izenda.Adhoc is needed
6
+
7
+ AdHocSettings.CurrentUserName = (string)user.Username;
8
+
9
+ if (!AdHocSettings.CurrentUserIsAdmin) {
10
+ //Sam is an administrator in the system and has full access to everything
11
+ AdHocSettings.SharedWithValues = new string[] { "Bob", "Sales", "Alice", "Marketing", "Sam", "Mallory" }; //Sam can freely choose who to share with based on department or username
12
+ }
13
+ else {
14
+ if (AdHocSettings.CurrentUserName == "Bob") {
15
+ AdHocSettings.CurrentUserRoles = new string[] { "Sales" };
16
+ AdHocSettings.SharedWithValues = new string[] { "Bob", "Sales", "Alice", "Marketing", "Sam", "PR" }; //Bob can share reports with anyone but Mallory but cannot view reports that are not shared with "Bob" or "Sales"
17
+ }
18
+ else if (AdHocSettings.CurrentUserName == "Alice") {
19
+ AdHocSettings.CurrentUserRoles = new string[] { "Sales", "Marketing" };
20
+ AdHocSettings.SharedWithValues = new string[] { "Sales", "Alice", "Marketing", "Sam" }; //Alice cannot share reports with Bob or Mallory specifically but Bob can still view reports created by Alice if they are shared with "Sales" and Mallory can view reports shared by Alice if they are shared with "Marketing"
21
+ }
22
+ else if (AdHocSettings.CurrentUserName == "Mallory") {
23
+ AdHocSettings.CurrentUserRoles = new string[] { "PR" };
24
+ AdHocSettings.SharedWithValues = new string[] { "Sales", "Marketing", "Mallory", "Sam", "Visitor" }; //Mallory can share reports with the Visitor role.
25
+ }
26
+ else {
27
+ AdHocSettings.CurrentUserRoles = new string[] { "Visitor" }; //visitors cannot share with anyone but can see reports shared with the "Visitor" role
28
+ }
29
+ }
30
+
31
+
32
+```
... ...
\ No newline at end of file