Adding
This commit is contained in:
+242
@@ -0,0 +1,242 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.API.Collections.RepoApi.Configuration;
|
||||
using LCU.API.Collections.RepoApi.Exceptions;
|
||||
using LCU.API.Collections.RepoApi.Extensions;
|
||||
using LCU.API.Collections.RepoApi.Models.Filters;
|
||||
using LCU.API.Collections.RepoApi.Models.Requests;
|
||||
using LCU.API.Collections.RepoApi.Models.Responses;
|
||||
using LCU.API.Collections.RepoApi.Services;
|
||||
using LCU.Shared.Collections.RepoApiLib.Exceptions;
|
||||
using LCU.Shared.Collections.RepoApiLib.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.FeatureManagement.Mvc;
|
||||
using Serilog;
|
||||
|
||||
namespace LCU.API.Collections.RepoApi.Controllers
|
||||
{
|
||||
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[FeatureGate(FeatureFlags.EnableControllers)]
|
||||
public class AuctionAssignmentController : RepoControllerBase
|
||||
{
|
||||
private readonly IAuctionAssignmentService _auctionAssignmentService;
|
||||
private readonly IFloorPricingService _floorPricingService;
|
||||
|
||||
public AuctionAssignmentController(
|
||||
IAuctionAssignmentService auctionAssignmentService,
|
||||
IFloorPricingService floorPricingService,
|
||||
IHttpContextAccessor httpContextAccessor) :
|
||||
base(httpContextAccessor)
|
||||
{
|
||||
_auctionAssignmentService = auctionAssignmentService;
|
||||
_floorPricingService = floorPricingService;
|
||||
}
|
||||
|
||||
// GET: api/AuctionAssignment
|
||||
[HttpGet(Name = "GetAllAuctionAssignments")]
|
||||
[ProducesResponseType(typeof(PagedResponse<AuctionAssignment>), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Get([FromQuery] AuctionAssignmentFilter filter)
|
||||
{
|
||||
try
|
||||
{
|
||||
var searchResult = await _auctionAssignmentService.ListByFilterAsync(filter);
|
||||
var result = new PagedResponse<AuctionAssignment>(searchResult, filter, this.Url, Request);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/AuctionAssignment/5
|
||||
[HttpGet("{id}", Name = "GetAuctionAssignmentById")]
|
||||
[ProducesResponseType(typeof(AuctionAssignment), 200)]
|
||||
[ProducesResponseType(typeof(string), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetById(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id <= 0)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var result = await _auctionAssignmentService.GetByIdAsync(id);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// Get: api/AuctionAssignment/repoId/7
|
||||
[HttpGet("repoId/{repoId}", Name = "GetAuctionAssignmentsByRepoId")]
|
||||
[ProducesResponseType(typeof(IEnumerable<AuctionAssignment>), 200)]
|
||||
[ProducesResponseType(typeof(string), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetByRepoId(int repoId)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (repoId <= 0)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var result = await _auctionAssignmentService.GetByRepoIdAsync(repoId);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/AuctionAssignment/5/FloorPrice
|
||||
[HttpGet("{id}/FloorPrice", Name = "GetAuctionAssignmentFloorPriceById")]
|
||||
[ProducesResponseType(typeof(FloorPriceCalculationResultSet), 200)]
|
||||
[ProducesResponseType(typeof(string), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public IActionResult GetAuctionAssignmentFloorPriceById(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id <= 0)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var result = _floorPricingService.DetermineFloorPrice(id);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
Log.Error(nfe, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/AuctionAssignment
|
||||
[HttpPost]
|
||||
[ProducesResponseType(typeof(AuctionAssignmentPostRequest), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Post([FromBody] AuctionAssignmentPostRequest auctionAssignmentPostRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _auctionAssignmentService.SaveAsync(auctionAssignmentPostRequest);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (WebException we)
|
||||
{
|
||||
Log.Error(we, $"Failure in {this.GetType().Name} at [AuctionAssignmentPostRequest]");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, we.Message);
|
||||
}
|
||||
catch (DuplicateResourceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status409Conflict, "An active auction assignment already exists. You must remove the auction before creating a new one.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, "Failed to add auction to AutoIMS.");
|
||||
}
|
||||
}
|
||||
|
||||
// PUT: api/AuctionAssignment/5
|
||||
[HttpPut("{id}")]
|
||||
[ProducesResponseType(typeof(AuctionAssignment), 200)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Put(int id, [FromBody] AuctionAssignment auctionAssignment)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
if (id <= 0 || id != auctionAssignment.ID)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var result = await _auctionAssignmentService.UpdateAsync(auctionAssignment);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
Log.Error(nfe, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// DELETE: api/ApiWithActions/5
|
||||
[HttpDelete("{id}")]
|
||||
[ProducesResponseType(typeof(AuctionAssignment), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Delete(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id <= 0)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var deletedRepoCompany = await _auctionAssignmentService.RemoveAuction(id);
|
||||
return Ok(deletedRepoCompany);
|
||||
}
|
||||
catch (WebException we)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, we.Message);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, "Failed to remove auction from AutoIMS.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.API.Collections.RepoApi.Configuration;
|
||||
using LCU.API.Collections.RepoApi.Exceptions;
|
||||
using LCU.API.Collections.RepoApi.Extensions;
|
||||
using LCU.API.Collections.RepoApi.Services;
|
||||
using LCU.Shared.Collections.RepoApiLib.Models;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.FeatureManagement.Mvc;
|
||||
using Serilog;
|
||||
|
||||
namespace LCU.API.Collections.RepoApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[FeatureGate(FeatureFlags.EnableControllers)]
|
||||
public class AuctionHouseController : RepoControllerBase
|
||||
{
|
||||
private readonly IAuctionHouseService _auctionHouseService;
|
||||
|
||||
public AuctionHouseController(
|
||||
IAuctionHouseService auctionHouseService,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
: base( httpContextAccessor)
|
||||
{
|
||||
_auctionHouseService = auctionHouseService;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetAllAuctionHouses")]
|
||||
[ProducesResponseType(typeof(IEnumerable<AuctionHouse>), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Get()
|
||||
{
|
||||
try
|
||||
{
|
||||
var auctions = await _auctionHouseService.ListAllAsync();
|
||||
return Ok(auctions);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("{id}", Name = "GetAuctionHouseById")]
|
||||
[ProducesResponseType(typeof(AuctionHouse), 200)]
|
||||
[ProducesResponseType(typeof(string), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetById(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var auction = await _auctionHouseService.GetAsync(id);
|
||||
return Ok(auction);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ProducesResponseType(typeof(AuctionHouse), 200)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "Admin")]
|
||||
public async Task<IActionResult> Post([FromBody] AuctionHouse auction)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var newAuction = await _auctionHouseService.SaveAsync(auction);
|
||||
return Ok(newAuction);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
[ProducesResponseType(typeof(AuctionHouse), 200)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "Admin")]
|
||||
public async Task<IActionResult> Put(string id, [FromBody] AuctionHouse auction)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
if (id != auction.AuctionID)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var updatedAuction = await _auctionHouseService.UpdateAsync(auction);
|
||||
return Ok(updatedAuction);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
[ProducesResponseType(typeof(AuctionHouse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "Admin")]
|
||||
public async Task<IActionResult> Delete(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var deletedAuction = await _auctionHouseService.DeleteAsync(id);
|
||||
return Ok(deletedAuction);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.API.Collections.RepoApi.Configuration;
|
||||
using LCU.API.Collections.RepoApi.Exceptions;
|
||||
using LCU.API.Collections.RepoApi.Extensions;
|
||||
using LCU.API.Collections.RepoApi.Models.Filters;
|
||||
using LCU.API.Collections.RepoApi.Models.Responses;
|
||||
using LCU.API.Collections.RepoApi.Services;
|
||||
using LCU.Shared.Collections.RepoApiLib.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.FeatureManagement.Mvc;
|
||||
using Serilog;
|
||||
|
||||
namespace LCU.API.Collections.RepoApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[FeatureGate(FeatureFlags.EnableControllers)]
|
||||
public class AuditRecordController : RepoControllerBase
|
||||
{
|
||||
private readonly IAuditRecordService _auditRecordService;
|
||||
|
||||
public AuditRecordController(
|
||||
IAuditRecordService repoAccountService,
|
||||
IHttpContextAccessor httpContextAccessor) : base(httpContextAccessor)
|
||||
{
|
||||
_auditRecordService = repoAccountService;
|
||||
}
|
||||
|
||||
// GET: api/AuditRecord
|
||||
[HttpGet(Name = "GetAllAuditRecords")]
|
||||
[ProducesResponseType(typeof(PagedResponse<AuditRecord>), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Get([FromQuery] PageFilter filter)
|
||||
{
|
||||
try
|
||||
{
|
||||
var searchResult = await _auditRecordService.ListAll(filter);
|
||||
var result = new PagedResponse<AuditRecord>(searchResult, filter, Url, Request);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/AuditRecord/5
|
||||
[HttpGet("{id}", Name = "GetAuditRecordById")]
|
||||
[ProducesResponseType(typeof(RepoAccount), 200)]
|
||||
[ProducesResponseType(typeof(string), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetById(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id <= 0)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var result = await _auditRecordService.Get(id);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/RepoAccount
|
||||
[HttpPost]
|
||||
[ProducesResponseType(typeof(RepoAccount), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Post([FromBody] AuditRecord repoAccount)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _auditRecordService.SaveAsync(repoAccount);
|
||||
return Ok( result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.API.Collections.RepoApi.Configuration;
|
||||
using LCU.API.Collections.RepoApi.Exceptions;
|
||||
using LCU.API.Collections.RepoApi.Extensions;
|
||||
using LCU.API.Collections.RepoApi.Services;
|
||||
using LCU.Shared.Collections.RepoApiLib.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.FeatureManagement.Mvc;
|
||||
using Serilog;
|
||||
|
||||
namespace LCU.API.Collections.RepoApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[FeatureGate(FeatureFlags.EnableControllers)]
|
||||
public class CollateralController : RepoControllerBase
|
||||
{
|
||||
private readonly ICollateralService _collateralService;
|
||||
|
||||
public CollateralController(
|
||||
ICollateralService collateralService,
|
||||
IHttpContextAccessor httpContextAccessor) :
|
||||
base(httpContextAccessor)
|
||||
{
|
||||
_collateralService = collateralService;
|
||||
}
|
||||
|
||||
// GET: api/Collateral
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(IEnumerable<Collateral>), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Get()
|
||||
{
|
||||
try
|
||||
{
|
||||
var results = await _collateralService.ListAll();
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/Collateral/5
|
||||
[HttpGet("{id}", Name = "GetCollateralById")]
|
||||
[ProducesResponseType(typeof(Collateral), 200)]
|
||||
[ProducesResponseType(typeof(string), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetById(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id <= 0)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var result = await _collateralService.Get(id);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/Collateral
|
||||
[HttpPost]
|
||||
[ProducesResponseType(typeof(Collateral), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Post([FromBody] Collateral collateral)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _collateralService.SaveAsync(collateral);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// PUT: api/Collateral/5
|
||||
[HttpPut("{id}")]
|
||||
[ProducesResponseType(typeof(Collateral), 200)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Put(int id, [FromBody] Collateral collateral)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id <= 0 || id != collateral.CollateralId)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var result = await _collateralService.UpdateAsync(collateral);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+252
@@ -0,0 +1,252 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.API.Collections.RepoApi.Configuration;
|
||||
using LCU.API.Collections.RepoApi.Exceptions;
|
||||
using LCU.API.Collections.RepoApi.Extensions;
|
||||
using LCU.API.Collections.RepoApi.Services;
|
||||
using LCU.Shared.Collections.RepoApiLib.Exceptions;
|
||||
using LCU.Shared.Collections.RepoApiLib.Models;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.FeatureManagement.Mvc;
|
||||
using Serilog;
|
||||
|
||||
namespace LCU.API.Collections.RepoApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[FeatureGate(FeatureFlags.EnableControllers)]
|
||||
public class EventAlertController : RepoControllerBase
|
||||
{
|
||||
private readonly IEventAlertService _eventAlertService;
|
||||
private readonly IRepoAccountService _repoAccountService;
|
||||
|
||||
public EventAlertController(
|
||||
IEventAlertService eventAlertService,
|
||||
IRepoAccountService repoAccountService,
|
||||
IHttpContextAccessor httpContextAccessor) : base(httpContextAccessor)
|
||||
{
|
||||
_eventAlertService = eventAlertService;
|
||||
_repoAccountService = repoAccountService;
|
||||
}
|
||||
|
||||
// GET: api/EventAlert
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(IEnumerable<EventAlert>), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Get(bool unreadOnly = false, bool actionNeeded = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (unreadOnly)
|
||||
{
|
||||
var unread = await _eventAlertService.ListUnread();
|
||||
return Ok(unread);
|
||||
}
|
||||
|
||||
if (actionNeeded)
|
||||
{
|
||||
var needed = await _eventAlertService.ListActionNeeded();
|
||||
return Ok(needed);
|
||||
}
|
||||
|
||||
var results = await _eventAlertService.ListAll();
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {this.GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/EventAlert/5
|
||||
[HttpGet("{id}", Name = "GetEventAlertById")]
|
||||
[ProducesResponseType(typeof(EventAlert), 200)]
|
||||
[ProducesResponseType(typeof(string), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetById(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id <= 0)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var result = await _eventAlertService.Get(id);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {this.GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/EventAlert/
|
||||
[HttpGet]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(typeof(EventAlert), 200)]
|
||||
[ProducesResponseType(typeof(string), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetWithinDateRange(DateTime start, DateTime end)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (start == null || end == null || end < start)
|
||||
{
|
||||
return BadRequest("Invalid dates");
|
||||
}
|
||||
|
||||
var result = await _eventAlertService.ListWithinDateRange(start, end);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {this.GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/EventAlert
|
||||
[HttpPost]
|
||||
[ProducesResponseType(typeof(EventAlert), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Post([FromBody] EventAlert eventAlert)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _eventAlertService.SaveAsync(eventAlert);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (DuplicateResourceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status409Conflict, "A Duplicate Event Alert already exists.");
|
||||
}
|
||||
catch (UnwantedStatusException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status409Conflict, $"Status of Repo: Reposession ID: {eventAlert.RepoId} is Cancelled or Redeemed. Event Alert not created.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {this.GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/EventAlert/ByAuctionAssignmentId/:AuctionAssignmentId
|
||||
[HttpPost("ByAuctionAssignmentId/{auctionAssignmentId}")]
|
||||
[ProducesResponseType(typeof(EventAlert), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> CreateByAuctionAssignmentId(int auctionAssignmentId,
|
||||
[FromBody] EventAlert eventAlert)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var repo = await _repoAccountService.FindByAuctionAssignmentId(auctionAssignmentId);
|
||||
if (repo == null)
|
||||
{
|
||||
return BadRequest("Repo Account Not Found For Auction Assignment");
|
||||
}
|
||||
|
||||
eventAlert.RepoId = repo.RepoId;
|
||||
eventAlert.AccountNo = repo.AccountNo;
|
||||
var result = await _eventAlertService.SaveAsync(eventAlert);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {this.GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// PUT: api/EventAlert/5
|
||||
[HttpPut("{id}")]
|
||||
[ProducesResponseType(typeof(EventAlert), 200)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||
public async Task<IActionResult> Put(int id, [FromBody] EventAlert eventAlert)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id <= 0 || id != eventAlert.Id)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var currentUser = CreateUserFromAuth();
|
||||
|
||||
var result = await _eventAlertService.UpdateAsync(eventAlert, currentUser);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {this.GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// DELETE: api/ApiWithActions/5
|
||||
[HttpDelete("{id}")]
|
||||
[ProducesResponseType(typeof(EventAlert), 200)]
|
||||
[ProducesResponseType(typeof(string), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Delete(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id <= 0)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var result = await _eventAlertService.DeleteAsync(id);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {this.GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+264
@@ -0,0 +1,264 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.API.Collections.RepoApi.Configuration;
|
||||
using LCU.API.Collections.RepoApi.Models.Responses;
|
||||
using LCU.API.Collections.RepoApi.Services;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.FeatureManagement.Mvc;
|
||||
using Serilog;
|
||||
|
||||
namespace LCU.API.Collections.RepoApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[FeatureGate(FeatureFlags.EnableControllers)]
|
||||
public class FactoidController : RepoControllerBase
|
||||
{
|
||||
private readonly IFactoidService _factoidService;
|
||||
|
||||
public FactoidController(IHttpContextAccessor httpContextAccessor,
|
||||
IFactoidService factoidService) :
|
||||
base(httpContextAccessor)
|
||||
{
|
||||
_factoidService = factoidService;
|
||||
}
|
||||
|
||||
// GET: api/Factoid
|
||||
[HttpGet(Name = "GetAllFactoids")]
|
||||
[ProducesResponseType(typeof(IEnumerable<FactoidResponse>), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetAllFactoids()
|
||||
{
|
||||
try
|
||||
{
|
||||
var highDate = DateTime.Today;
|
||||
var lowDate = highDate.Subtract(TimeSpan.FromDays(30));
|
||||
|
||||
var factoidResponse = new List<FactoidResponse>()
|
||||
{
|
||||
await _factoidService.GetAllAccountsO4R(),
|
||||
await _factoidService.GetAvgDaysO4RToREPO(lowDate, highDate),
|
||||
await _factoidService.GetCurrentInventory(),
|
||||
await _factoidService.GetPercentFloorPrice(lowDate, highDate),
|
||||
await _factoidService.GetCurrentlyOnHold(),
|
||||
await _factoidService.GetRecentlyRedeemed(lowDate, highDate),
|
||||
await _factoidService.GetRecentlyRepoed(lowDate, highDate),
|
||||
await _factoidService.GetGetAvgDaysDelqToO4R(lowDate, highDate),
|
||||
await _factoidService.GetGetAvgDaysRepoToSold(lowDate, highDate),
|
||||
await _factoidService.GetRecentlySold(lowDate, highDate)
|
||||
};
|
||||
return Ok(factoidResponse);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/factoid/CurrentInventory
|
||||
[HttpGet("CurrentInventory", Name = "GetCurrentInventory")]
|
||||
[ProducesResponseType(typeof(FactoidResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetCurrentInventory()
|
||||
{
|
||||
try
|
||||
{
|
||||
var factoidResponse = await _factoidService.GetCurrentInventory();
|
||||
return Ok(factoidResponse);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at Factoid: {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/factoid/AccountsO4R
|
||||
[HttpGet("AccountsO4R", Name = "GetAllAccountsInO4R")]
|
||||
[ProducesResponseType(typeof(FactoidResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetAllAccountsO4R()
|
||||
{
|
||||
try
|
||||
{
|
||||
var factoidResponse = await _factoidService.GetAllAccountsO4R();
|
||||
return Ok(factoidResponse);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at Factoid: {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/factoid/PercentFloor
|
||||
[HttpGet("PercentFloor", Name = "GetPercentFloor")]
|
||||
[ProducesResponseType(typeof(FactoidResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetPercentFloor()
|
||||
{
|
||||
try
|
||||
{
|
||||
var highDate = DateTime.Today;
|
||||
var lowDate = highDate.Subtract(TimeSpan.FromDays(30));
|
||||
|
||||
var factoidResponse = await _factoidService.GetPercentFloorPrice(lowDate, highDate);
|
||||
return Ok(factoidResponse);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at Factoid: {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/factoid/RecentlyRedeemed
|
||||
[HttpGet("RecentlyRedeemed", Name = "GetRecentlyRedeemed")]
|
||||
[ProducesResponseType(typeof(FactoidResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetRecentlyRedeemed()
|
||||
{
|
||||
try
|
||||
{
|
||||
var highDate = DateTime.Today;
|
||||
var lowDate = highDate.Subtract(TimeSpan.FromDays(30));
|
||||
|
||||
var factoidResponse = await _factoidService.GetRecentlyRedeemed(lowDate, highDate);
|
||||
return Ok(factoidResponse);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at Factoid: {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/factoid/AvgDaysO4RToREPO
|
||||
[HttpGet("AvgDaysO4RToREPO", Name = "GetAvgDaysO4RToRepo")]
|
||||
[ProducesResponseType(typeof(FactoidResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetAvgDaysO4RToRepo()
|
||||
{
|
||||
try
|
||||
{
|
||||
var highDate = DateTime.Today;
|
||||
var lowDate = highDate.Subtract(TimeSpan.FromDays(30));
|
||||
|
||||
var factoidResponse = await _factoidService.GetAvgDaysO4RToREPO(lowDate, highDate);
|
||||
return Ok(factoidResponse);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at Factoid: {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/factoid/AvgDaysDelqToO4R
|
||||
[HttpGet("AvgDaysDelqToO4R", Name = "GetAvgDaysDelqToO4R")]
|
||||
[ProducesResponseType(typeof(FactoidResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetAvgDaysDelqToO4R()
|
||||
{
|
||||
try
|
||||
{
|
||||
var highDate = DateTime.Today;
|
||||
var lowDate = highDate.Subtract(TimeSpan.FromDays(30));
|
||||
|
||||
var factoidResponse = await _factoidService.GetGetAvgDaysDelqToO4R(lowDate, highDate);
|
||||
return Ok(factoidResponse);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at Factoid: {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/factoid/AvgDaysRepoToSold
|
||||
[HttpGet("AvgDaysRepoToSold", Name = "GetAvgDaysRepoToSold")]
|
||||
[ProducesResponseType(typeof(FactoidResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetAvgDaysRepoToSold()
|
||||
{
|
||||
try
|
||||
{
|
||||
var highDate = DateTime.Today;
|
||||
var lowDate = highDate.Subtract(TimeSpan.FromDays(30));
|
||||
|
||||
var factoidResponse = await _factoidService.GetGetAvgDaysRepoToSold(lowDate, highDate);
|
||||
return Ok(factoidResponse);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at Factoid: {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/factoid/CurrentOnHold
|
||||
[HttpGet("CurrentOnHold", Name = "GetCurrentOnHold")]
|
||||
[ProducesResponseType(typeof(FactoidResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetCurrentOnHold()
|
||||
{
|
||||
try
|
||||
{
|
||||
var factoidResponse = await _factoidService.GetCurrentlyOnHold();
|
||||
return Ok(factoidResponse);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at Factoid: {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/factoid/RecentlyRepoed
|
||||
[HttpGet("RecentlyRepoed", Name = "GetRecentlyRepoed")]
|
||||
[ProducesResponseType(typeof(FactoidResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetRecentlyRepoed()
|
||||
{
|
||||
try
|
||||
{
|
||||
var highDate = DateTime.Today;
|
||||
var lowDate = highDate.Subtract(TimeSpan.FromDays(30));
|
||||
|
||||
var factoidResponse = await _factoidService.GetRecentlyRepoed(lowDate, highDate);
|
||||
return Ok(factoidResponse);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at Factoid: {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/factoid/RecentlySold
|
||||
[HttpGet("RecentlySold", Name = "GetRecentlySold")]
|
||||
[ProducesResponseType(typeof(FactoidResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetRecentlySold()
|
||||
{
|
||||
try
|
||||
{
|
||||
var highDate = DateTime.Today;
|
||||
var lowDate = highDate.Subtract(TimeSpan.FromDays(30));
|
||||
|
||||
var factoidResponse = await _factoidService.GetRecentlySold(lowDate, highDate);
|
||||
return Ok(factoidResponse);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at Factoid: {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using LCU.API.Collections.RepoApi.Configuration;
|
||||
using LCU.Shared.Collections.RepoApiLib.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.FeatureManagement.Mvc;
|
||||
using Serilog;
|
||||
|
||||
namespace LCU.API.Collections.RepoApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[FeatureGate(FeatureFlags.EnableControllers)]
|
||||
public class LoggingController : RepoControllerBase
|
||||
{
|
||||
public LoggingController(IHttpContextAccessor httpContextAccessor) : base(httpContextAccessor)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use to send something to the logger from the client
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Logs a message from a client.
|
||||
/// Cookies: None required or set.
|
||||
/// Security: Must have a valid JWT token retrieved from Azure AD, with ADMIN role.
|
||||
/// </remarks>
|
||||
// Post: api/Logging/Error
|
||||
[HttpPost("Error")]
|
||||
[ProducesResponseType(200)]
|
||||
[ProducesResponseType(400)]
|
||||
[ProducesResponseType(403)]
|
||||
[ProducesResponseType(500)]
|
||||
public IActionResult Post([FromBody] ClientError error)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Error($"Client Exception: <{ error.Name}> : {error.Message} => {error.StackTrace}");
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Fatal(e,"Failed to log client error. Exception Thrown.");
|
||||
return StatusCode((int) System.Net.HttpStatusCode.InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.API.Collections.RepoApi.Configuration;
|
||||
using LCU.API.Collections.RepoApi.HostedServices;
|
||||
using LCU.API.Collections.RepoApi.Services;
|
||||
using LCU.Shared.Collections.RepoApiLib.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.FeatureManagement.Mvc;
|
||||
using Serilog;
|
||||
|
||||
namespace LCU.API.Collections.RepoApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[FeatureGate(FeatureFlags.EnableControllers)]
|
||||
public class ProcessingReceiptController : RepoControllerBase
|
||||
{
|
||||
|
||||
private readonly IProcessingReceiptService _receiptService;
|
||||
|
||||
public ProcessingReceiptController(IProcessingReceiptService receiptService,
|
||||
IHttpContextAccessor httpContextAccessor):
|
||||
base(httpContextAccessor)
|
||||
{
|
||||
_receiptService = receiptService;
|
||||
}
|
||||
|
||||
//GET: api/ProcessingReceipt/AccountNo/5
|
||||
[HttpGet("AccountNo/{accountNo}")]
|
||||
[ProducesResponseType(typeof(ReadOnlyCollection<ProcessingReceipt>),200)]
|
||||
[ProducesResponseType(typeof(string),400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetByAccountNo(string accountNo)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace((accountNo)))
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var results = await _receiptService.GetReceiptsByAccountNoAsync(accountNo);
|
||||
if (results.Any())
|
||||
{
|
||||
return Ok(results);
|
||||
}
|
||||
|
||||
return NotFound("No receipts found for for this account");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+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();
|
||||
}
|
||||
}
|
||||
}
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.API.Collections.RepoApi.Configuration;
|
||||
using LCU.API.Collections.RepoApi.Exceptions;
|
||||
using LCU.API.Collections.RepoApi.Extensions;
|
||||
using LCU.API.Collections.RepoApi.Services;
|
||||
using LCU.Shared.Collections.RepoApiLib.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.FeatureManagement.Mvc;
|
||||
using Serilog;
|
||||
|
||||
namespace LCU.API.Collections.RepoApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[FeatureGate(FeatureFlags.EnableControllers)]
|
||||
public class RefundStatusController : RepoControllerBase
|
||||
{
|
||||
private IRefundStatusService _refundStatusService;
|
||||
|
||||
public RefundStatusController(
|
||||
IRefundStatusService refundStatusService,
|
||||
IHttpContextAccessor httpContextAccessor) :
|
||||
base(httpContextAccessor)
|
||||
{
|
||||
_refundStatusService = refundStatusService;
|
||||
}
|
||||
|
||||
// GET: api/RefundStatus
|
||||
[HttpGet(Name = "GetAllRefundStatus")]
|
||||
[ProducesResponseType(typeof(IEnumerable<RefundStatus>), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Get()
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _refundStatusService.ListAllAsync();
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/RefundStatus/5
|
||||
[HttpGet("{repoId}", Name = "GetRefundStatusById")]
|
||||
[ProducesResponseType(typeof(RefundStatus), 200)]
|
||||
[ProducesResponseType(typeof(string), 404)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetById(int repoId)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (repoId <= 0)
|
||||
{
|
||||
return BadRequest("Invalid RepoId");
|
||||
}
|
||||
|
||||
var refundStatus = await _refundStatusService.GetAsync(repoId);
|
||||
return Ok(refundStatus);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ProducesResponseType(typeof(RefundStatus), 200)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Post([FromBody] RefundStatus refundStatus)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
if (refundStatus.RepoId <= 0)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var newRefundStatus = await _refundStatusService.SaveAsync(refundStatus);
|
||||
return Ok(newRefundStatus);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut("{repoId}")]
|
||||
[ProducesResponseType(typeof(RefundStatus), 200)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Put(int repoId, [FromBody] RefundStatus refundStatus)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
if (repoId <= 0 || repoId != refundStatus.RepoId)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var newRefundStatus = await _refundStatusService.UpdateAsync(refundStatus);
|
||||
return Ok(newRefundStatus);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+343
@@ -0,0 +1,343 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.API.Collections.RepoApi.Configuration;
|
||||
using LCU.API.Collections.RepoApi.Exceptions;
|
||||
using LCU.API.Collections.RepoApi.Extensions;
|
||||
using LCU.API.Collections.RepoApi.Models;
|
||||
using LCU.API.Collections.RepoApi.Models.Filters;
|
||||
using LCU.API.Collections.RepoApi.Models.Requests;
|
||||
using LCU.API.Collections.RepoApi.Models.Responses;
|
||||
using LCU.API.Collections.RepoApi.Services;
|
||||
using LCU.Shared.Collections.RepoApiLib.Exceptions;
|
||||
using LCU.Shared.Collections.RepoApiLib.Models;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.FeatureManagement.Mvc;
|
||||
using Serilog;
|
||||
|
||||
namespace LCU.API.Collections.RepoApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[FeatureGate(FeatureFlags.EnableControllers)]
|
||||
public class RepoAccountController : RepoControllerBase
|
||||
{
|
||||
private readonly IRepoAccountService _repoAccountService;
|
||||
private readonly IRepoLetterService _repoLetterService;
|
||||
private readonly IRepoStatusChangeService _repoStatusChangeService;
|
||||
|
||||
public RepoAccountController(
|
||||
IRepoAccountService repoAccountService,
|
||||
IRepoLetterService repoLetterService,
|
||||
IRepoStatusChangeService repoStatusChangeService,
|
||||
IHttpContextAccessor httpContextAccessor) : base(httpContextAccessor)
|
||||
{
|
||||
_repoAccountService = repoAccountService;
|
||||
_repoLetterService = repoLetterService;
|
||||
_repoStatusChangeService = repoStatusChangeService;
|
||||
}
|
||||
|
||||
// GET: api/RepoAccount
|
||||
[HttpGet(Name = "GetAllRepoAccounts")]
|
||||
[ProducesResponseType(typeof(PagedResponse<RepoAccount>), 200)]
|
||||
[ProducesResponseType(typeof(string), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Get([FromQuery] PageFilter filter)
|
||||
{
|
||||
try
|
||||
{
|
||||
var searchResult = await _repoAccountService.ListAll(filter);
|
||||
var result = new PagedResponse<RepoAccount>(searchResult, filter, this.Url, Request);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/RepoAccount/5
|
||||
[HttpGet("{id}", Name = "GetRepoAccountById")]
|
||||
[ProducesResponseType(typeof(RepoAccount), 200)]
|
||||
[ProducesResponseType(typeof(string), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetById(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id <= 0)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var result = await _repoAccountService.Get(id);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/RepoAccount/5/statusChanges
|
||||
[HttpGet("{id}/statusChanges", Name = "GetRepoAccountStatusChanges")]
|
||||
[ProducesResponseType(typeof(RepoStatusChange), 200)]
|
||||
[ProducesResponseType(typeof(string), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetStatusChangesByRepoId(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id <= 0)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var result = await _repoStatusChangeService.ListByAccount(id);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/RepoAccount/5/repoLetters
|
||||
[HttpGet("{id}/repoLetters", Name = "GetLettersByRepoId")]
|
||||
[ProducesResponseType(typeof(RepoLetter), 200)]
|
||||
[ProducesResponseType(typeof(string), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetLettersByRepoId(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id <= 0)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var result = await _repoLetterService.ListByAccountIdAsync(id);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/RepoAccount/Search/searchPhrase
|
||||
[HttpGet("Search/{searchPhrase}", Name = "SearchRepoAccounts")]
|
||||
[ProducesResponseType(typeof(RepoAccount), 200)]
|
||||
[ProducesResponseType(typeof(string), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> SearchRepoAccounts(string searchPhrase)
|
||||
{
|
||||
var maxResults = 100;
|
||||
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(searchPhrase))
|
||||
{
|
||||
return BadRequest("Search Phrase Cannot Be Empty");
|
||||
}
|
||||
|
||||
if (searchPhrase.Trim().Length < 3)
|
||||
{
|
||||
return BadRequest("Search Phrase Must Be At Least Three (3) Characters Long");
|
||||
}
|
||||
|
||||
var result = await _repoAccountService.SearchRepoAccounts(searchPhrase, maxResults);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (MaxItemException ex)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status413PayloadTooLarge, $"Too Many Search Results. (Max: {maxResults}) (Found: {ex.ItemCount})");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/RepoAccount/AccountNo/5
|
||||
[HttpGet("AccountNo/{accountNo}", Name = "GetRepoAccountByAccountNo")]
|
||||
[ProducesResponseType(typeof(RepoAccount), 200)]
|
||||
[ProducesResponseType(typeof(string), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetByAccountNo(string accountNo)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(accountNo))
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var result = await _repoAccountService.GetByAccountNo(accountNo);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/RepoAccount
|
||||
[HttpPost]
|
||||
[ProducesResponseType(typeof(RepoAccount), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Post([FromBody] RepoAccount repoAccount)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _repoAccountService.SaveAsync(repoAccount);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// PUT: api/RepoAccount/5
|
||||
[HttpPut("{id}")]
|
||||
[ProducesResponseType(typeof(RepoAccount), 200)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||
public async Task<IActionResult> Put(int id, [FromBody] RepoAccount repoAccount)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id <= 0 || id != repoAccount.RepoId)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
var currentUser = CreateUserFromAuth();
|
||||
var result = await _repoAccountService.UpdateAsync(repoAccount, currentUser);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (MaxItemException mie)
|
||||
{
|
||||
return BadRequest(mie.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// PUT: api/RepoAccount/Insecure/5
|
||||
[HttpPut("Insecure/{id}", Name = "Update Account Insecure Batch")]
|
||||
[ProducesResponseType(typeof(RepoAccount), 200)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> PutBatch(int id, [FromBody] RepoAccount repoAccount)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id <= 0 || id != repoAccount.RepoId)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
var currentUser = new AppUser()
|
||||
{
|
||||
FirstName = "System",
|
||||
LastName = "User"
|
||||
};
|
||||
var result = await _repoAccountService.UpdateAsync(repoAccount, currentUser);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (MaxItemException mie)
|
||||
{
|
||||
return BadRequest(mie.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/Filter
|
||||
[HttpPost("Filter")]
|
||||
[ProducesResponseType(typeof(PagedResponse<RepoAccount>), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Filter([FromQuery] PageFilter pageFilter, [FromBody] RepoAccountPostFilter repoAccountFilter)
|
||||
{
|
||||
try
|
||||
{
|
||||
var searchResult = await _repoAccountService.ListAll(pageFilter, repoAccountFilter);
|
||||
var result = new PagedResponse<RepoAccount>(searchResult, pageFilter, this.Url, Request, "Filter");
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete("Delete/{AccountId}")]
|
||||
[ProducesResponseType(200)]
|
||||
[ProducesResponseType(500)]
|
||||
[ProducesResponseType(400)]
|
||||
public async Task<IActionResult> DeleteAccountById([FromRoute] int accountId)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _repoAccountService.DeleteAsync(accountId);
|
||||
}catch(Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
return Ok($"Delete of Account with Id: {accountId} Successful");
|
||||
}
|
||||
}
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.API.Collections.RepoApi.Configuration;
|
||||
using LCU.API.Collections.RepoApi.Exceptions;
|
||||
using LCU.API.Collections.RepoApi.Extensions;
|
||||
using LCU.API.Collections.RepoApi.Services;
|
||||
using LCU.Shared.Collections.RepoApiLib.Models;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.FeatureManagement.Mvc;
|
||||
using Serilog;
|
||||
|
||||
namespace LCU.API.Collections.RepoApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[FeatureGate(FeatureFlags.EnableControllers)]
|
||||
public class RepoCompanyController : RepoControllerBase
|
||||
{
|
||||
private readonly IRepoCompanyService _repoCompanyService;
|
||||
|
||||
public RepoCompanyController(
|
||||
IRepoCompanyService repoCompanyService,
|
||||
IHttpContextAccessor httpContextAccessor) :
|
||||
base(httpContextAccessor)
|
||||
{
|
||||
_repoCompanyService = repoCompanyService;
|
||||
}
|
||||
|
||||
// GET: api/RepoCompany
|
||||
[ProducesResponseType(typeof(IEnumerable<RepoCompany>), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Get()
|
||||
{
|
||||
try
|
||||
{
|
||||
var repoCompanies = await _repoCompanyService.ListAll();
|
||||
return Ok(repoCompanies);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/RepoCompany/5
|
||||
[HttpGet("{id}", Name = "GetRepoCompanyById")]
|
||||
[ProducesResponseType(typeof(RepoCompany), 200)]
|
||||
[ProducesResponseType(typeof(string), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetById(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id <= 0)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var repoCompany = await _repoCompanyService.Get(id);
|
||||
return Ok(repoCompany);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/RepoCompany
|
||||
[HttpPost]
|
||||
[ProducesResponseType(typeof(RepoCompany), 200)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||
public async Task<IActionResult> Post([FromBody] RepoCompany repoCompany)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var newRepoCompany = await _repoCompanyService.Save(repoCompany);
|
||||
return Ok(newRepoCompany);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// PUT: api/RepoCompany/5
|
||||
[HttpPut("{id}")]
|
||||
[ProducesResponseType(typeof(RepoCompany), 200)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||
public async Task<IActionResult> Put(int id, [FromBody] RepoCompany repoCompany)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
if (id <= 0 || id != repoCompany.ID)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var currentUser = CreateUserFromAuth();
|
||||
|
||||
var updatedRepoCompany = await _repoCompanyService.Update(repoCompany, currentUser);
|
||||
return Ok(updatedRepoCompany);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.API.Collections.RepoApi.Configuration;
|
||||
using LCU.API.Collections.RepoApi.Exceptions;
|
||||
using LCU.API.Collections.RepoApi.Services;
|
||||
using LCU.Shared.Collections.RepoApiLib.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.FeatureManagement.Mvc;
|
||||
using Serilog;
|
||||
|
||||
namespace LCU.API.Collections.RepoApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[FeatureGate(FeatureFlags.EnableControllers)]
|
||||
public class RepoCompanySelectionController : RepoControllerBase
|
||||
{
|
||||
private readonly IRepoCompanySelectionService _repoCompanySelectionService;
|
||||
|
||||
public RepoCompanySelectionController(
|
||||
IRepoCompanySelectionService repoCompanySelectionService,
|
||||
IHttpContextAccessor httpContextAccessor) :
|
||||
base(httpContextAccessor)
|
||||
{
|
||||
_repoCompanySelectionService = repoCompanySelectionService;
|
||||
}
|
||||
|
||||
// GET: api/RepoCompanySelection
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(IEnumerable<RepoCompanySelection>), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<ActionResult> Get()
|
||||
{
|
||||
try
|
||||
{
|
||||
var repoCompanySelections = await _repoCompanySelectionService.ListAllAsync();
|
||||
return Ok(repoCompanySelections);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/RepoCompanySelection/5
|
||||
[HttpGet("{id}", Name = "GetRepoCompanySelectionById")]
|
||||
[ProducesResponseType(typeof(RepoCompanySelection), 200)]
|
||||
[ProducesResponseType(typeof(string), 400)]
|
||||
[ProducesResponseType(typeof(string), 404)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<ActionResult> Get(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id <= 0)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var repoCompanySelection = await _repoCompanySelectionService.GetAsync(id);
|
||||
return Ok(repoCompanySelection);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Security.Claims;
|
||||
using LCU.API.Collections.RepoApi.Configuration;
|
||||
using LCU.API.Collections.RepoApi.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.FeatureManagement.Mvc;
|
||||
|
||||
namespace LCU.API.Collections.RepoApi.Controllers
|
||||
{
|
||||
public class RepoControllerBase : ControllerBase
|
||||
{
|
||||
protected readonly IHttpContextAccessor HttpContextAccessor;
|
||||
|
||||
protected RepoControllerBase(IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
HttpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
protected AppUser CreateUserFromAuth()
|
||||
{
|
||||
var userClaimsPrincipal = HttpContextAccessor.HttpContext.User;
|
||||
|
||||
return new AppUser
|
||||
{
|
||||
FirstName = userClaimsPrincipal.Claims.FirstOrDefault(claim => claim.Type == ClaimTypes.GivenName)?.Value,
|
||||
LastName = userClaimsPrincipal.Claims.FirstOrDefault(claim => claim.Type == ClaimTypes.Surname)?.Value,
|
||||
Email = userClaimsPrincipal.Claims.FirstOrDefault(claim => claim.Type == ClaimTypes.Upn)?.Value,
|
||||
Roles = userClaimsPrincipal.Claims.Where((claim) => claim.Type == ClaimTypes.Role).Select((claim) => claim?.Value).ToArray(),
|
||||
};
|
||||
}
|
||||
|
||||
public static string GetInvokerAsyncMethodName([CallerMemberName] string methodName = null) => methodName;
|
||||
|
||||
}
|
||||
}
|
||||
+382
@@ -0,0 +1,382 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.API.Collections.RepoApi.Configuration;
|
||||
using LCU.API.Collections.RepoApi.Models.Requests;
|
||||
using LCU.API.Collections.RepoApi.Services.Reporting;
|
||||
using LCU.Shared.Collections.RepoApiLib.Models.Reporting.Responses;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.FeatureManagement.Mvc;
|
||||
using Serilog;
|
||||
|
||||
namespace LCU.API.Collections.RepoApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[FeatureGate(FeatureFlags.EnableControllers)]
|
||||
[ApiController]
|
||||
public class ReportingController : RepoControllerBase
|
||||
{
|
||||
private readonly ILandmarkReportingService _landmarkReportingService;
|
||||
private readonly IAuctionReportingService _auctionReportingService;
|
||||
private readonly IRepoCompanyReportingService _repoCompanyReportingService;
|
||||
|
||||
public ReportingController(
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
ILandmarkReportingService landmarkReportingService,
|
||||
IAuctionReportingService auctionReportingService,
|
||||
IRepoCompanyReportingService repoCompanyReportingService) :
|
||||
base(httpContextAccessor)
|
||||
{
|
||||
_landmarkReportingService = landmarkReportingService;
|
||||
_auctionReportingService = auctionReportingService;
|
||||
_repoCompanyReportingService = repoCompanyReportingService;
|
||||
}
|
||||
|
||||
// POST: api/Reporting/AuctionAssignedBalance
|
||||
[HttpPost("AuctionAssignedBalance", Name = "AuctionAssignedBalance")]
|
||||
[ProducesResponseType(typeof(ReportTableResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetAuctionAssignedBalance([FromBody] ReportingRequest reportingRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var results = await _auctionReportingService.GetAssignedBalance(reportingRequest.LowDate, reportingRequest.HighDate);
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/Reporting/AuctionCountOfAssignedCollateral
|
||||
[HttpPost("AuctionCountOfAssignedCollateral", Name = "AuctionCountOfAssignedCollateral")]
|
||||
[ProducesResponseType(typeof(ReportTableResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetAuctionCountOfAssignedCollateral([FromBody] ReportingRequest reportingRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var results = await _auctionReportingService.GetAssignedCollateralCount(reportingRequest.LowDate, reportingRequest.HighDate);
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/Reporting/AuctionSalePrice
|
||||
[HttpPost("AuctionSalePrice", Name = "AuctionSalePrice")]
|
||||
[ProducesResponseType(typeof(ReportTableResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetAuctionSalePrice([FromBody] ReportingRequest reportingRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var results = await _auctionReportingService.GetSalePriceReport(reportingRequest.LowDate, reportingRequest.HighDate);
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/Reporting/AuctionTotalFees
|
||||
[HttpPost("AuctionTotalFees", Name = "AuctionTotalFees")]
|
||||
[ProducesResponseType(typeof(ReportTableResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetAuctionTotalFees([FromBody] ReportingRequest reportingRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var results = await _auctionReportingService.GetAuctionFeeReport(reportingRequest.LowDate, reportingRequest.HighDate);
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/Reporting/AuctionAvgDaysToSold
|
||||
[HttpPost("AuctionAvgDaysToSold", Name = "AuctionAvgDaysToSold")]
|
||||
[ProducesResponseType(typeof(ReportTableResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetAuctionAvgDaysToSold([FromBody] ReportingRequest reportingRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _auctionReportingService.GetAvgDaysAssignedToSold(reportingRequest.LowDate, reportingRequest.HighDate);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/Reporting/AuctionAvgNetOfFloor
|
||||
[HttpPost("AuctionAvgNetOfFloor", Name = "AuctionAvgNetOfFloor")]
|
||||
[ProducesResponseType(typeof(ReportTableResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetAuctionAvgNetOfFloor([FromBody] ReportingRequest reportingRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _auctionReportingService.GetAvgNetOfFloor(reportingRequest.LowDate, reportingRequest.HighDate);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/Reporting/RepoCompanyCountOfAssignedCollateral
|
||||
[HttpPost("RepoCompanyCountOfAssignedCollateral", Name = "RepoCompanyCountOfAssignedCollateral")]
|
||||
[ProducesResponseType(typeof(ReportTableResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetRepoCompanyCountOfAssignedCollateral([FromBody] ReportingRequest reportingRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var results = await _repoCompanyReportingService.GetAssignmentCountReport(reportingRequest.LowDate, reportingRequest.HighDate);
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/Reporting/RepoCompanyAssignedBalance
|
||||
[HttpPost("RepoCompanyAssignedBalance", Name = "RepoCompanyAssignedBalance")]
|
||||
[ProducesResponseType(typeof(ReportTableResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetRepoCompanyAssignedBalance([FromBody] ReportingRequest reportingRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _repoCompanyReportingService.GetAssignedBalance(reportingRequest.LowDate, reportingRequest.HighDate);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/Reporting/RepoCompanyRepoCount
|
||||
[HttpPost("RepoCompanyRepoCount", Name = "RepoCompanyRepoCount")]
|
||||
[ProducesResponseType(typeof(ReportTableResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetRepoCompanyRepoCount([FromBody] ReportingRequest reportingRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _repoCompanyReportingService.GetRepoedCountReport(reportingRequest.LowDate, reportingRequest.HighDate);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/Reporting/RepoCompanyAvgDaysAssignedToRepo
|
||||
[HttpPost("RepoCompanyAvgDaysAssignedToRepo", Name = "RepoCompanyAvgDaysAssignedToRepo")]
|
||||
[ProducesResponseType(typeof(ReportTableResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetRepoCompanyAvgDaysAssignedToRepo([FromBody] ReportingRequest reportingRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _repoCompanyReportingService.GetAvgDaysAssignedToRepoed(reportingRequest.LowDate, reportingRequest.HighDate);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/Reporting/AvgDaysDlqWhenAdded
|
||||
[HttpPost("AvgDaysDlqWhenAdded", Name = "AvgDaysDlqWhenAdded")]
|
||||
[ProducesResponseType(typeof(ReportTableResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetAvgDaysDlqWhenAdded([FromBody] ReportingRequest reportingRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _landmarkReportingService.GetAvgDaysDelqWhenAddedReport(reportingRequest.LowDate, reportingRequest.HighDate);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/Reporting/AvgDaysRepoToSold
|
||||
[HttpPost("AvgDaysRepoToSold", Name = "AvgDaysRepoToSold")]
|
||||
[ProducesResponseType(typeof(ReportTableResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetAvgDaysRepoToSold([FromBody] ReportingRequest reportingRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _landmarkReportingService.GetAvgDaysRepoToSoldReport(reportingRequest.LowDate, reportingRequest.HighDate);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/Reporting/CountOfSales
|
||||
[HttpPost("CountOfSales", Name = "CountOfSales")]
|
||||
[ProducesResponseType(typeof(ReportTableResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetCountOfSales([FromBody] ReportingRequest reportingRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _landmarkReportingService.GetCountOfSalesReport(reportingRequest.LowDate, reportingRequest.HighDate);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/Reporting/AvgSurplusOrDeficiency
|
||||
[HttpPost("AvgSurplusOrDeficiency", Name = "AvgSurplusOrDeficiency")]
|
||||
[ProducesResponseType(typeof(ReportTableResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetAvgSurplusOrDeficiency([FromBody] ReportingRequest reportingRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _landmarkReportingService.GetAvgSurplusReport(reportingRequest.LowDate, reportingRequest.HighDate);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/Reporting/CountOfRedemptions
|
||||
[HttpPost("CountOfRedemptions", Name = "CountOfRedemptions")]
|
||||
[ProducesResponseType(typeof(ReportTableResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetCountOfRedemptions([FromBody] ReportingRequest reportingRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _landmarkReportingService.GetRedemptionCountReport(reportingRequest.LowDate, reportingRequest.HighDate);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/Reporting/TotalRedemptionBalance
|
||||
[HttpPost("TotalRedemptionBalance", Name = "TotalRedemptionBalance")]
|
||||
[ProducesResponseType(typeof(ReportTableResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetTotalRedemptionBalance([FromBody] ReportingRequest reportingRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _landmarkReportingService.GetRedemptionBalanceReport(reportingRequest.LowDate, reportingRequest.HighDate);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/Reporting/LoanBalanceRepoedCollateral
|
||||
[HttpPost("LoanBalanceInventory", Name = "LoanBalanceInventory")]
|
||||
[ProducesResponseType(typeof(ReportTableResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetLoanBalanceInventory([FromBody] ReportingRequest reportingRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _landmarkReportingService.GetRepoBalanceReport(reportingRequest.LowDate, reportingRequest.HighDate);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/Reporting/IsActiveAccount
|
||||
[HttpPost("IsActiveAccount", Name = "IsActiveAccount")]
|
||||
[ProducesResponseType(typeof(ReportTableResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetIsActiveAccount([FromBody] ReportingRequest reportingRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var results =
|
||||
await _landmarkReportingService.GetIsActiveAccountReport(reportingRequest.LowDate,
|
||||
reportingRequest.HighDate);
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/Reporting/IsClosedAccount
|
||||
[HttpPost("IsClosedAccount", Name = "IsClosedAccount")]
|
||||
[ProducesResponseType(typeof(ReportTableResponse), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetIsClosedAccount([FromBody] ReportingRequest reportingRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var results =
|
||||
await _landmarkReportingService.GetIsClosedAccountReport(reportingRequest.LowDate,
|
||||
reportingRequest.HighDate);
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.API.Collections.RepoApi.Configuration;
|
||||
using LCU.API.Collections.RepoApi.Exceptions;
|
||||
using LCU.API.Collections.RepoApi.Extensions;
|
||||
using LCU.API.Collections.RepoApi.Services;
|
||||
using LCU.Shared.Collections.RepoApiLib.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.FeatureManagement.Mvc;
|
||||
using Serilog;
|
||||
|
||||
namespace LCU.API.Collections.RepoApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[FeatureGate(FeatureFlags.EnableControllers)]
|
||||
public class SavedLocationController : RepoControllerBase
|
||||
{
|
||||
private readonly ISavedLocationService _savedLocationService;
|
||||
|
||||
public SavedLocationController(
|
||||
ISavedLocationService savedLocationService,
|
||||
IHttpContextAccessor httpContextAccessor) :
|
||||
base(httpContextAccessor)
|
||||
{
|
||||
_savedLocationService = savedLocationService;
|
||||
}
|
||||
|
||||
// GET: api/SavedLocation
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(IEnumerable<SavedLocation>), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Get()
|
||||
{
|
||||
try
|
||||
{
|
||||
var savedLocations = await _savedLocationService.ListAllAsync();
|
||||
return Ok(savedLocations);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/SavedLocation/5
|
||||
[HttpGet("{id}", Name = "GetSavedLocationById")]
|
||||
[ProducesResponseType(typeof(SavedLocation), 200)]
|
||||
[ProducesResponseType(typeof(string), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetById(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id <= 0)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var savedLocation = await _savedLocationService.GetAsync(id);
|
||||
return Ok(savedLocation);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// POST: api/SavedLocation
|
||||
[HttpPost]
|
||||
[ProducesResponseType(typeof(SavedLocation), 200)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Post([FromBody] SavedLocation savedLocation)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var newSavedLocation = await _savedLocationService.SaveAsync(savedLocation);
|
||||
return Ok(newSavedLocation);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// PUT: api/SavedLocation/5
|
||||
[HttpPut("{id}")]
|
||||
[ProducesResponseType(typeof(SavedLocation), 200)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Put(int id, [FromBody] SavedLocation savedLocation)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
if (id <= 0 || id != savedLocation.ID)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var updatedSavedLocation = await _savedLocationService.UpdateAsync(savedLocation);
|
||||
return Ok(updatedSavedLocation);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// DELETE: api/ApiWithActions/5
|
||||
[HttpDelete("{id}")]
|
||||
[ProducesResponseType(typeof(SavedLocation), 200)]
|
||||
[ProducesResponseType(typeof(string), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Delete(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id <= 0)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var result = await _savedLocationService.DeleteAsync(id);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+531
@@ -0,0 +1,531 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.Shared.Collections.RepoApiLib.Models.Settings;
|
||||
using LCU.API.Collections.RepoApi.Services;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using LCU.API.Collections.RepoApi.Configuration;
|
||||
using LCU.API.Collections.RepoApi.Extensions;
|
||||
using Microsoft.FeatureManagement.Mvc;
|
||||
using Serilog;
|
||||
|
||||
namespace LCU.API.Collections.RepoApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[FeatureGate(FeatureFlags.EnableControllers)]
|
||||
public class SettingsController : RepoControllerBase
|
||||
{
|
||||
private readonly ISettingsService _settingsService;
|
||||
|
||||
public SettingsController(
|
||||
ISettingsService settingsService,
|
||||
IHttpContextAccessor httpContextAccessor) : base(httpContextAccessor)
|
||||
{
|
||||
_settingsService = settingsService;
|
||||
}
|
||||
|
||||
// GET: api/Settings
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(Settings), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Get()
|
||||
{
|
||||
try
|
||||
{
|
||||
var results = await _settingsService.ListAllSettingsAsync();
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// PUT: api/Settings/[method]
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(typeof(AccountType), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> PutAccountType([FromBody] AccountType accountType)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _settingsService.UpdateAsync(accountType);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(typeof(AllowedStatusChange), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> PutAllowedStatusChange([FromBody] AllowedStatusChange statusChange)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _settingsService.UpdateAsync(statusChange);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(typeof(AllowedStatusChange), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> PutBodyStyle([FromBody] BodyStyle bodyStyle)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _settingsService.UpdateAsync(bodyStyle);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(typeof(AllowedStatusChange), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> PutCleaningLevel([FromBody] CleaningLevel cleaningLevel)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _settingsService.UpdateAsync(cleaningLevel);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(typeof(AllowedStatusChange), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> PutCollateralType([FromBody] CollateralType collateralType)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _settingsService.UpdateAsync(collateralType);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(typeof(AllowedStatusChange), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> PutCollateralTypeToVehicleType(
|
||||
[FromBody] CollateralTypeToVehicleType collateralToVehicle)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _settingsService.UpdateAsync(collateralToVehicle);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(typeof(AllowedStatusChange), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> PutHoldStatus([FromBody] HoldStatus holdStatus)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _settingsService.UpdateAsync(holdStatus);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(typeof(AllowedStatusChange), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> PutLoanCategory([FromBody] LoanCategory loanCategory)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _settingsService.UpdateAsync(loanCategory);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(typeof(AllowedStatusChange), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> PutLocationType([FromBody] LocationType locationType)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _settingsService.UpdateAsync(locationType);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(typeof(AllowedStatusChange), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> PutVehicleType([FromBody] VehicleType vehicleType)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _settingsService.UpdateAsync(vehicleType);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// POST: api/Settings/[method]
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(typeof(AccountType), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> PostAccountType([FromBody] AccountType accountType)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _settingsService.SaveAsync(accountType);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(typeof(AccountType), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> PostAllowedStatusChange([FromBody] AllowedStatusChange statusChange)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _settingsService.SaveAsync(statusChange);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(typeof(AccountType), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> PostBodyStyle([FromBody] BodyStyle bodyStyle)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _settingsService.SaveAsync(bodyStyle);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(typeof(AccountType), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> PostCleaningLevel([FromBody] CleaningLevel cleaningLevel)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _settingsService.SaveAsync(cleaningLevel);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(typeof(AccountType), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> PostCollateralType([FromBody] CollateralType collateralType)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _settingsService.SaveAsync(collateralType);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(typeof(AccountType), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> PostCollateralTypeToVehicleType(
|
||||
[FromBody] CollateralTypeToVehicleType collateralToVehicle)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _settingsService.SaveAsync(collateralToVehicle);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(typeof(AccountType), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> PostHoldStatus([FromBody] HoldStatus holdStatus)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _settingsService.SaveAsync(holdStatus);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(typeof(AccountType), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> PostLoanCategory([FromBody] LoanCategory loanCategory)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _settingsService.SaveAsync(loanCategory);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(typeof(AccountType), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> PostLocationType([FromBody] LocationType locationType)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _settingsService.SaveAsync(locationType);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(typeof(AccountType), 201)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> PostVehicleType([FromBody] VehicleType vehicleType)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _settingsService.SaveAsync(vehicleType);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using LCU.Shared.Collections.RepoApiLib.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Serilog;
|
||||
|
||||
namespace LCU.API.Collections.RepoApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class StatusController : RepoControllerBase
|
||||
{
|
||||
private readonly IEnvironmentView _environmentView;
|
||||
|
||||
public StatusController(IHttpContextAccessor httpContextAccessor, IEnvironmentView environmentView) : base(httpContextAccessor)
|
||||
{
|
||||
_environmentView = environmentView;
|
||||
}
|
||||
|
||||
[HttpGet()]
|
||||
[ProducesResponseType(200)]
|
||||
[ProducesResponseType(500)]
|
||||
public IActionResult Get()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Ok(_environmentView);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode((int) System.Net.HttpStatusCode.InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.API.Collections.RepoApi.Configuration;
|
||||
using LCU.API.Collections.RepoApi.Exceptions;
|
||||
using LCU.API.Collections.RepoApi.Extensions;
|
||||
using LCU.API.Collections.RepoApi.Models.Requests;
|
||||
using LCU.API.Collections.RepoApi.Models.Responses;
|
||||
using LCU.API.Collections.RepoApi.Services;
|
||||
using LCU.Shared.Collections.RepoApiLib.Models;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.FeatureManagement.Mvc;
|
||||
using Serilog;
|
||||
|
||||
namespace LCU.API.Collections.RepoApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[FeatureGate(FeatureFlags.EnableControllers)]
|
||||
public class VehicleFloorPricingParametersController : RepoControllerBase
|
||||
{
|
||||
private readonly IVehicleFloorPricingParametersService _parametersService;
|
||||
|
||||
public VehicleFloorPricingParametersController(
|
||||
IVehicleFloorPricingParametersService parametersService,
|
||||
IHttpContextAccessor httpContextAccessor) : base(httpContextAccessor)
|
||||
{
|
||||
_parametersService = parametersService;
|
||||
}
|
||||
|
||||
// GET: api/VehicleFloorPricingParameters
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(IEnumerable<VehicleFloorPricingParameters>), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Get()
|
||||
{
|
||||
try
|
||||
{
|
||||
var results = await _parametersService.ListAll();
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/VehicleFloorPricingParameters/5
|
||||
[HttpGet("{id}", Name = "GetVehicleFloorPricingParametersById")]
|
||||
[ProducesResponseType(typeof(VehicleFloorPricingParameters), 200)]
|
||||
[ProducesResponseType(typeof(string), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetById(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id <= 0)
|
||||
{
|
||||
return BadRequest("Invalid ID");
|
||||
}
|
||||
|
||||
var result = await _parametersService.Get(id);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut()]
|
||||
[ProducesResponseType(typeof(AuctionHouse), 200)]
|
||||
[ProducesResponseType(typeof(List<string>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "Admin")]
|
||||
public async Task<IActionResult> Put([FromBody] VehicleFloorPricingParametersPutRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var updatedParams = await UpdateVehiceFloorPricingParameters(request.vehicleFloorPricingParameters);
|
||||
return Ok(new VehicleFloorPricingParametersPutResponse { vehicleFloorPricingParameters = updatedParams });
|
||||
}
|
||||
catch (NotFoundException nfe)
|
||||
{
|
||||
return NotFound(nfe.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name} at {GetInvokerAsyncMethodName()}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<VehicleFloorPricingParameters[]> UpdateVehiceFloorPricingParameters(VehicleFloorPricingParameters[] vehicleFloorPricingParameters)
|
||||
{
|
||||
var result = new List<VehicleFloorPricingParameters>();
|
||||
foreach (var param in vehicleFloorPricingParameters)
|
||||
{
|
||||
result.Add(await _parametersService.UpdateAsync(param));
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user