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 WpfApp2;

namespace WpfApp2.model
{
    [DataContract]
    public class Spares
    {
        [DataMember]
        public string name { get; set; }
        [DataMember]
        public string detail { get; set; }
        [DataMember]
        public int price { get; set; }
        [DataMember]
        public string type { get; set; }

        [DataMember]
        public string photo { get; set; }

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

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

        [IgnoreDataMember]
        public DateTime? date

        {
            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;
            }
        }
    }

   

}