using Elwig.Helpers;
using Elwig.Models.Dtos;
using Elwig.Models.Entities;
using System;
using System.Collections.Generic;

namespace Elwig.Documents {
    public class DeliveryConfirmation : BusinessDocument {

        public new static string Name => "Anlieferungsbestätigung";

        public Season Season;
        public DeliveryConfirmationDeliveryData Data;
        public string? Text = App.Client.TextDeliveryConfirmation;
        public Dictionary<string, MemberBucket> MemberBuckets;
        public List<MemberStat> MemberStats;

        public DeliveryConfirmation(AppDbContext ctx, int year, Member m, DeliveryConfirmationDeliveryData data) :
            base($"{Name} {year}", m) {
            Season = ctx.Seasons.Find(year) ?? throw new ArgumentException("invalid season");
            ShowDateAndLocation = true;
            UseBillingAddress = true;
            DocumentId = $"Anl.-Best. {Season.Year}/{m.MgNr}";
            Data = data;
            MemberBuckets = ctx.GetMemberBuckets(Season.Year, m.MgNr).GetAwaiter().GetResult();
            MemberStats = AppDbContext.GetMemberStats(Season.Year, m.MgNr).GetAwaiter().GetResult();
        }
    }
}
