using InABox.Core;
using InABox.Core.Reports;

namespace InABox.Database
{
    public class DigitalFormStore : Store<DigitalForm>
    {
        protected override void AfterDelete(DigitalForm entity)
        {
            base.AfterDelete(entity);
            var templates = Provider.Query(
                new Filter<ReportTemplate>(x => x.DataModel).IsEqualTo("Digital Form Reports")
                    .And(x => x.Section).IsEqualTo(entity.ID.ToString()),
                Columns.None<ReportTemplate>().Add(c => c.ID)
            ).Rows.Select(x => x.ToObject<ReportTemplate>());
            Provider.Delete(templates, UserID);
        }
    }
}