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

72 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
using ContosoUniversity.Data;
using ContosoUniversity.Services;
using ContosoUniversity.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
namespace ContosoUniversity.Controllers
{
public class NotificationsController : BaseController
{
public NotificationsController(SchoolContext context) : base(context)
{
}
// GET: api/notifications - Get pending notifications for admin
[HttpGet]
public JsonResult GetNotifications()
{
var notifications = new List<Notification>();
try
{
// Read all available notifications from the queue
Notification notification;
while ((notification = notificationService.ReceiveNotification()) != null)
{
notifications.Add(notification);
// Limit to prevent overwhelming the UI
if (notifications.Count >= 10)
break;
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"Error retrieving notifications: {ex.Message}");
return Json(new { success = false, message = "Error retrieving notifications" });
}
return Json(new {
success = true,
notifications,
count = notifications.Count
});
}
// POST: api/notifications/mark-read
[HttpPost]
public JsonResult MarkAsRead(int id)
{
try
{
notificationService.MarkAsRead(id);
return Json(new { success = true });
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"Error marking notification as read: {ex.Message}");
return Json(new { success = false, message = "Error updating notification" });
}
}
// GET: Notifications/Index - Admin notification dashboard
public ActionResult Index()
{
return View();
}
}
}