using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static wpf_listbox.models.Globals;
using System.Threading.Tasks;
using System.Collections.Generic;
using wpf_listbox;
using CsvHelper;
using System.Diagnostics;
using wpf_listbox.models;
using static wpf_listbox.MainWindow;
using System.IO;
using System.Globalization;
using System.Runtime.Serialization;

namespace wpf_listbox.models
{
    [DataContract]
    public class People
    {
        [DataMember]
        public string Name { get; set; }
        [DataMember]
        public int Age { get; set; }
        [DataMember]
        public int Price { get; set; }
        [DataMember]
        public string Gender { get; set; }
        [DataMember]
        public string Photo { get; set; }
        [DataMember]
        public string Place { get; set; }
        [DataMember]
        public bool IsFavorite { get; set; }
        [DataMember(Name = "dateOfConnections")]
        private string? stringDate { get; set; }

        [IgnoreDataMember]
        public DateTime? dateOfConnections
        {
            get
            {
                return stringDate == null ? null : DateTime.Parse(stringDate);
            }
            set
            {
                stringDate = value.ToString();
            }
        }

        public Uri? ImageBitmap
        {
            get
                {
                    var imageName = Environment.CurrentDirectory + "/img/" + (Photo ?? "");
                    return System.IO.File.Exists(imageName) ? new Uri(imageName) : null;
                }
            }
    }
}