using LEA.Models;
using Microsoft.AspNetCore.Mvc.Rendering;

namespace LEA.ViewModels;

public class ApplicationListViewModel
{
    public IEnumerable<Application> Applications { get; set; } = new List<Application>();

    public string? SearchTerm { get; set; }

    public ApplicationStatus? StatusFilter { get; set; }

    public IEnumerable<SelectListItem> StatusOptions { get; set; } = new List<SelectListItem>();

    public IDictionary<ApplicationStatus, int> StatusCounts { get; set; } = new Dictionary<ApplicationStatus, int>();

    public int TotalApplications { get; set; }

    public int AppliedCount => GetCount(ApplicationStatus.Applied);

    public int InterviewCount => GetCount(ApplicationStatus.Interview);

    public int OfferCount => GetCount(ApplicationStatus.Offer);

    public int RejectedCount => GetCount(ApplicationStatus.Rejected);

    private int GetCount(ApplicationStatus status)
        => StatusCounts.TryGetValue(status, out var count) ? count : 0;
}
