This commit is contained in:
2020-06-13 21:42:57 +00:00
parent a306b84c01
commit 2293933953
2 changed files with 36 additions and 10 deletions

View File

@@ -188,14 +188,35 @@ namespace AyaNova.Api.Controllers
{
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "There is an active registered license. Only an unlicensed or trial license database can request a trial key."));
}
try
{
//Send the request to RockFish here (or at least start the job to do it in which case return Accepted instead of no content and update comment above)
var ret = await Core.License.RequestTrialAsync(trialRequest, log);
if (ret == "ok")
{
//Log
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.License, AyaEvent.LicenseTrialRequest), ct);
}
return Ok(ret);
}
catch (Exception ex)
{
Exception rootex = ex;
while (rootex.InnerException != null)
{
rootex = rootex.InnerException;
}
//Send the request to RockFish here (or at least start the job to do it in which case return Accepted instead of no content and update comment above)
var ret = await Core.License.RequestTrialAsync(trialRequest, log);
if (rootex.Message.Contains("E1020"))
{
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, "LICENSE_KEY", rootex.Message));
}
else
{
throw ex;
}
//Log
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.License, AyaEvent.LicenseTrialRequest), ct);
return Ok(ApiOkResponse.Response(ret));
}
}