initial commit

This commit is contained in:
2026-04-15 15:02:32 +02:00
commit 3bfc79e6d9
1380 changed files with 69684 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.SelfService.Portal.Core.API.Context;
using Microsoft.SelfService.Portal.Core.API.Events.Interfaces;
using Microsoft.SelfService.Portal.Core.API.Helper;
using Microsoft.SelfService.Portal.Core.API.Models;
namespace Microsoft.SelfService.Portal.Core.API.Events
{
public class AbstractEventHandler : IEventHandlerInterface
{
private readonly DataContext _context;
public AbstractEventHandler(DataContext context)
{
_context = context;
new APIHelper();
}
public ICollection<EventModel> GetEvents(string Class, string Method)
{
return _context.Events
.Where(e => e.Class == Class && e.Method == Method)
.Include(r => r.Runbook)
.ToList();
}
public async void FireEvent(string Class, string Method, Guid parameters)
{
var events = GetEvents(Class, Method);
foreach (EventModel @event in events){
APIHelper.SetUrl(@event.RunbookId, @event.RestEndpointOperation);
APIHelper.SetRequestBody(parameters);
var response = await APIHelper.ApiClient.PostAsync(APIHelper.GetUrl(), APIHelper.SetRequestHeaders("application/json;odata=verbose;charset=utf-8"));
if (response.IsSuccessStatusCode)
{
var stringResponse = await response.Content.ReadAsStringAsync();
}
else
{
throw new HttpRequestException(response.ReasonPhrase);
}
}
}
}
}

View File

@@ -0,0 +1,10 @@
using Microsoft.SelfService.Portal.Core.API.Models;
namespace Microsoft.SelfService.Portal.Core.API.Events.Interfaces
{
public interface IEventHandlerInterface
{
ICollection<EventModel> GetEvents(string Class, string Method);
void FireEvent(string Class, string Method, Guid parameters);
}
}