-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMessagesController.cs
More file actions
77 lines (66 loc) · 2.52 KB
/
MessagesController.cs
File metadata and controls
77 lines (66 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// <copyright file="MessagesController.cs" company="Michael Silver">
// Copyright (c) Michael Silver. All rights reserved.
// </copyright>
using Microsoft.AspNetCore.Mvc;
using Procession.AdminWeb.Models;
using Procession.AdminWeb.Services;
namespace Procession.AdminWeb.Controllers;
/// <summary>
/// Controller for message management and viewing.
/// </summary>
public class MessagesController : Controller
{
private readonly AdminService adminService;
/// <summary>
/// Initializes a new instance of the <see cref="MessagesController"/> class.
/// </summary>
/// <param name="adminService">The admin service.</param>
public MessagesController(AdminService adminService)
{
this.adminService = adminService;
}
/// <summary>
/// Shows paginated list of messages with filtering options.
/// </summary>
/// <param name="page">Page number (1-based).</param>
/// <param name="queueId">Optional queue ID filter.</param>
/// <param name="processedOnly">Optional processed state filter.</param>
/// <returns>Message list view.</returns>
public async Task<IActionResult> Index(int page = 1, long? queueId = null, bool? processedOnly = null)
{
const int pageSize = 50;
var model = new MessageListViewModel
{
CurrentPage = page,
PageSize = pageSize,
SelectedQueueId = queueId,
ProcessedOnly = processedOnly,
Messages = await this.adminService.GetMessagesAsync(page, pageSize, queueId, processedOnly),
TotalCount = await this.adminService.GetMessageCountAsync(queueId, processedOnly),
AvailableQueues = await this.adminService.GetAllQueuesAsync()
};
return this.View(model);
}
/// <summary>
/// Shows detailed information for a specific message.
/// </summary>
/// <param name="id">The message ID.</param>
/// <param name="showPayload">Whether to show the payload content.</param>
/// <returns>Message detail view.</returns>
public async Task<IActionResult> Details(long id, bool showPayload = false)
{
var message = await this.adminService.GetMessageByIdAsync(id);
if (message == null)
{
return this.NotFound();
}
var queue = await this.adminService.GetQueueByIdAsync(message.QueueId);
var model = new MessageDetailViewModel
{
Message = message,
Queue = queue,
ShowPayload = showPayload
};
return this.View(model);
}
}