First saving the project sevice mapping then the project org mapping

This commit is contained in:
ashutosh.nehete 2025-09-19 16:46:41 +05:30
parent 7f2b9f0ceb
commit 3884c74d9b

View File

@ -352,6 +352,7 @@ namespace Marco.Pms.Services.Controllers
}
List<ProjectOrgMapping> projectOrgMappings = new List<ProjectOrgMapping>();
List<ProjectServiceMapping> projectServiceMappings = new List<ProjectServiceMapping>();
foreach (var serviceId in model.ServiceIds)
{
@ -368,6 +369,7 @@ namespace Marco.Pms.Services.Controllers
{
projectService = new ProjectServiceMapping
{
Id = Guid.NewGuid(),
ProjectId = project.Id,
ServiceId = serviceId,
TenantId = project.TenantId,
@ -376,7 +378,7 @@ namespace Marco.Pms.Services.Controllers
ActualStartDate = DateTime.UtcNow,
IsActive = true
};
_context.ProjectServiceMappings.Add(projectService);
projectServiceMappings.Add(projectService);
}
var projectOrgMapping = new ProjectOrgMapping
{
@ -395,6 +397,12 @@ namespace Marco.Pms.Services.Controllers
}
}
if (projectServiceMappings.Any())
{
_context.ProjectServiceMappings.AddRange(projectServiceMappings);
await _context.SaveChangesAsync();
}
_context.ProjectOrgMappings.AddRange(projectOrgMappings);
await _context.SaveChangesAsync();