Chnaged the name of view employee feature permission to view team members

This commit is contained in:
ashutosh.nehete 2025-06-30 16:58:28 +05:30
parent 5f9ca98284
commit a3de905159
7 changed files with 3477 additions and 14 deletions

View File

@ -538,8 +538,8 @@ namespace Marco.Pms.DataAccess.Data
new FeaturePermission { Id = new Guid("db4e40c5-2ba9-4b6d-b8a6-a16a250ff99c"), FeatureId = new Guid("9d4b5489-2079-40b9-bd77-6e1bf90bc19f"), IsEnabled = true, Name = "Approve Task", Description = "Grants a user the authority to officially confirm the completion or acceptance of a task, often signifying that it meets the required standards or criteria" },
new FeaturePermission { Id = new Guid("60611762-7f8a-4fb5-b53f-b1139918796b"), FeatureId = new Guid("81ab8a87-8ccd-4015-a917-0627cee6a100"), IsEnabled = true, Name = "View All Employee", Description = "Grants a user read-only access to details about the all individuals within the system. This typically includes names, contact information, roles, departments, and potentially other relevant employee data" },
new FeaturePermission { Id = new Guid("b82d2b7e-0d52-45f3-997b-c008ea460e7f"), FeatureId = new Guid("81ab8a87-8ccd-4015-a917-0627cee6a100"), IsEnabled = true, Name = "View Employee", Description = "Grants a user read-only access to details about the individuals within the system which are is assigned to same projects as user. This typically includes names, contact information, roles, departments, and potentially other relevant employee data" },
new FeaturePermission { Id = new Guid("60611762-7f8a-4fb5-b53f-b1139918796b"), FeatureId = new Guid("81ab8a87-8ccd-4015-a917-0627cee6a100"), IsEnabled = true, Name = "View All Employees", Description = "Grants a user read-only access to details about the all individuals within the system. This typically includes names, contact information, roles, departments, and potentially other relevant employee data" },
new FeaturePermission { Id = new Guid("b82d2b7e-0d52-45f3-997b-c008ea460e7f"), FeatureId = new Guid("81ab8a87-8ccd-4015-a917-0627cee6a100"), IsEnabled = true, Name = "View Team Members", Description = "Grants a user read-only access to details about the individuals within the system which are is assigned to same projects as user. This typically includes names, contact information, roles, departments, and potentially other relevant employee data" },
new FeaturePermission { Id = new Guid("a97d366a-c2bb-448d-be93-402bd2324566"), FeatureId = new Guid("81ab8a87-8ccd-4015-a917-0627cee6a100"), IsEnabled = true, Name = "Add/Edit Employee", Description = "Grants a user the authority to create new employee profiles and modify existing employee details within the system. This typically includes adding or updating information such as names, contact details, roles, departments, skills, and potentially other personal or professional data" },
new FeaturePermission { Id = new Guid("fbd213e0-0250-46f1-9f5f-4b2a1e6e76a3"), FeatureId = new Guid("81ab8a87-8ccd-4015-a917-0627cee6a100"), IsEnabled = true, Name = "Assign Roles", Description = "Grants a user the authority to manage employee application roles, enabling them to assign or revoke access privileges within the system." },

View File

@ -0,0 +1,47 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Marco.Pms.DataAccess.Migrations
{
/// <inheritdoc />
public partial class Changed_Name_Of_Feature_Permission_To_ViewTeamMembers : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "FeaturePermissions",
keyColumn: "Id",
keyValue: new Guid("60611762-7f8a-4fb5-b53f-b1139918796b"),
column: "Name",
value: "View All Employees");
migrationBuilder.UpdateData(
table: "FeaturePermissions",
keyColumn: "Id",
keyValue: new Guid("b82d2b7e-0d52-45f3-997b-c008ea460e7f"),
column: "Name",
value: "View Team Members");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "FeaturePermissions",
keyColumn: "Id",
keyValue: new Guid("60611762-7f8a-4fb5-b53f-b1139918796b"),
column: "Name",
value: "View All Employee");
migrationBuilder.UpdateData(
table: "FeaturePermissions",
keyColumn: "Id",
keyValue: new Guid("b82d2b7e-0d52-45f3-997b-c008ea460e7f"),
column: "Name",
value: "View Employee");
}
}
}

View File

@ -1039,7 +1039,7 @@ namespace Marco.Pms.DataAccess.Migrations
Description = "Grants a user read-only access to details about the all individuals within the system. This typically includes names, contact information, roles, departments, and potentially other relevant employee data",
FeatureId = new Guid("81ab8a87-8ccd-4015-a917-0627cee6a100"),
IsEnabled = true,
Name = "View All Employee"
Name = "View All Employees"
},
new
{
@ -1047,7 +1047,7 @@ namespace Marco.Pms.DataAccess.Migrations
Description = "Grants a user read-only access to details about the individuals within the system which are is assigned to same projects as user. This typically includes names, contact information, roles, departments, and potentially other relevant employee data",
FeatureId = new Guid("81ab8a87-8ccd-4015-a917-0627cee6a100"),
IsEnabled = true,
Name = "View Employee"
Name = "View Team Members"
},
new
{

View File

@ -38,8 +38,8 @@ namespace MarcoBMS.Services.Controllers
private readonly IHubContext<MarcoHub> _signalR;
private readonly PermissionServices _permission;
private readonly ProjectsHelper _projectsHelper;
private readonly Guid ViewAllEmployee;
private readonly Guid ViewEmployee;
private readonly Guid ViewAllEmployees;
private readonly Guid ViewTeamMembers;
private readonly Guid tenantId;
@ -56,8 +56,8 @@ namespace MarcoBMS.Services.Controllers
_logger = logger;
_signalR = signalR;
_permission = permission;
ViewAllEmployee = Guid.Parse("60611762-7f8a-4fb5-b53f-b1139918796b");
ViewEmployee = Guid.Parse("b82d2b7e-0d52-45f3-997b-c008ea460e7f");
ViewAllEmployees = Guid.Parse("60611762-7f8a-4fb5-b53f-b1139918796b");
ViewTeamMembers = Guid.Parse("b82d2b7e-0d52-45f3-997b-c008ea460e7f");
_projectsHelper = projectsHelper;
tenantId = _userHelper.GetTenantId();
}
@ -126,18 +126,18 @@ namespace MarcoBMS.Services.Controllers
List<Project> projects = await _projectsHelper.GetMyProjects(tenantId, loggedInEmployee);
var projectIds = projects.Select(p => p.Id).ToList();
var hasViewAllEmployeePermission = await _permission.HasPermission(ViewAllEmployee, loggedInEmployee.Id);
var hasViewEmployeePermission = await _permission.HasPermission(ViewEmployee, loggedInEmployee.Id);
var hasViewAllEmployeesPermission = await _permission.HasPermission(ViewAllEmployees, loggedInEmployee.Id);
var hasViewTeamMembersPermission = await _permission.HasPermission(ViewTeamMembers, loggedInEmployee.Id);
List<EmployeeVM> result = new();
// Step 4: Determine access level and fetch employees accordingly
if (hasViewAllEmployeePermission || projectid != null)
if (hasViewAllEmployeesPermission || projectid != null)
{
result = await _employeeHelper.GetEmployeeByProjectId(tenantId, projectid, ShowInactive);
_logger.LogInfo("Employee list fetched using full access or specific project.");
}
else if (hasViewEmployeePermission && !ShowInactive)
else if (hasViewTeamMembersPermission && !ShowInactive)
{
var employeeIds = await _context.ProjectAllocations
.Where(pa => projectIds.Contains(pa.ProjectId) && pa.IsActive)

View File

@ -33,7 +33,7 @@ namespace MarcoBMS.Services.Controllers
features.Add(item);
}
}
return features;
return features.OrderBy(f => f.Name).ToList();
}
[HttpGet]
@ -50,7 +50,7 @@ namespace MarcoBMS.Services.Controllers
ModuleId = c.ModuleId,
ModuleName = c.Module != null ? c.Module.Name : string.Empty,
IsActive = c.IsActive
});
}).OrderBy(f => f.Name).ToList();
return Ok(ApiResponse<object>.SuccessResponse(rolesVM, "Success.", 200));
}
}

View File

@ -156,6 +156,7 @@ namespace MarcoBMS.Services.Controllers
RoleName = x.Role.Role,
FeaturePermission = x.FeaturePermission
})
.OrderByDescending(r => r.RoleName)
.ToListAsync();
List<ApplicationRolesVM> applicationRoles = new List<ApplicationRolesVM>();