Skip to main content

Save

C#
1
2
3
public void Save() { }
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Create the role. var newRole = project.Security.Roles.New("Blog authors", "Blog authors can create and update blog content"); // Assign the required permissions to be able to create and update a blog entry. newRole.Permissions.Entries.Add( new EntryPermission("blog", new List<string> { "contensisEntryBasic.sysCreate", "contensisEntryBasic.draft.sysUpdate" })); // Assign users to the role. newRole.Assignments.Users.Add("m.jackson"); newRole.Assignments.Users.Add("g.michael"); try { // Save the role to take effect. newRole.Save(); } catch(RestRequestException restEx) { // Handle service error. } catch(ValidationException valEx) { // Handle data validation errors. } catch(Exception ex) { // Handle anything else, e.g. network error. }

SaveAsync

C#
1
2
3
public async Task SaveAsync() { }
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Create the role. var newRole = project.Security.Roles.New("Blog authors", "Blog authors can create and update blog content"); // Assign the required permissions to be able to create and update a blog entry. newRole.Permissions.Entries.Add( new EntryPermission("blog", new List<string> { "contensisEntryBasic.sysCreate", "contensisEntryBasic.draft.sysUpdate" })); // Assign users to the role. newRole.Assignments.Users.Add("m.jackson"); newRole.Assignments.Users.Add("g.michael"); try { // Save the role to take effect. await newRole.SaveAsync(); } catch(RestRequestException restEx) { // Handle service error. } catch(ValidationException valEx) { // Handle data validation errors. } catch(Exception ex) { // Handle anything else, e.g. network error. }

Delete

C#
1
2
3
public void Delete() { }
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Get an existing role. var role = project.Security.Roles.Get("cffd4ac9-2710-44f2-9ca4-f02a3e114c2d"); try { // Delete the role. role.Delete(); } catch(RestRequestException restEx) { // Handle service error. } catch(Exception ex) { // Handle anything else, e.g. network error. }

DeleteAsync

C#
1
2
3
public Task DeleteAsync() { }
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Get an existing role. var role = await project.Security.Roles.GetAsync("cffd4ac9-2710-44f2-9ca4-f02a3e114c2d"); try { // Delete the role. await role.DeleteAsync(); } catch(RestRequestException restEx) { // Handle service error. } catch(Exception ex) { // Handle anything else, e.g. network error. }

Still need help?

New support request