Skip to content

Commit 7fdef97

Browse files
committed
✨ Implement permissions management with repositories, controllers and migrations
1 parent ca9f583 commit 7fdef97

55 files changed

Lines changed: 2795 additions & 156 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
namespace TaleEngine.API.Contracts.Dtos
2+
{
3+
/// <summary>
4+
/// Assigned Permission Dto
5+
/// </summary>
6+
public class AssignedPermissionDto
7+
{
8+
/// <summary>
9+
/// Gets or sets the identifier.
10+
/// </summary>
11+
/// <value>
12+
/// The identifier.
13+
/// </value>
14+
public int Id { get; set; }
15+
16+
/// <summary>
17+
/// Gets or sets the role identifier.
18+
/// </summary>
19+
/// <value>
20+
/// The role identifier.
21+
/// </value>
22+
public int RoleId { get; set; }
23+
24+
/// <summary>
25+
/// Gets or sets the permission identifier.
26+
/// </summary>
27+
/// <value>
28+
/// The permission identifier.
29+
/// </value>
30+
public int PermissionId { get; set; }
31+
32+
/// <summary>
33+
/// Gets or sets the permission value identifier.
34+
/// </summary>
35+
/// <value>
36+
/// The permission value identifier.
37+
/// </value>
38+
public int PermissionValueId { get; set; }
39+
40+
/// <summary>
41+
/// Gets or sets the permission.
42+
/// </summary>
43+
/// <value>
44+
/// The permission.
45+
/// </value>
46+
public PermissionDto Permission { get; set; }
47+
48+
/// <summary>
49+
/// Gets or sets the permission value.
50+
/// </summary>
51+
/// <value>
52+
/// The permission value.
53+
/// </value>
54+
public PermissionValueDto PermissionValue { get; set; }
55+
}
56+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
namespace TaleEngine.API.Contracts.Dtos
2+
{
3+
/// <summary>
4+
/// Permission Dto
5+
/// </summary>
6+
public class PermissionDto
7+
{
8+
/// <summary>
9+
/// Gets or sets the identifier.
10+
/// </summary>
11+
/// <value>
12+
/// The identifier.
13+
/// </value>
14+
public int Id { get; set; }
15+
16+
/// <summary>
17+
/// Gets or sets the name.
18+
/// </summary>
19+
/// <value>
20+
/// The name.
21+
/// </value>
22+
public string Name { get; set; }
23+
24+
/// <summary>
25+
/// Gets or sets the abbreviation.
26+
/// </summary>
27+
/// <value>
28+
/// The abbreviation.
29+
/// </value>
30+
public string Abbr { get; set; }
31+
32+
/// <summary>
33+
/// Gets or sets the description.
34+
/// </summary>
35+
/// <value>
36+
/// The description.
37+
/// </value>
38+
public string Description { get; set; }
39+
}
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
namespace TaleEngine.API.Contracts.Dtos
2+
{
3+
/// <summary>
4+
/// Permission Value Dto
5+
/// </summary>
6+
public class PermissionValueDto
7+
{
8+
/// <summary>
9+
/// Gets or sets the identifier.
10+
/// </summary>
11+
/// <value>
12+
/// The identifier.
13+
/// </value>
14+
public int Id { get; set; }
15+
16+
/// <summary>
17+
/// Gets or sets the name.
18+
/// </summary>
19+
/// <value>
20+
/// The name.
21+
/// </value>
22+
public string Name { get; set; }
23+
24+
/// <summary>
25+
/// Gets or sets the abbreviation.
26+
/// </summary>
27+
/// <value>
28+
/// The abbreviation.
29+
/// </value>
30+
public string Abbr { get; set; }
31+
32+
/// <summary>
33+
/// Gets or sets the description.
34+
/// </summary>
35+
/// <value>
36+
/// The description.
37+
/// </value>
38+
public string Description { get; set; }
39+
}
40+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
namespace TaleEngine.API.Contracts.Dtos.Requests
2+
{
3+
/// <summary>
4+
/// Request to assign a permission to a role
5+
/// </summary>
6+
public class AssignPermissionRequest
7+
{
8+
/// <summary>
9+
/// Gets or sets the role identifier.
10+
/// </summary>
11+
/// <value>
12+
/// The role identifier.
13+
/// </value>
14+
public int RoleId { get; set; }
15+
16+
/// <summary>
17+
/// Gets or sets the permission identifier.
18+
/// </summary>
19+
/// <value>
20+
/// The permission identifier.
21+
/// </value>
22+
public int PermissionId { get; set; }
23+
24+
/// <summary>
25+
/// Gets or sets the permission value identifier.
26+
/// </summary>
27+
/// <value>
28+
/// The permission value identifier.
29+
/// </value>
30+
public int PermissionValueId { get; set; }
31+
}
32+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Collections.Generic;
2+
using TaleEngine.Data.Contracts.Entities;
3+
4+
namespace TaleEngine.Services.Contracts
5+
{
6+
public interface IAssignedPermissionService
7+
{
8+
AssignedPermissionEntity GetAssignedPermission(int id);
9+
List<AssignedPermissionEntity> GetAllAssignedPermissions();
10+
List<AssignedPermissionEntity> GetAssignedPermissionsByRole(int roleId);
11+
void AssignPermissionToRole(int roleId, int permissionId, int permissionValueId);
12+
void RemovePermissionFromRole(int roleId, int permissionId, int permissionValueId);
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Collections.Generic;
2+
using TaleEngine.Data.Contracts.Entities;
3+
4+
namespace TaleEngine.Services.Contracts
5+
{
6+
public interface IPermissionService
7+
{
8+
PermissionEntity GetPermission(int id);
9+
List<PermissionEntity> GetAllPermissions();
10+
void CreatePermission(PermissionEntity permission);
11+
void UpdatePermission(PermissionEntity permission);
12+
void DeletePermission(int id);
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Collections.Generic;
2+
using TaleEngine.Data.Contracts.Entities;
3+
4+
namespace TaleEngine.Services.Contracts
5+
{
6+
public interface IPermissionValueService
7+
{
8+
PermissionValueEntity GetPermissionValue(int id);
9+
List<PermissionValueEntity> GetAllPermissionValues();
10+
void CreatePermissionValue(PermissionValueEntity permissionValue);
11+
void UpdatePermissionValue(PermissionValueEntity permissionValue);
12+
void DeletePermissionValue(int id);
13+
}
14+
}

TaleEngine/TaleEngine.Application.Testing/Services/ActivityServiceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
using TaleEngine.Services;
1111
using Xunit;
1212

13-
namespace TaleEngine.DbServices.Testing.Services
13+
namespace TaleEngine.Services.Testing.Services
1414
{
1515
[ExcludeFromCodeCoverage]
1616
public class ActivityServiceTests

TaleEngine/TaleEngine.Application.Testing/Services/ActivityStatusServiceTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
using TaleEngine.Data.Contracts;
66
using TaleEngine.Data.Contracts.Entities;
77
using TaleEngine.Fakes.Entities;
8-
using TaleEngine.Services;
98
using Xunit;
109

11-
namespace TaleEngine.DbServices.Testing.Services
10+
namespace TaleEngine.Services.Testing.Services
1211
{
1312
[ExcludeFromCodeCoverage]
1413
public class ActivityStatusServiceTests

TaleEngine/TaleEngine.Application.Testing/Services/ActivityTypeServiceTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
using TaleEngine.Data.Contracts;
66
using TaleEngine.Data.Contracts.Entities;
77
using TaleEngine.Fakes.Entities;
8-
using TaleEngine.Services;
98
using Xunit;
109

11-
namespace TaleEngine.DbServices.Testing.Services
10+
namespace TaleEngine.Services.Testing.Services
1211
{
1312
[ExcludeFromCodeCoverage]
1413
public class ActivityTypeServiceTests

0 commit comments

Comments
 (0)