Added new paremeter of NumberOfImages in signalR message object
This commit is contained in:
parent
558fd6bd5b
commit
65f3376523
@ -199,6 +199,8 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
var comment = reportTask.ToCommentFromReportTaskDto(tenantId, loggedInEmployee.Id);
|
var comment = reportTask.ToCommentFromReportTaskDto(tenantId, loggedInEmployee.Id);
|
||||||
_context.TaskComments.Add(comment);
|
_context.TaskComments.Add(comment);
|
||||||
|
|
||||||
|
int numberofImages = 0;
|
||||||
|
|
||||||
var workAreaId = taskAllocation.WorkItem?.WorkAreaId;
|
var workAreaId = taskAllocation.WorkItem?.WorkAreaId;
|
||||||
var workArea = await _context.WorkAreas.Include(a => a.Floor)
|
var workArea = await _context.WorkAreas.Include(a => a.Floor)
|
||||||
.FirstOrDefaultAsync(a => a.Id == workAreaId) ?? new WorkArea();
|
.FirstOrDefaultAsync(a => a.Id == workAreaId) ?? new WorkArea();
|
||||||
@ -252,6 +254,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
ReferenceId = reportTask.Id
|
ReferenceId = reportTask.Id
|
||||||
};
|
};
|
||||||
_context.TaskAttachments.Add(attachment);
|
_context.TaskAttachments.Add(attachment);
|
||||||
|
numberofImages += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +268,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
response.Comments = comments.Select(c => c.ToCommentVMFromTaskComment()).ToList();
|
response.Comments = comments.Select(c => c.ToCommentVMFromTaskComment()).ToList();
|
||||||
response.checkList = checkListVMs;
|
response.checkList = checkListVMs;
|
||||||
|
|
||||||
var notification = new { LoggedInUserId = loggedInEmployee.Id, Keyword = "Task_Report", ProjectId = projectId };
|
var notification = new { LoggedInUserId = loggedInEmployee.Id, Keyword = "Task_Report", NumberOfImages = numberofImages, ProjectId = projectId };
|
||||||
await _signalR.Clients.All.SendAsync("NotificationEventHandler", notification);
|
await _signalR.Clients.All.SendAsync("NotificationEventHandler", notification);
|
||||||
|
|
||||||
_logger.LogInfo("Task {TaskId} reported successfully by Employee {EmployeeId}", taskAllocation.Id, loggedInEmployee.Id);
|
_logger.LogInfo("Task {TaskId} reported successfully by Employee {EmployeeId}", taskAllocation.Id, loggedInEmployee.Id);
|
||||||
@ -310,6 +313,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
// Process image uploads
|
// Process image uploads
|
||||||
var images = createComment.Images;
|
var images = createComment.Images;
|
||||||
var batchId = Guid.NewGuid();
|
var batchId = Guid.NewGuid();
|
||||||
|
int numberofImages = 0;
|
||||||
|
|
||||||
if (images != null && images.Any())
|
if (images != null && images.Any())
|
||||||
{
|
{
|
||||||
@ -355,6 +359,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
};
|
};
|
||||||
|
|
||||||
_context.TaskAttachments.Add(attachment);
|
_context.TaskAttachments.Add(attachment);
|
||||||
|
numberofImages += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
@ -365,7 +370,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
var response = comment.ToCommentVMFromTaskComment();
|
var response = comment.ToCommentVMFromTaskComment();
|
||||||
_logger.LogInfo("Returning response for commentId: {CommentId}", comment.Id);
|
_logger.LogInfo("Returning response for commentId: {CommentId}", comment.Id);
|
||||||
|
|
||||||
var notification = new { LoggedInUserId = loggedInEmployee.Id, Keyword = "Task_Comment", ProjectId = projectId };
|
var notification = new { LoggedInUserId = loggedInEmployee.Id, Keyword = "Task_Comment", NumberOfImages = numberofImages, ProjectId = projectId };
|
||||||
await _signalR.Clients.All.SendAsync("NotificationEventHandler", notification);
|
await _signalR.Clients.All.SendAsync("NotificationEventHandler", notification);
|
||||||
|
|
||||||
return Ok(ApiResponse<object>.SuccessResponse(response, "Comment saved successfully", 200));
|
return Ok(ApiResponse<object>.SuccessResponse(response, "Comment saved successfully", 200));
|
||||||
@ -749,6 +754,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
var building = await _context.Buildings
|
var building = await _context.Buildings
|
||||||
.FirstOrDefaultAsync(b => b.Id == buildingId);
|
.FirstOrDefaultAsync(b => b.Id == buildingId);
|
||||||
var projectId = building?.ProjectId;
|
var projectId = building?.ProjectId;
|
||||||
|
int numberofImages = 0;
|
||||||
|
|
||||||
// Handle image attachments, if any
|
// Handle image attachments, if any
|
||||||
if (approveTask.Images?.Count > 0)
|
if (approveTask.Images?.Count > 0)
|
||||||
@ -795,13 +801,14 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
_context.TaskAttachments.Add(attachment);
|
_context.TaskAttachments.Add(attachment);
|
||||||
|
|
||||||
_logger.LogInfo("Attachment uploaded for Task {TaskId}: {FileName}", approveTask.Id, fileName);
|
_logger.LogInfo("Attachment uploaded for Task {TaskId}: {FileName}", approveTask.Id, fileName);
|
||||||
|
numberofImages += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commit all changes to the database
|
// Commit all changes to the database
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
var notification = new { LoggedInUserId = loggedInEmployee.Id, Keyword = "Task_Comment", ProjectId = projectId };
|
var notification = new { LoggedInUserId = loggedInEmployee.Id, Keyword = "Task_Report", NumberOfImages = numberofImages, ProjectId = projectId };
|
||||||
await _signalR.Clients.All.SendAsync("NotificationEventHandler", notification);
|
await _signalR.Clients.All.SendAsync("NotificationEventHandler", notification);
|
||||||
|
|
||||||
_logger.LogInfo("Task {TaskId} successfully approved by Employee {EmployeeId}", approveTask.Id, loggedInEmployee.Id);
|
_logger.LogInfo("Task {TaskId} successfully approved by Employee {EmployeeId}", approveTask.Id, loggedInEmployee.Id);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user