2026-01-11 13:11:55 +01:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2026-01-12 15:42:18 +01:00
|
|
|
using PlanTempus.Application.Features.Localization.Services;
|
2026-01-11 13:11:55 +01:00
|
|
|
|
|
|
|
|
namespace PlanTempus.Application.Features.Dashboard.Components;
|
|
|
|
|
|
|
|
|
|
public class BookingListViewComponent : ViewComponent
|
|
|
|
|
{
|
2026-01-12 15:42:18 +01:00
|
|
|
private readonly ILocalizationService _localization;
|
|
|
|
|
|
|
|
|
|
public BookingListViewComponent(ILocalizationService localization)
|
|
|
|
|
{
|
|
|
|
|
_localization = localization;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-11 13:11:55 +01:00
|
|
|
public IViewComponentResult Invoke(string key)
|
|
|
|
|
{
|
2026-01-12 15:42:18 +01:00
|
|
|
var model = BookingListCatalog.Get(key, _localization);
|
2026-01-11 13:11:55 +01:00
|
|
|
return View(model);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class BookingListViewModel
|
|
|
|
|
{
|
|
|
|
|
public required string Key { get; init; }
|
|
|
|
|
public required string Title { get; init; }
|
|
|
|
|
public required string CurrentTime { get; init; }
|
|
|
|
|
public required IReadOnlyList<string> BookingKeys { get; init; }
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-12 15:42:18 +01:00
|
|
|
internal class BookingListData
|
|
|
|
|
{
|
|
|
|
|
public required string Key { get; init; }
|
|
|
|
|
public required string TitleKey { get; init; }
|
|
|
|
|
public required string CurrentTime { get; init; }
|
|
|
|
|
public required IReadOnlyList<string> BookingKeys { get; init; }
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-11 13:11:55 +01:00
|
|
|
public static class BookingListCatalog
|
|
|
|
|
{
|
2026-01-12 15:42:18 +01:00
|
|
|
private static readonly Dictionary<string, BookingListData> Lists = new()
|
2026-01-11 13:11:55 +01:00
|
|
|
{
|
2026-01-12 15:42:18 +01:00
|
|
|
["todays-bookings"] = new BookingListData
|
2026-01-11 13:11:55 +01:00
|
|
|
{
|
|
|
|
|
Key = "todays-bookings",
|
2026-01-12 15:42:18 +01:00
|
|
|
TitleKey = "dashboard.bookings.title",
|
2026-01-11 13:11:55 +01:00
|
|
|
CurrentTime = "10:45",
|
|
|
|
|
BookingKeys = ["booking-1", "booking-2", "booking-3", "booking-4", "booking-5", "booking-6"]
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2026-01-12 15:42:18 +01:00
|
|
|
public static BookingListViewModel Get(string key, ILocalizationService localization)
|
2026-01-11 13:11:55 +01:00
|
|
|
{
|
2026-01-12 15:42:18 +01:00
|
|
|
if (!Lists.TryGetValue(key, out var list))
|
|
|
|
|
throw new KeyNotFoundException($"BookingList with key '{key}' not found");
|
2026-01-11 13:11:55 +01:00
|
|
|
|
2026-01-12 15:42:18 +01:00
|
|
|
return new BookingListViewModel
|
|
|
|
|
{
|
|
|
|
|
Key = list.Key,
|
|
|
|
|
Title = localization.Get(list.TitleKey),
|
|
|
|
|
CurrentTime = list.CurrentTime,
|
|
|
|
|
BookingKeys = list.BookingKeys
|
|
|
|
|
};
|
2026-01-11 13:11:55 +01:00
|
|
|
}
|
|
|
|
|
}
|