Assigning the root employee to default when creating the tenant

This commit is contained in:
ashutosh.nehete 2025-08-16 17:15:01 +05:30
parent d8870b8140
commit d240a79e49

View File

@ -352,7 +352,6 @@ namespace Marco.Pms.Services.Controllers
return Ok(ApiResponse<object>.SuccessResponse(response, "Tenant profile fetched successfully", 200)); return Ok(ApiResponse<object>.SuccessResponse(response, "Tenant profile fetched successfully", 200));
} }
// POST api/<TenantController> // POST api/<TenantController>
[HttpPost("create")] [HttpPost("create")]
public async Task<IActionResult> CreateTenant([FromBody] CreateTenantDto model) public async Task<IActionResult> CreateTenant([FromBody] CreateTenantDto model)
@ -551,6 +550,17 @@ namespace Marco.Pms.Services.Controllers
}; };
_context.Projects.Add(project); _context.Projects.Add(project);
var projectAllocation = new ProjectAllocation
{
ProjectId = project.Id,
EmployeeId = employeeUser.Id,
AllocationDate = model.OnBoardingDate,
IsActive = true,
JobRoleId = adminJobRole.Id,
TenantId = tenant.Id
};
_context.ProjectAllocations.Add(projectAllocation);
// All entities are now added to the context. Save them all in a single database operation. // All entities are now added to the context. Save them all in a single database operation.
await _context.SaveChangesAsync(); await _context.SaveChangesAsync();