using System;
using WpfApp1;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace WpfApp1.model
{
    [DataContract]
    public class cars
    {
        [DataMember]
        public string name { get; set; }
        [DataMember]
        public int year { get; set; }
        [DataMember]
        public double price { get; set; }
        [DataMember]
        public string color { get; set; }
        [DataMember]
        public bool defects { get; set; }
        [DataMember]
        public DateOnly? dateOfLastSTO { get; set; }
        [DataMember]
        public string? photo { get; set; }

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

    }
}