/// <summary> /// Nominate an Identity to process the task. When a person gets /// nominated then the task status changes to 'Reserved' and the person becomes Actual Owner. if /// a group gets nominated, then the task status will be changed to 'Rady'. Each nominated /// entity should be added to the collection of Potential Owners. /// This action can be performed by a Business Administrator when the task is in 'Created' state /// </summary> /// <param name="task">The task.</param> /// <param name="target">Actual Owner or Potential Owners</param> /// <param name="principal">The principal.</param> /// <exception cref="TaskAccessException"/> /// <exception cref="TaskInvalidStateException"/> public virtual void Nominate(TaskEntity task, IIdentity target, IPrincipal principal) { if (task.Status != TaskStatus.Created) throw new TaskInvalidStateException(); if (!principal.IsInRole(HumanRoles.BusinessAdministrator)) throw new TaskAccessException(); if (target.IsGroupIdentity()) { task.Status = TaskStatus.Ready; } else { task.Status = TaskStatus.Reserved; task.ActualOwner = target; } }
/// <summary> /// Executes the forwarding of the task. /// </summary> /// <param name="task">The task.</param> /// <param name="target">The target.</param> protected virtual void ExecuteForward(TaskEntity task, IIdentity target) { if (target.IsGroupIdentity()) throw new ArgumentException("Cannot forward a task to a group!"); task.Status = TaskStatus.Ready; task.ActualOwner = target; }
/// <summary> /// Delegates the task. /// Assign the task to a target user and set the task status to 'Reserved'. /// If the recipient was not a potential owner then this /// person will be added to the list of potential owners. /// </summary> /// <param name="task">The task entity</param> /// <param name="target">The target user.</param> /// <param name="priority">The priority.</param> /// <param name="principal">The principal.</param> public virtual void Delegate(TaskEntity task, IIdentity target, Priority priority, IPrincipal principal) { if (task.Status != TaskStatus.InProgress) throw new TaskInvalidStateException(); if (!principal.IsInAnyRole(HumanRoles.ActualOwner, HumanRoles.BusinessAdministrator)) throw new TaskAccessException(); task.Status = TaskStatus.Reserved; if (target.IsGroupIdentity()) throw new ArgumentException("Cannot delegate a task to a group!"); task.ActualOwner = target; task.Priority = priority; }