Refactor DocumentController for clarity and updates

Updated the DocumentController to use new namespace for constants and added a directive for domain entities. Marked the constructor as obsolete for future MediatR implementation. Refactored Get and Open methods to enhance readability by simplifying error handling. Maintained authorization attributes in their original positions.
This commit is contained in:
tekh 2025-06-27 10:26:56 +02:00
parent 2a4255e5a3
commit 08601adc49

View File

@ -3,19 +3,22 @@ using EnvelopeGenerator.CommonServices;
using EnvelopeGenerator.Web.Services; using EnvelopeGenerator.Web.Services;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using EnvelopeGenerator.Extensions; using EnvelopeGenerator.Extensions;
using static EnvelopeGenerator.CommonServices.Constants;
using EnvelopeGenerator.Application.Contracts.Services; using EnvelopeGenerator.Application.Contracts.Services;
using static EnvelopeGenerator.Domain.Constants;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Web.Controllers namespace EnvelopeGenerator.Web.Controllers;
[Authorize(Roles = ReceiverRole.FullyAuth)]
[Route("api/[controller]")]
public class DocumentController : BaseController
{ {
[Authorize(Roles = ReceiverRole.FullyAuth)]
[Route("api/[controller]")]
public class DocumentController : BaseController
{
private readonly EnvelopeOldService envelopeService; private readonly EnvelopeOldService envelopeService;
private readonly ActionService? actionService; private readonly ActionService? actionService;
[Obsolete("Use MediatR")]
private readonly IEnvelopeDocumentService _envDocService; private readonly IEnvelopeDocumentService _envDocService;
[Obsolete("Use MediatR")]
public DocumentController(DatabaseService database, EnvelopeOldService envelope, IEnvelopeDocumentService envDocService, ILogger<DocumentController> logger) : base(database, logger) public DocumentController(DatabaseService database, EnvelopeOldService envelope, IEnvelopeDocumentService envDocService, ILogger<DocumentController> logger) : base(database, logger)
{ {
envelopeService = envelope; envelopeService = envelope;
@ -73,6 +76,4 @@ namespace EnvelopeGenerator.Web.Controllers
return StatusCode(StatusCodes.Status500InternalServerError); return StatusCode(StatusCodes.Status500InternalServerError);
} }
} }
}
} }