Files
Jan Krivanek e4670b33a1 [PoC] Code testing agent + tests PoC (#433)
* Add code testing agent agents + tests PoC

* Remove AssertionEvaluator.cs change (moved to dev/jankrivanek/agents-evals)
2026-03-30 17:57:08 +02:00

50 lines
1.6 KiB
C#

using ContosoUniversity.Data;
using ContosoUniversity.Models;
using ContosoUniversity.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using System;
namespace ContosoUniversity.Controllers
{
public abstract class BaseController : Controller
{
protected SchoolContext db;
protected NotificationService notificationService = new NotificationService();
public BaseController(SchoolContext context)
{
db = context;
}
protected void SendEntityNotification(string entityType, string entityId, EntityOperation operation)
{
SendEntityNotification(entityType, entityId, null, operation);
}
protected void SendEntityNotification(string entityType, string entityId, string entityDisplayName, EntityOperation operation)
{
try
{
var userName = "System"; // No authentication, use System as default user
notificationService.SendNotification(entityType, entityId, entityDisplayName, operation, userName);
}
catch (Exception ex)
{
// Log the error but don't break the main operation
System.Diagnostics.Debug.WriteLine($"Failed to send notification: {ex.Message}");
}
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
db?.Dispose();
notificationService?.Dispose();
}
base.Dispose(disposing);
}
}
}