42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
|
|
using Microsoft.AspNetCore.Mvc;
|
||
|
|
using PlanTempus.Application.Features.Localization.Services;
|
||
|
|
|
||
|
|
namespace PlanTempus.Application.Features.Services.Components;
|
||
|
|
|
||
|
|
public class ServiceDetailAddonsViewComponent : ViewComponent
|
||
|
|
{
|
||
|
|
private readonly ILocalizationService _localization;
|
||
|
|
|
||
|
|
public ServiceDetailAddonsViewComponent(ILocalizationService localization)
|
||
|
|
{
|
||
|
|
_localization = localization;
|
||
|
|
}
|
||
|
|
|
||
|
|
public IViewComponentResult Invoke(string key)
|
||
|
|
{
|
||
|
|
var service = ServiceDetailCatalog.Get(key);
|
||
|
|
|
||
|
|
var model = new ServiceDetailAddonsViewModel
|
||
|
|
{
|
||
|
|
// Data
|
||
|
|
Addons = service.Addons,
|
||
|
|
|
||
|
|
// Labels
|
||
|
|
LabelAddonsForService = _localization.Get("services.detail.addons.addonsForService"),
|
||
|
|
LabelAddExistingAddon = _localization.Get("services.detail.addons.addExistingAddon")
|
||
|
|
};
|
||
|
|
|
||
|
|
return View(model);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public class ServiceDetailAddonsViewModel
|
||
|
|
{
|
||
|
|
// Data
|
||
|
|
public required List<ServiceAddon> Addons { get; init; }
|
||
|
|
|
||
|
|
// Labels
|
||
|
|
public required string LabelAddonsForService { get; init; }
|
||
|
|
public required string LabelAddExistingAddon { get; init; }
|
||
|
|
}
|