60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using rockfishCore.Models;
|
|
using rockfishCore.Util;
|
|
|
|
namespace rockfishCore.Controllers
|
|
{
|
|
[Produces("text/plain")]
|
|
[Route("rvf")]
|
|
|
|
public class RvfController : Controller //RAVEN License fetch route
|
|
{
|
|
private readonly rockfishContext _context;
|
|
|
|
public RvfController(rockfishContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
|
|
[HttpGet("{dbid}")]
|
|
public ActionResult Get([FromRoute] Guid dbid)
|
|
{
|
|
if (!ModelState.IsValid)
|
|
{
|
|
return BadRequest(ModelState);
|
|
}
|
|
|
|
//This is to simulate the scenarios where there is no license to return
|
|
//either due to no current account / canceled or simply no license exists
|
|
//Changes here must be reflected in RAVEN Util.License.Fetch block
|
|
bool bTestStatusOtherThanOk = false;
|
|
if (bTestStatusOtherThanOk)
|
|
{
|
|
return Json(new {Status="NONE", Reason="No license"});
|
|
//return Json(new {Status="Canceled", Reason="Non payment"});
|
|
}
|
|
else
|
|
{
|
|
return Ok(RavenKeyFactory.GetRavenTestKey(dbid));
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool LicenseExists(long id)
|
|
{
|
|
return _context.License.Any(e => e.Id == id);
|
|
}
|
|
}
|
|
} |