using System.Text;

namespace BS.Shared.DataContracts
{
    partial class MailDC
    {
        public string ReceiverString
        {
            get
            {
                var builder = new StringBuilder();

                var first = true;

                foreach (var item in this.Receiver)
                {
                    if (!first)
                    {
                        builder.Append(", ");
                    }

                    if (!string.IsNullOrEmpty(item.FirstName))
                    {
                        builder.Append(item.FirstName);
                        builder.Append(' ');
                    }

                    if (!string.IsNullOrEmpty(item.LastName))
                    {
                        builder.Append(item.LastName);
                        builder.Append(' ');
                    }

                    builder.Append(item.EmailAddress);

                    first = false;
                }

                return builder.ToString();
            }
        }

        public override string ToString()
        {
            return this.Subject;
        }
    }
}