This commit is contained in:
Janus C. H. Knudsen 2026-01-10 20:39:17 +01:00
parent 54b057886c
commit 7fc1ae0650
204 changed files with 4345 additions and 134 deletions

View file

@ -0,0 +1,43 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.ApplicationInsights;
namespace PlanTempus.Application.Components
{
public class OrganizationViewComponent : ApiViewComponentBase
{
private readonly TelemetryClient _telemetry;
public OrganizationViewComponent(
IHttpClientFactory httpClientFactory,
TelemetryClient telemetry)
: base(httpClientFactory, telemetry)
{
_telemetry = telemetry;
}
public async Task<IViewComponentResult> InvokeAsync(int organizationId, bool showDetailedView = true)
{
_telemetry.TrackEvent($"{GetType().Name}Invoked", new Dictionary<string, string>
{
["OrganizationId"] = organizationId.ToString(),
["ShowDetailedView"] = showDetailedView.ToString()
});
var organization = await GetJObjectFromApiAsync($"/api/organization/get/{organizationId}");
if (organization == null)
return HandleError("Organization not found");
ViewBag.ShowDetailedView = showDetailedView;
_telemetry.TrackEvent("Viewed", new Dictionary<string, string>
{
["OrganizationId"] = organizationId.ToString(),
["Name"] = organization["name"]?.ToString()
});
return View(organization);
}
}
}