Ashutosh_Task#513 #96
@ -518,7 +518,11 @@ namespace MarcoBMS.Services.Controllers
|
||||
if (projectAllocationDot != null)
|
||||
{
|
||||
Guid TenentID = GetTenantId();
|
||||
var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
|
||||
List<object>? result = new List<object>();
|
||||
List<Guid> employeeIds = new List<Guid>();
|
||||
List<Guid> projectIds = new List<Guid>();
|
||||
|
||||
foreach (var item in projectAllocationDot)
|
||||
{
|
||||
@ -547,6 +551,9 @@ namespace MarcoBMS.Services.Controllers
|
||||
projectAllocationFromDb.IsActive = false;
|
||||
_context.Entry(projectAllocationFromDb).Property(e => e.ReAllocationDate).IsModified = true;
|
||||
_context.Entry(projectAllocationFromDb).Property(e => e.IsActive).IsModified = true;
|
||||
|
||||
employeeIds.Add(projectAllocation.EmployeeId);
|
||||
projectIds.Add(projectAllocation.ProjectId);
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
var result1 = new
|
||||
@ -568,15 +575,21 @@ namespace MarcoBMS.Services.Controllers
|
||||
projectAllocation.IsActive = true;
|
||||
_context.ProjectAllocations.Add(projectAllocation);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
employeeIds.Add(projectAllocation.EmployeeId);
|
||||
projectIds.Add(projectAllocation.ProjectId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Ok(ApiResponse<object>.ErrorResponse(ex.Message, ex, 400));
|
||||
}
|
||||
}
|
||||
var notification = new { LoggedInUserId = LoggedInEmployee.Id, Keyword = "Assign_Project", ProjectIds = projectIds, EmployeeList = employeeIds };
|
||||
|
||||
await _signalR.Clients.All.SendAsync("NotificationEventHandler", notification);
|
||||
return Ok(ApiResponse<object>.SuccessResponse(result, "Data saved successfully", 200));
|
||||
|
||||
}
|
||||
@ -590,6 +603,7 @@ namespace MarcoBMS.Services.Controllers
|
||||
Guid tenantId = GetTenantId();
|
||||
var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
List<WorkItemVM> workItems = new List<WorkItemVM> { };
|
||||
Building building = new Building();
|
||||
string responseMessage = "";
|
||||
if (workItemDot != null)
|
||||
{
|
||||
@ -597,6 +611,10 @@ namespace MarcoBMS.Services.Controllers
|
||||
{
|
||||
WorkItem workItem = item.ToWorkItemFromWorkItemDto(tenantId);
|
||||
|
||||
var workArea = await _context.WorkAreas.Include(a => a.Floor).FirstOrDefaultAsync(a => a.Id == workItem.WorkAreaId) ?? new WorkArea();
|
||||
|
||||
building = await _context.Buildings.FirstOrDefaultAsync(b => b.Id == (workArea.Floor != null ? workArea.Floor.BuildingId : Guid.Empty)) ?? new Building();
|
||||
|
||||
if (item.Id != null)
|
||||
{
|
||||
//update
|
||||
@ -621,7 +639,7 @@ namespace MarcoBMS.Services.Controllers
|
||||
var activity = await _context.ActivityMasters.ToListAsync();
|
||||
var category = await _context.WorkCategoryMasters.ToListAsync();
|
||||
|
||||
var notification = new { LoggedInUserId = LoggedInEmployee.Id, Keyword = "Infra", Response = workItems };
|
||||
var notification = new { LoggedInUserId = LoggedInEmployee.Id, Keyword = "Infra", ProjectId = building.ProjectId };
|
||||
|
||||
await _signalR.Clients.All.SendAsync("NotificationEventHandler", notification);
|
||||
return Ok(ApiResponse<object>.SuccessResponse(workItems, responseMessage, 200));
|
||||
@ -808,7 +826,9 @@ namespace MarcoBMS.Services.Controllers
|
||||
if (projectAllocationDtos != null && employeeId != Guid.Empty)
|
||||
{
|
||||
Guid TenentID = GetTenantId();
|
||||
var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
List<object>? result = new List<object>();
|
||||
List<Guid> projectIds = new List<Guid>();
|
||||
|
||||
foreach (var projectAllocationDto in projectAllocationDtos)
|
||||
{
|
||||
@ -836,6 +856,8 @@ namespace MarcoBMS.Services.Controllers
|
||||
projectAllocationFromDb.IsActive = false;
|
||||
_context.Entry(projectAllocationFromDb).Property(e => e.ReAllocationDate).IsModified = true;
|
||||
_context.Entry(projectAllocationFromDb).Property(e => e.IsActive).IsModified = true;
|
||||
|
||||
projectIds.Add(projectAllocation.ProjectId);
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
var result1 = new
|
||||
@ -858,6 +880,8 @@ namespace MarcoBMS.Services.Controllers
|
||||
_context.ProjectAllocations.Add(projectAllocation);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
projectIds.Add(projectAllocation.ProjectId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -868,6 +892,9 @@ namespace MarcoBMS.Services.Controllers
|
||||
return Ok(ApiResponse<object>.ErrorResponse(ex.Message, ex, 400));
|
||||
}
|
||||
}
|
||||
var notification = new { LoggedInUserId = LoggedInEmployee.Id, Keyword = "Assign_Project", ProjectIds = projectIds, EmployeeId = employeeId };
|
||||
|
||||
await _signalR.Clients.All.SendAsync("NotificationEventHandler", notification);
|
||||
|
||||
return Ok(ApiResponse<object>.SuccessResponse(result, "Data saved successfully", 200));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user