Make changes in report api to check if user reporting second time.

This commit is contained in:
ashutosh.nehete 2025-04-07 09:42:38 +05:30
parent 745b4d2e1c
commit 0b81a6ea62
2 changed files with 13 additions and 3 deletions

View File

@ -14,6 +14,6 @@ namespace Marco.Pms.Model.ViewModels.Activities
public int WorkItemId { get; set; }
public int TenantId { get; set; }
public List<TaskComment> Comments { get; set; }
public List<CommentVM> Comments { get; set; }
}
}

View File

@ -108,7 +108,10 @@ namespace MarcoBMS.Services.Controllers
if (taskAllocation == null) {
return BadRequest(ApiResponse<object>.ErrorResponse("No such task has been allocated.", "No such task has been allocated.", 400));
}
if(taskAllocation.CompletedTask != 0)
{
taskAllocation.WorkItem.CompletedWork -= taskAllocation.CompletedTask;
}
taskAllocation.ReportedDate = reportTask.ReportedDate;
taskAllocation.CompletedTask = reportTask.CompletedTask;
taskAllocation.WorkItem.CompletedWork += reportTask.CompletedTask;
@ -117,8 +120,15 @@ namespace MarcoBMS.Services.Controllers
_context.TaskComments.Add(comment);
await _context.SaveChangesAsync();
var response = taskAllocation.ToReportTaskVMFromTaskAllocation();
response.Comments = await _context.TaskComments.Where(c => c.TaskAllocationId == taskAllocation.Id).ToListAsync();
List < TaskComment > comments = await _context.TaskComments.Where(c => c.TaskAllocationId == taskAllocation.Id).ToListAsync();
List < CommentVM > resultComments = new List<CommentVM> { };
foreach(var result in comments)
{
resultComments.Add(result.ToCommentVMFromTaskComment());
}
response.Comments = resultComments;
return Ok(ApiResponse<object>.SuccessResponse(response, "Task reported successfully", 200));
}