Backend/e-suite.Workflow.Core/TaskAssignee.cs

26 lines
858 B
C#

using e_suite.Database.Core.Tables.Domain;
using System.ComponentModel.DataAnnotations;
using e_suite.Database.Core.Tables.UserManager;
using e_suite.Workflow.Core.Enums;
using e_suite.Workflow.Core.Interfaces;
namespace e_suite.Workflow.Core;
public class TaskAssignee : ITaskAssignee, IValidatableObject
{
public Role? Role { get; set; }
public User? User { get; set; }
public Raci Raci { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (!((Role != null) ^ (User != null))) //Role Xor Contact means either must be set, but not both the same
{
yield return new ValidationResult(
"Either Role or Contact must be set, but not both.",
[nameof(Role), nameof(User)]
);
}
}
}