|
|
|
@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Expedience.Api.Controllers
|
|
|
|
namespace Expedience.Api.Controllers
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[Route("api/[controller]")]
|
|
|
|
[Route("api")]
|
|
|
|
[ApiController]
|
|
|
|
[ApiController]
|
|
|
|
public class ExpedienceController : ControllerBase
|
|
|
|
public class ExpedienceController : ControllerBase
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -50,42 +50,42 @@ namespace Expedience.Api.Controllers
|
|
|
|
return Ok();
|
|
|
|
return Ok();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet("DutyCompletionRecords/{expac}")]
|
|
|
|
[HttpGet("UserName/{worldId}/{userHash}")]
|
|
|
|
public async Task<ActionResult> GetDutyCompletionRecords(string expac, CancellationToken cancellationToken)
|
|
|
|
public async Task<ActionResult> GetUserName(int worldId, string userHash, CancellationToken cancellationToken)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
using var scope = _serviceScopeFactory.CreateScope();
|
|
|
|
using var scope = _serviceScopeFactory.CreateScope();
|
|
|
|
using var repository = scope.ServiceProvider.GetService<IExpedienceRepository>();
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<ExpedienceContext>();
|
|
|
|
|
|
|
|
|
|
|
|
var results = await repository.GetDutyCompletionRecords(expac, cancellationToken);
|
|
|
|
var user = await dbContext.Users.FirstOrDefaultAsync(x => x.UserHash == userHash && x.WorldId == worldId, cancellationToken);
|
|
|
|
return Ok(results);
|
|
|
|
if (user != null)
|
|
|
|
|
|
|
|
return Ok(user.UserName);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return NotFound();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogError(ex, "Error getting Duty Completion Records for {expac}: {errorMessage}", expac, ex.Message);
|
|
|
|
_logger.LogError(ex, "Error obtaining user name for World Id {worldId} and hash {userHash}: {errorMessage}", worldId, userHash, ex.Message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return StatusCode(500);
|
|
|
|
return StatusCode(500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet("UserName/{worldId}/{userHash}")]
|
|
|
|
[HttpGet("DeepDungeonRecords")]
|
|
|
|
public async Task<ActionResult> GetUserName(int worldId, string userHash, CancellationToken cancellationToken)
|
|
|
|
public async Task<ActionResult> GetDeepDungeonRecords(CancellationToken cancellationToken)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
using var scope = _serviceScopeFactory.CreateScope();
|
|
|
|
using var scope = _serviceScopeFactory.CreateScope();
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<ExpedienceContext>();
|
|
|
|
var repository = scope.ServiceProvider.GetService<IExpedienceRepository>();
|
|
|
|
|
|
|
|
|
|
|
|
var user = await dbContext.Users.FirstOrDefaultAsync(x => x.UserHash == userHash && x.WorldId == worldId, cancellationToken);
|
|
|
|
var results = await repository.GetDeepDungeonRecords(cancellationToken);
|
|
|
|
if (user != null)
|
|
|
|
return Ok(results);
|
|
|
|
return Ok(user.UserName);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return NotFound();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogError(ex, "Error obtaining user name for World Id {worldId} and hash {userHash}: {errorMessage}", worldId, userHash, ex.Message);
|
|
|
|
_logger.LogError(ex, "Error getting Deep Dungeon Records: {errorMessage}", ex.Message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return StatusCode(500);
|
|
|
|
return StatusCode(500);
|
|
|
|
|