264 lines
10 KiB
C#
264 lines
10 KiB
C#
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);
|
|
|
|
}
|
|
}
|
|
}
|
|
} |