Skip to content

Commit df8592f

Browse files
Module Type added in Module and migrations updated
1 parent dc29fe7 commit df8592f

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

UserManagement.Contracts/Permissions/PermissionsDto.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace UserManagement.Contracts.DTO
99
public record LoginRequest(string UserName, string Password);
1010

1111
public record FunctionDto(int Id, string Code, string DisplayName);
12-
public record ModuleDto(int Id, string Name, string Area, string Controller, string Action, List<FunctionDto> Functions);
12+
public record ModuleDto(int Id, string Name, string Area, string Controller, string Action, string Type, List<FunctionDto> Functions);
1313
public record CategoryDto(int Id, string Name, List<ModuleDto> Modules);
1414
public record UserPermissionsDto(int UserId, string UserName, List<CategoryDto> Categories);
1515
}

UserManagementApi/Controllers/UsersController.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ on rf.FunctionId equals f.Id
113113
CategoryId = f.Module.Category.Id,
114114
CategoryName = f.Module.Category.Name,
115115
ModuleId = f.Module.Id,
116-
ModuleName = f.Module.Name,
116+
ModuleName = f.Module.Name,
117+
ModuleType = f.Module.Type,
117118
f.Module.Area,
118119
f.Module.Controller,
119120
f.Module.Action,
@@ -129,13 +130,14 @@ on rf.FunctionId equals f.Id
129130
.Select(cg => new CategoryDto(
130131
cg.Key.CategoryId,
131132
cg.Key.CategoryName,
132-
cg.GroupBy(t => new { t.ModuleId, t.ModuleName, t.Area, t.Controller, t.Action })
133+
cg.GroupBy(t => new { t.ModuleId, t.ModuleName, t.Area, t.Controller, t.Action, t.ModuleType})
133134
.Select(mg => new ModuleDto(
134135
mg.Key.ModuleId,
135136
mg.Key.ModuleName,
136137
mg.Key.Area,
137138
mg.Key.Controller,
138139
mg.Key.Action,
140+
mg.Key.ModuleType,
139141
mg.GroupBy(x => new { x.FunctionId, x.Code, x.DisplayName }) // distinct functions
140142
.Select(g => new FunctionDto(g.Key.FunctionId, g.Key.Code, g.Key.DisplayName))
141143
.OrderBy(f => f.Code)

UserManagementApi/Migrations/20251101102948_AddModuleTypeAndApiLogsSeed.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,19 @@ protected override void Up(MigrationBuilder migrationBuilder)
4343
-- Ensure Administration category exists
4444
SELECT @catId = Id FROM Categories WHERE Name = 'Administration';
4545
46-
-- Ensure ApiLogs module exists (Area='', Controller='api', Action='errorlogs')
46+
-- Ensure ApiLogs module exists (Area='', Controller='ErrorLogs', Action='GetAllErrors')
4747
IF NOT EXISTS (
4848
SELECT 1 FROM Modules
49-
WHERE Name = 'ApiLogs' AND Controller = 'api' AND Action = 'errorlogs'
49+
WHERE Name = 'ApiLogs' AND Controller = 'ErrorLogs' AND Action = 'GetAllErrors'
5050
)
5151
BEGIN
5252
INSERT INTO Modules ([Name],[Area],[Controller],[Action],[CategoryId],[Type])
53-
VALUES ('ApiLogs','', 'api','errorlogs', @catId, 'Api');
53+
VALUES ('ApiLogs','', 'ErrorLogs','GetAllErrors', @catId, 'Api');
5454
END
5555
5656
DECLARE @modId INT;
5757
SELECT @modId = Id FROM Modules
58-
WHERE Name='ApiLogs' AND Controller='api' AND Action='errorlogs';
58+
WHERE Name='ApiLogs' AND Controller='ErrorLogs' AND Action='GetAllErrors';
5959
6060
-- Ensure function Api.Logs.View exists
6161
IF NOT EXISTS (SELECT 1 FROM Functions WHERE [Code] = 'Api.Logs.View')
@@ -79,7 +79,7 @@ FROM Functions F
7979
migrationBuilder.Sql(@"
8080
DELETE M
8181
FROM Modules M
82-
WHERE M.[Name] = 'ApiLogs' AND M.[Controller] = 'api' AND M.[Action] = 'errorlogs';
82+
WHERE M.[Name] = 'ApiLogs' AND M.[Controller] = 'ErrorLogs' AND M.[Action] = 'GetAllErrors';
8383
");
8484

8585
// Drop the Type column

0 commit comments

Comments
 (0)