Implement Backend API Core (Phase 1)
Complete API layer with Clean Architecture:
- Application DTOs (proposals, line items, customers, users, files, audit, dashboard)
- Service interfaces (IProposalService, ILineItemService, ICustomerService, IAuditService, IS3Service, IJobPublisher)
- FluentValidation validators for all create requests
- Infrastructure service implementations (ProposalService, LineItemService, CustomerService, AuditService, S3Service, SqsJobPublisher, ProposalNumberGenerator)
- Secrets Manager connection string resolver for RDS
- API controllers: Proposals (CRUD + approve/send/revise), LineItems (CRUD + bulk), Customers, Users, Files (presigned upload/download), Admin (dashboard)
- Middleware: GlobalExceptionHandler (ProblemDetails), ValidationFilter (FluentValidation pipeline)
- CurrentUserService (Cognito JWT claims -> User entity, auto-provisioning)
- Full DI configuration in Program.cs with Lambda hosting
- Role-based authorization (dispatchers, admins, sysadmins)
- CORS configured for proposals.seahaven.com + localhost
2026-05-16 18:49:48 -04:00
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using ProposalSystem.Application.DTOs;
|
|
|
|
|
using ProposalSystem.Domain.Entities;
|
|
|
|
|
using ProposalSystem.Infrastructure.Data;
|
|
|
|
|
|
|
|
|
|
namespace ProposalSystem.Api.Controllers;
|
|
|
|
|
|
|
|
|
|
[ApiController]
|
|
|
|
|
[Route("api/admin")]
|
|
|
|
|
[Authorize(Roles = "admins,sysadmins")]
|
|
|
|
|
public class AdminController : ControllerBase
|
|
|
|
|
{
|
|
|
|
|
private readonly ProposalDbContext _db;
|
|
|
|
|
|
|
|
|
|
public AdminController(ProposalDbContext db)
|
|
|
|
|
{
|
|
|
|
|
_db = db;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet("dashboard")]
|
|
|
|
|
public async Task<ActionResult<DashboardResponse>> GetDashboard(CancellationToken ct)
|
|
|
|
|
{
|
|
|
|
|
var pendingCount = await _db.Proposals
|
|
|
|
|
.CountAsync(p => p.Status == ProposalStatus.InReview, ct);
|
|
|
|
|
|
|
|
|
|
var weekStart = DateTime.UtcNow.AddDays(-7);
|
|
|
|
|
var approvedThisWeek = await _db.Proposals
|
|
|
|
|
.CountAsync(p => p.ApprovedAt >= weekStart, ct);
|
|
|
|
|
|
2026-05-20 18:08:50 -04:00
|
|
|
var approvedTimes = await _db.Proposals
|
Implement Backend API Core (Phase 1)
Complete API layer with Clean Architecture:
- Application DTOs (proposals, line items, customers, users, files, audit, dashboard)
- Service interfaces (IProposalService, ILineItemService, ICustomerService, IAuditService, IS3Service, IJobPublisher)
- FluentValidation validators for all create requests
- Infrastructure service implementations (ProposalService, LineItemService, CustomerService, AuditService, S3Service, SqsJobPublisher, ProposalNumberGenerator)
- Secrets Manager connection string resolver for RDS
- API controllers: Proposals (CRUD + approve/send/revise), LineItems (CRUD + bulk), Customers, Users, Files (presigned upload/download), Admin (dashboard)
- Middleware: GlobalExceptionHandler (ProblemDetails), ValidationFilter (FluentValidation pipeline)
- CurrentUserService (Cognito JWT claims -> User entity, auto-provisioning)
- Full DI configuration in Program.cs with Lambda hosting
- Role-based authorization (dispatchers, admins, sysadmins)
- CORS configured for proposals.seahaven.com + localhost
2026-05-16 18:49:48 -04:00
|
|
|
.Where(p => p.ApprovedAt.HasValue)
|
2026-05-20 18:08:50 -04:00
|
|
|
.Select(p => new { p.ApprovedAt, p.SubmittedAt })
|
|
|
|
|
.ToListAsync(ct);
|
|
|
|
|
|
|
|
|
|
var avgTurnaround = approvedTimes.Count > 0
|
|
|
|
|
? approvedTimes.Average(p => (p.ApprovedAt!.Value - p.SubmittedAt).TotalHours)
|
|
|
|
|
: 0;
|
Implement Backend API Core (Phase 1)
Complete API layer with Clean Architecture:
- Application DTOs (proposals, line items, customers, users, files, audit, dashboard)
- Service interfaces (IProposalService, ILineItemService, ICustomerService, IAuditService, IS3Service, IJobPublisher)
- FluentValidation validators for all create requests
- Infrastructure service implementations (ProposalService, LineItemService, CustomerService, AuditService, S3Service, SqsJobPublisher, ProposalNumberGenerator)
- Secrets Manager connection string resolver for RDS
- API controllers: Proposals (CRUD + approve/send/revise), LineItems (CRUD + bulk), Customers, Users, Files (presigned upload/download), Admin (dashboard)
- Middleware: GlobalExceptionHandler (ProblemDetails), ValidationFilter (FluentValidation pipeline)
- CurrentUserService (Cognito JWT claims -> User entity, auto-provisioning)
- Full DI configuration in Program.cs with Lambda hosting
- Role-based authorization (dispatchers, admins, sysadmins)
- CORS configured for proposals.seahaven.com + localhost
2026-05-16 18:49:48 -04:00
|
|
|
|
|
|
|
|
var totalProposals = await _db.Proposals.CountAsync(ct);
|
|
|
|
|
|
|
|
|
|
return Ok(new DashboardResponse(pendingCount, approvedThisWeek, avgTurnaround, totalProposals));
|
|
|
|
|
}
|
|
|
|
|
}
|