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

namespace Expedience.Web.Pages
{
    public class RecordsModel(IApiService apiService) : PageModel
    {
		public List<DutyCompletionResult> Results { get; set; }
		public string Mode { get; set; }

		public async Task OnGet(string recordType, int territoryId, CancellationToken cancellationToken)
		{
			var recordTypeNum = 0;

			if (recordType == "normal")
			{
				Mode = "Normal";
				recordTypeNum = 1;
			}
			else if (recordType == "solo")
			{
				Mode = "Solo";
				recordTypeNum = 2;
			}
			else if (recordType == "mine")
			{
				Mode = "MINE";
				recordTypeNum = 3;
			}
			else if (recordType == "npc")
			{
				Mode = "NPC Assisted";
				recordTypeNum = 4;
			}
			else if (recordType == "unsync")
			{
				Mode = "Unsynched";
				recordTypeNum = 5;
			}
			else
				throw new Exception($"Record Type {recordType} not found");

            Results = await apiService.GetTopXRecords(recordTypeNum, territoryId, 10, cancellationToken);


        }
	}
}
