using System; using System.Reflection; using System.Runtime.Serialization; using Umbraco.Core.Models.EntityBase; namespace Umbraco.Core.Models { /// /// Represents a Task /// [Serializable] [DataContract(IsReference = true)] public class Task : Entity, IAggregateRoot { private bool _closed; private TaskType _taskType; private int _entityId; private int _ownerUserId; private int _assigneeUserId; private string _comment; public Task(TaskType taskType) { _taskType = taskType; } private static readonly PropertyInfo ClosedSelector = ExpressionHelper.GetPropertyInfo(x => x.Closed); private static readonly PropertyInfo TaskTypeSelector = ExpressionHelper.GetPropertyInfo(x => x.TaskType); private static readonly PropertyInfo EntityIdSelector = ExpressionHelper.GetPropertyInfo(x => x.EntityId); private static readonly PropertyInfo OwnerUserIdSelector = ExpressionHelper.GetPropertyInfo(x => x.OwnerUserId); private static readonly PropertyInfo AssigneeUserIdSelector = ExpressionHelper.GetPropertyInfo(x => x.AssigneeUserId); private static readonly PropertyInfo CommentSelector = ExpressionHelper.GetPropertyInfo(x => x.Comment); /// /// Gets or sets a boolean indicating whether the task is closed /// [DataMember] public bool Closed { get { return _closed; } set { SetPropertyValueAndDetectChanges(o => { _closed = value; return _closed; }, _closed, ClosedSelector); } } /// /// Gets or sets the TaskType of the Task /// [DataMember] public TaskType TaskType { get { return _taskType; } set { SetPropertyValueAndDetectChanges(o => { _taskType = value; return _taskType; }, _taskType, TaskTypeSelector); } } /// /// Gets or sets the Id of the entity, which this task is associated to /// [DataMember] public int EntityId { get { return _entityId; } set { SetPropertyValueAndDetectChanges(o => { _entityId = value; return _entityId; }, _entityId, EntityIdSelector); } } /// /// Gets or sets the Id of the user, who owns this task /// [DataMember] public int OwnerUserId { get { return _ownerUserId; } set { SetPropertyValueAndDetectChanges(o => { _ownerUserId = value; return _ownerUserId; }, _ownerUserId, OwnerUserIdSelector); } } /// /// Gets or sets the Id of the user, who is assigned to this task /// [DataMember] public int AssigneeUserId { get { return _assigneeUserId; } set { SetPropertyValueAndDetectChanges(o => { _assigneeUserId = value; return _assigneeUserId; }, _assigneeUserId, AssigneeUserIdSelector); } } /// /// Gets or sets the Comment for the Task /// [DataMember] public string Comment { get { return _comment; } set { SetPropertyValueAndDetectChanges(o => { _comment = value; return _comment; }, _comment, CommentSelector); } } } }