using System;
using System.Collections.Generic;
using System.Formats.Asn1;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using CsvHelper;
using WpfApp1;

namespace WpfApp1.model
{
    [DataContract]
    public class Worker
    {
        public Uri? ImageBitmap
        {
            get
            {
                var imageName = Environment.CurrentDirectory + "/img/" + (photo ?? "");
                return System.IO.File.Exists(imageName) ? new Uri(imageName) : null;
            }
        }

        [DataMember]
        public string name { get; set; }
        [DataMember]
        public string Pos { get; set; }
        [DataMember]
        public int Age { get; set; }
        [DataMember]
        public string Sex { get; set; }

        [DataMember]
        public bool available { get; set; }

        [DataMember(Name = "date")]
        private string? stringdate { get; set; }
        [DataMember]
        public string photo { get; set; }

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



}
