using InABox.Core;

namespace InABox.Database
{
    public class DocumentStore : Store<Document>
    {
        protected override void AfterLoad(IEnumerable<Document> items)
        {
            base.AfterLoad(items);
            //if (!Provider.IsRelational())
            //{
            //    foreach (var item in items)
            //    {
            //        if ((item.Data == null) || (item.Data.Length == 0))
            //            item.Data = Provider.LoadFile(item.ID);
            //    }
            //}
        }

        protected override void OnSave(Document entity, ref string auditnote)
        {
            //if (!Provider.IsRelational())
            //{
            //    byte[] data = entity.Data;
            //    entity.Data = new byte[] { };
            //    base.OnSave(entity);
            //    entity.Data = data;
            //    Provider.SaveFile(entity.ID, data);
            //}
            //else
            base.OnSave(entity, ref auditnote);
        }

        protected override void OnSave(IEnumerable<Document> entities, ref string auditnote)
        {
            foreach (var entity in entities)
                OnSave(entity, ref auditnote);
        }

        protected override void AfterDelete(Document entity)
        {
            base.AfterDelete(entity);
            //if (!Provider.IsRelational())
            //    Provider.DeleteFile(entity.ID);
        }
    }
}