mirror of
https://github.com/dotnet/skills.git
synced 2026-09-20 09:49:54 +08:00
e4670b33a1
* Add code testing agent agents + tests PoC * Remove AssertionEvaluator.cs change (moved to dev/jankrivanek/agents-evals)
50 lines
1.6 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|