using System;
using Expedience.Infrastructure.Models;
using Expedience.Web.Services;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace Expedience.Web.Pages
{
    public class IndexModel : PageModel
    {
        private readonly IApiService _apiService;

        public List<DutyCompletionRecord>? DutyCompletionRecords { get; private set; }
		public List<DeepDungeonRecord>? DeepDungeonRecords { get; private set; }

		public IndexModel(IApiService apiService)
        {
            _apiService = apiService;
        }

        public async Task OnGet(string? expac, CancellationToken cancellationToken)
        {
            if (expac == null) expac = "EW";

            if (expac == "DeepDungeons")
            {
                DutyCompletionRecords = null;
                DeepDungeonRecords = await _apiService.GetDeepDungeonRecordsAsync(cancellationToken);
			}
            else
            {
                DutyCompletionRecords = await _apiService.GetDutyCompletionRecordsAsync(expac, cancellationToken);
				DeepDungeonRecords = null;
			}
            
        }
	}
}