using System;
using System.IO;
using System.Windows.Media.Imaging;

namespace NBAManagement.Models
{
    public class Image
    {
        public int Id { get; set; }
        public DateTime CreateTime { get; set; }
        public BitmapImage ImageSource { get; set; }

        public void SaveAsFile(string path)
        {
            var encoder = new PngBitmapEncoder();
            encoder.Frames.Add(BitmapFrame.Create(ImageSource));

            using (var stream = new FileStream(path, FileMode.Create))
            {
                encoder.Save(stream);
            }
        }
    }
}
