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)
72 lines
2.2 KiB
C#
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();
|
|
}
|
|
}
|
|
}
|