Make changes in report api to check if user reporting second time.
This commit is contained in:
parent
745b4d2e1c
commit
0b81a6ea62
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user