using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GreenTree.Nachtragsmanagement.Core.Domain.Misc
{
    public class MailNotification : BaseEntity
    {
        #region Fields

        /// <summary>
        /// Users related to the notification
        /// </summary>
        private ICollection<User.User> _users;

        #endregion

        /// <summary>
        /// The cron expression if the notification will be sent by time
        /// </summary>
        public string CronExpression { get; set; }

        /// <summary>
        /// The system name of the corresponding plugin generating the notification
        /// </summary>
        public string NotificationPluginSystemName { get; set; }

        /// <summary>
        /// The system name of the job that should be processed by the corresponding notification plugin
        /// </summary>
        public string NotificationJobSystemName { get; set; }

        /// <summary>
        /// Users assigned to the notification
        /// </summary>
        public virtual ICollection<User.User> Users
        {
            get { return _users ?? ( _users = new List<User.User>()); }
            protected set { _users = value; }
        }

        #region Helper

        /// <summary>
        /// Adds missing users and removes not selected users
        /// </summary>
        /// <param name="users">Site users.</param>
        public void SetUsers(ICollection<User.User> users)
        {
            Users = users;
        }

        #endregion
    }
}
