using System.Collections.Generic;
using System.Net;

namespace UnivateProperties_API.Model.Communication
{
    public class SMTPHost : BaseEntity
    {
        #region Constructor
        public SMTPHost()
        {

        }

        public SMTPHost(string host, bool needsAutorize, string user, string password)
        {
            Host = host;
            User = user;
            NeedsAuthorize = needsAutorize;
            Password = password;
        }
        #endregion

        #region Properties
        public string Host { get; set; }
        public bool NeedsAuthorize { get; set; } = false;
        public string User { get; set; }
        public string Password { get; set; }
        public bool UseSSL { get; set; } = false;

        public virtual ICollection<SMTPAccount> SMTPAccounts { get; set; }
        #endregion Properties

        #region Methods
        public NetworkCredential GetNetworkCredential()
        {
            if (NeedsAuthorize)
            {
                return new NetworkCredential(User, Password);
            }
            return null;
        }
        #endregion
    }
}