using Elwig.Models.Dtos;
using System.Collections.Generic;
using System.Linq;

namespace Elwig.Documents {
    public class MemberList : Document {

        public new static string Name => "Mitgliederliste";

        public string Filter;
        public IEnumerable<MemberListRow> Members;

        public string[] AreaComFilters;
        public bool FilterAreaComs => AreaComFilters.Length > 0;

        public MemberList(string filter, IEnumerable<MemberListRow> members) : base(Name) {
            Filter = filter;
            Members = members;
            AreaComFilters = [..members
                .SelectMany(m => m.AreaCommitmentsFiltered)
                .Select(c => c.VtrgId)
                .Distinct()
                .Order()];
        }

        public MemberList(string filter, MemberListData data) :
            this(filter, data.Rows) {
        }
    }
}
