Adding
This commit is contained in:
+65
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using LCU.API.Collections.RepoApi.Configuration;
|
||||
using LCU.API.Collections.RepoApi.Extensions;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Serilog;
|
||||
using LCU.API.Collections.RepoApi.HostedServices;
|
||||
using LCU.API.Collections.RepoApi.Models.Requests;
|
||||
using LCU.Shared.Collections.RepoApiLib.Models.Producer;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.FeatureManagement.Mvc;
|
||||
|
||||
namespace LCU.API.Collections.RepoApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[FeatureGate(FeatureFlags.EnableControllers)]
|
||||
public class QueueController : RepoControllerBase
|
||||
{
|
||||
private readonly IRepoQueueProducerService _repoQueueProducer;
|
||||
|
||||
public QueueController(IRepoQueueProducerService producerService, IHttpContextAccessor httpContextAccessor) :
|
||||
base(httpContextAccessor)
|
||||
{
|
||||
_repoQueueProducer = producerService;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ProducesResponseType(200)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||
public IActionResult PutSingleAccountOnQueue([FromBody] AccountQueueRequest queueRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var currentUser = CreateUserFromAuth();
|
||||
|
||||
var request = new ProcessingItem()
|
||||
{
|
||||
AccountNo = queueRequest.AccountNo,
|
||||
CaseId = queueRequest.CaseId,
|
||||
QueuedBy = currentUser.Email
|
||||
};
|
||||
|
||||
_repoQueueProducer.SendRequestToQueue(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode((int) System.Net.HttpStatusCode.InternalServerError,
|
||||
$"A server error occured, and your request could not be complete");
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user