private WorkflowTask GetWorkflowTask(WorkflowTask request) { var id = request?.Id; WorkflowTask ret = null; var query = DocQuery.ActiveQuery ?? Execute; DocPermissionFactory.SetVisibleFields <WorkflowTask>(currentUser, "WorkflowTask", request.VisibleFields); DocEntityWorkflowTask entity = null; if (id.HasValue) { entity = DocEntityWorkflowTask.GetWorkflowTask(id.Value); } if (null == entity) { throw new HttpError(HttpStatusCode.NotFound, $"No WorkflowTask found for Id {id.Value}"); } if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.VIEW)) { throw new HttpError(HttpStatusCode.Forbidden, "You do not have VIEW permission for this route."); } ret = entity?.ToDto(); return(ret); }
public WorkflowTask Post(WorkflowTaskCopy request) { WorkflowTask ret = null; using (Execute) { Execute.Run(ssn => { var entity = DocEntityWorkflowTask.GetWorkflowTask(request?.Id); if (null == entity) { throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed."); } if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD)) { throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route."); } var pAssignee = entity.Assignee; var pData = entity.Data; var pDescription = entity.Description; if (!DocTools.IsNullOrEmpty(pDescription)) { pDescription += " (Copy)"; } var pDueDate = entity.DueDate; var pReporter = entity.Reporter; var pStatus = entity.Status; var pType = entity.Type; var pWorkflow = entity.Workflow; #region Custom Before copyWorkflowTask #endregion Custom Before copyWorkflowTask var copy = new DocEntityWorkflowTask(ssn) { Hash = Guid.NewGuid() , Assignee = pAssignee , Data = pData , Description = pDescription , DueDate = pDueDate , Reporter = pReporter , Status = pStatus , Type = pType , Workflow = pWorkflow }; #region Custom After copyWorkflowTask #endregion Custom After copyWorkflowTask copy.SaveChanges(DocConstantPermission.ADD); ret = copy.ToDto(); }); } return(ret); }