using System;
using System.Collections.Generic;
using KellermanSoftware.NetDataAccessLayer.Attributes;

namespace KellermanSoftware.ContactsModule.Models
{
    public class ContactHistory
    {
        private static string[] _contactTypes = { "Email", "Phone" };

        //Foreign Key
        [ParentObject("ContactId")]
        public Contact Contact { get; set; }

        public int ContactHistoryId { get; set; }
        public DateTime UpdateDate { get; set; }
        public string ContactType { get; set; }
        public string Note { get; set; }

        public ContactHistory()
        {
        }

        public ContactHistory(Contact contact)
        {
            UpdateDate = DateTime.Now;
            ContactType = _contactTypes[0];
            Contact = contact;
        }

        public ContactHistory(ContactHistory other)
        {
            Contact = other.Contact;
            ContactHistoryId = other.ContactHistoryId;
            UpdateDate = other.UpdateDate;
            ContactType = other.ContactType;
            Note = other.Note;
        }

        public static IEnumerable<string> ContactTypes
        {
            get { return _contactTypes; }
        }


        public Tuple<bool, string> ValidateNote()
        {
            if (string.IsNullOrEmpty(Note))
            {
                return new Tuple<bool, string>(false, "Note is required");
            }
            return new Tuple<bool, string>(true, null);
        }
    }
}
