Exemplo n.º 1
0
        public async Task CompleteWorkItem(int workItemId, int userId, string workNotes, int?onBehalfOfUserId = null, bool force = false)
        {
            var workItem = await _workItemRepository.GetWorkItem(workItemId);

            var assignments = await _workItemRepository.GetWorkItemAssignments(workItemId);

            if (workItem.CompletedAt.HasValue)
            {
                return;
            }

            //sanitize work note markup
            if (!string.IsNullOrEmpty(workNotes))
            {
                workNotes = SanitizeHtml(workNotes);
            }

            //administrative completion
            if (force)
            {
                await this.CompleteWorkItemAdminOnly(workItem, assignments, userId, workNotes, onBehalfOfUserId);
            }
            else if (workItem.CompletionMode == CompletionMode.AdminOnly)
            {
                await this.CompleteWorkItemAdminOnly(workItem, assignments, userId, workNotes, onBehalfOfUserId);
            }
            else if (workItem.CompletionMode == CompletionMode.AllAssigned)
            {
                await this.CompleteWorkItemAllAssigned(workItem, assignments, onBehalfOfUserId ?? userId, workNotes);
            }
            else if (workItem.CompletionMode == CompletionMode.Any)
            {
                await this.CompleteWorkItemAny(workItem, assignments, onBehalfOfUserId ?? userId, workNotes);
            }
            else if (workItem.CompletionMode == CompletionMode.AnyAssigned)
            {
                await this.CompleteWorkItemAnyAssigned(workItem, assignments, onBehalfOfUserId ?? userId, workNotes);
            }
        }