using AutoMapper;
using LeafWeb.Core.Entities;

namespace LeafWeb.Core.Remote
{
	public class PiscalLeafOutputFile
	{
		private static readonly IMapper Mapper;

		public string Filename { get; set; }
		public byte[] Contents { get; set; }
		public string DirectoryName { get; set; }
		public int LeafInputId => PiscalUtility.GetIdFromDirectoryName(DirectoryName);

		static PiscalLeafOutputFile()
		{
			var config =
				new MapperConfiguration(cfg =>
				{
					cfg.CreateMap<PiscalLeafOutputFile, LeafOutputFile>();
				});
			Mapper = config.CreateMapper();
		}

		public PiscalLeafOutputFile() { }

		public LeafOutputFile GetLeafOutputFile()
		{
			var leafOutputFile = new LeafOutputFile();
			Mapper.Map(this, leafOutputFile);
			return leafOutputFile;
		}
	}
}