Working on the TaskController, returns all the detail needed to be able to complete and assignment.
This commit is contained in:
parent
d93d7e3dcc
commit
c62e25681c
89
e-suite.API.Common/e-suite.API.Common/AssignmentDetails.cs
Normal file
89
e-suite.API.Common/e-suite.API.Common/AssignmentDetails.cs
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
using e_suite.Database.Core.Extensions;
|
||||||
|
using e_suite.Database.Core.Models;
|
||||||
|
using e_suite.Database.Core.Tables.Activity;
|
||||||
|
using eSuite.Core.Miscellaneous;
|
||||||
|
using eSuite.Core.Workflow;
|
||||||
|
|
||||||
|
namespace e_suite.API.Common;
|
||||||
|
|
||||||
|
public class GetAssignment : IGeneralId
|
||||||
|
{
|
||||||
|
public GetAssignment()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public GetAssignment(ActivityAssignment assignment)
|
||||||
|
{
|
||||||
|
Id = assignment.Id;
|
||||||
|
Guid = assignment.Guid;
|
||||||
|
StartDateTime = assignment.StartDateTime;
|
||||||
|
Raci = assignment.Raci;
|
||||||
|
AllowNoVerdict = assignment.AllowNoVerdict;
|
||||||
|
Outcomes = assignment.Outcomes;
|
||||||
|
RoleId = assignment.Role.ToGeneralIdRef();
|
||||||
|
UserId = assignment.User.ToGeneralIdRef();
|
||||||
|
Comments = assignment.Comments;
|
||||||
|
}
|
||||||
|
public long Id { get; set; }
|
||||||
|
public Guid Guid { get; set; }
|
||||||
|
public DateTimeOffset? StartDateTime { get; set; }
|
||||||
|
public Raci Raci { get; set; }
|
||||||
|
public bool AllowNoVerdict { get; set; }
|
||||||
|
public List<string> Outcomes { get; set; }
|
||||||
|
public GeneralIdRef? RoleId { get; set; }
|
||||||
|
public GeneralIdRef? UserId { get; set; }
|
||||||
|
public string Comments { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetTask : IGeneralId
|
||||||
|
{
|
||||||
|
public GetTask()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public GetTask(ActivityTask task)
|
||||||
|
{
|
||||||
|
Id = task.Id;
|
||||||
|
Guid = task.Guid;
|
||||||
|
TaskName = task.TaskName;
|
||||||
|
TaskType = task.TaskType;
|
||||||
|
TaskGuid = task.TaskGuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long Id { get; set; }
|
||||||
|
public Guid Guid { get; set; }
|
||||||
|
public string TaskName { get; set; }
|
||||||
|
public string TaskType { get; set; }
|
||||||
|
public Guid TaskGuid { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetActivity : IGeneralId
|
||||||
|
{
|
||||||
|
public GetActivity()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public GetActivity(Activity activity)
|
||||||
|
{
|
||||||
|
Id = activity.Id;
|
||||||
|
Guid = activity.Guid;
|
||||||
|
Name = activity.Name;
|
||||||
|
WorkflowVersionId = activity.WorkflowVersionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long Id { get; set; }
|
||||||
|
public Guid Guid { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public long WorkflowVersionId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AssignmentDetails
|
||||||
|
{
|
||||||
|
public GetAssignment Assignment { get; set; }
|
||||||
|
public GetTask Task { get; set; }
|
||||||
|
public object Activity { get; set; }
|
||||||
|
public GetWorkflowTemplateVersion WorkflowTemplateVersion { get; set; }
|
||||||
|
}
|
||||||
@ -1,5 +1,4 @@
|
|||||||
using System.Diagnostics;
|
using e_suite.Database.Core.Extensions;
|
||||||
using e_suite.Database.Core.Extensions;
|
|
||||||
using e_suite.Database.Core.Models;
|
using e_suite.Database.Core.Models;
|
||||||
using eSuite.Core.Miscellaneous;
|
using eSuite.Core.Miscellaneous;
|
||||||
|
|
||||||
@ -31,5 +30,4 @@ public class GetMyAssignments : IGeneralId
|
|||||||
|
|
||||||
public GeneralIdRef? Role { get; set; }
|
public GeneralIdRef? Role { get; set; }
|
||||||
public DateTimeOffset? StartDateTime { get; set; }
|
public DateTimeOffset? StartDateTime { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
using e_suite.Database.Audit;
|
using e_suite.Database.Audit;
|
||||||
using e_suite.Utilities.Pagination;
|
using e_suite.Utilities.Pagination;
|
||||||
|
using eSuite.Core.Miscellaneous;
|
||||||
|
|
||||||
namespace e_suite.API.Common;
|
namespace e_suite.API.Common;
|
||||||
|
|
||||||
@ -7,4 +8,5 @@ public interface IActivityManager
|
|||||||
{
|
{
|
||||||
Task CreateActivity(AuditUserDetails auditUserDetails, CreateActivity template, CancellationToken cancellationToken);
|
Task CreateActivity(AuditUserDetails auditUserDetails, CreateActivity template, CancellationToken cancellationToken);
|
||||||
Task<PaginatedData<GetMyAssignments>> GetMyActiveAssignmentsAsync(AuditUserDetails auditUserDetails, Paging paging, CancellationToken cancellationToken);
|
Task<PaginatedData<GetMyAssignments>> GetMyActiveAssignmentsAsync(AuditUserDetails auditUserDetails, Paging paging, CancellationToken cancellationToken);
|
||||||
|
Task<AssignmentDetails> GetAssignmentDetails(AuditUserDetails auditUserDetails, GeneralIdRef assignmentId, CancellationToken cancellationToken);
|
||||||
}
|
}
|
||||||
@ -2,6 +2,7 @@
|
|||||||
using e_suite.Utilities.Pagination;
|
using e_suite.Utilities.Pagination;
|
||||||
using eSuite.API.security;
|
using eSuite.API.security;
|
||||||
using eSuite.API.Utilities;
|
using eSuite.API.Utilities;
|
||||||
|
using eSuite.Core.Miscellaneous;
|
||||||
using eSuite.Core.Security;
|
using eSuite.Core.Security;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ public class TasksController : ESuiteControllerBase
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a list of workflow templates
|
/// Get my current assignments
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="paging"></param>
|
/// <param name="paging"></param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
@ -41,4 +42,23 @@ public class TasksController : ESuiteControllerBase
|
|||||||
var result = await _activityManager.GetMyActiveAssignmentsAsync(AuditUserDetails, paging, cancellationToken);
|
var result = await _activityManager.GetMyActiveAssignmentsAsync(AuditUserDetails, paging, cancellationToken);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the details of an assignment
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assignmentId"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
|
[Route("getAssignmentDetails")]
|
||||||
|
[AccessKey(SecurityAccess.ViewTasks)]
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IActionResult> GetAssignmentDetails( [FromQuery] GeneralIdRef assignmentId, CancellationToken cancellationToken = default!
|
||||||
|
)
|
||||||
|
{
|
||||||
|
var result = await _activityManager.GetAssignmentDetails(AuditUserDetails, assignmentId, cancellationToken);
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,15 +1,15 @@
|
|||||||
using e_suite.API.Common;
|
using e_suite.API.Common;
|
||||||
|
using e_suite.API.Common.exceptions;
|
||||||
using e_suite.API.Common.repository;
|
using e_suite.API.Common.repository;
|
||||||
using e_suite.Database.Audit;
|
using e_suite.Database.Audit;
|
||||||
using e_suite.Database.Core.Extensions;
|
using e_suite.Database.Core.Extensions;
|
||||||
using e_suite.Database.Core.Tables.Activity;
|
using e_suite.Database.Core.Tables.Activity;
|
||||||
using e_suite.Messaging.Common;
|
using e_suite.Messaging.Common;
|
||||||
using e_suite.Utilities.Pagination;
|
using e_suite.Utilities.Pagination;
|
||||||
|
using eSuite.Core.Enums;
|
||||||
using eSuite.Core.Miscellaneous;
|
using eSuite.Core.Miscellaneous;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using eSuite.Core.Enums;
|
|
||||||
|
|
||||||
namespace e_suite.Modules.RunningActivityManager;
|
namespace e_suite.Modules.RunningActivityManager;
|
||||||
|
|
||||||
@ -80,4 +80,34 @@ public class ActivityManager : IActivityManager
|
|||||||
_ => x => x.Id
|
_ => x => x.Id
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<AssignmentDetails> GetAssignmentDetails(
|
||||||
|
AuditUserDetails auditUserDetails,
|
||||||
|
GeneralIdRef assignmentId,
|
||||||
|
CancellationToken cancellationToken
|
||||||
|
)
|
||||||
|
{
|
||||||
|
var assignment = await _activityRepository.GetAssignments().FindByGeneralIdRefAsync(assignmentId, cancellationToken);
|
||||||
|
if (assignment == null)
|
||||||
|
throw new NotFoundException("Unable to find assignment");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var assignmentObject = new GetAssignment(assignment);
|
||||||
|
|
||||||
|
var taskObject = new GetTask(assignment.Task);
|
||||||
|
|
||||||
|
var activityObject = new GetActivity(assignment.Task.Activity);
|
||||||
|
|
||||||
|
var dbWorkflowTemplate = _workflowTemplateRepository.GetWorkflowVersions().Single(x => x.Id == activityObject.WorkflowVersionId);
|
||||||
|
|
||||||
|
return new AssignmentDetails
|
||||||
|
{
|
||||||
|
Assignment = assignmentObject,
|
||||||
|
Task = taskObject,
|
||||||
|
Activity = activityObject,
|
||||||
|
WorkflowTemplateVersion = new GetWorkflowTemplateVersion(dbWorkflowTemplate)
|
||||||
|
//todo add the assignment metadata (outcomes)
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -68,4 +68,5 @@ public class ActivityRepository : RepositoryBase, IActivityRepository
|
|||||||
.Include(x => x.Task)
|
.Include(x => x.Task)
|
||||||
.ThenInclude( x => x.Activity);
|
.ThenInclude( x => x.Activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -82,9 +82,6 @@ public class WorkflowTemplateManager : IWorkflowTemplateManager
|
|||||||
var workflow = await _workflowTemplateRepository.GetWorkflows().FindByGeneralIdRefAsync(generalIdRef, cancellationToken) ?? throw new NotFoundException("Unable to find Workflow");
|
var workflow = await _workflowTemplateRepository.GetWorkflows().FindByGeneralIdRefAsync(generalIdRef, cancellationToken) ?? throw new NotFoundException("Unable to find Workflow");
|
||||||
|
|
||||||
var dbWorkflowTemplate = _workflowTemplateRepository.GetWorkflowVersions().Where(x => x.WorkflowId == workflow.Id).OrderByDescending( x => x.Version).First();
|
var dbWorkflowTemplate = _workflowTemplateRepository.GetWorkflowVersions().Where(x => x.WorkflowId == workflow.Id).OrderByDescending( x => x.Version).First();
|
||||||
//var dbWorkflowTemplate = await _workflowTemplateRepository.GetWorkflowVersions().FindByGeneralIdRefAsync(generalIdRef, cancellationToken) ?? throw new NotFoundException("Unable to find Workflow Version");
|
|
||||||
|
|
||||||
//var workflowTemplate = _workflowConverter.DeserialiseFromDatabase(dbWorkflowTemplate);
|
|
||||||
|
|
||||||
return new GetWorkflowTemplateVersion(dbWorkflowTemplate);
|
return new GetWorkflowTemplateVersion(dbWorkflowTemplate);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user