This commit is contained in:
@@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using rockfishCore.Models;
|
||||
using rockfishCore.Util;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace rockfishCore.Controllers
|
||||
{
|
||||
@@ -20,19 +21,26 @@ namespace rockfishCore.Controllers
|
||||
ct = context;
|
||||
}
|
||||
|
||||
public class dtoFetchRequest
|
||||
{
|
||||
[Required]
|
||||
public string DbId { get; set; }
|
||||
}
|
||||
|
||||
//### CUSTOMER ROUTE CALLED FROM RAVEN ####
|
||||
[HttpGet("{dbid}")]
|
||||
public async Task<IActionResult> Get([FromRoute] string dbid)
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> PostLicenseFetchRequest([FromBody] dtoFetchRequest fetchRequest)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
string FetchRequestDbId=fetchRequest.DbId;
|
||||
|
||||
string LicenseKey = null;
|
||||
//check for a key for this dbid, first check licensed then check trial
|
||||
var PurchasedLicense = await ct.License.Where(z => z.DbId == dbid && z.Fetched == false).FirstOrDefaultAsync();
|
||||
var PurchasedLicense = await ct.License.Where(z => z.DbId == FetchRequestDbId && z.Fetched == false).FirstOrDefaultAsync();
|
||||
if (PurchasedLicense != null)
|
||||
{
|
||||
LicenseKey = PurchasedLicense.Key;
|
||||
@@ -43,7 +51,7 @@ namespace rockfishCore.Controllers
|
||||
else
|
||||
{
|
||||
//is there an Approved UnFetched trial request for this DB ID?
|
||||
var req = await ct.TrialRequest.Where(z => z.DbId == dbid && z.DtFetched == null && z.Status == TrialRequest.TrialRequestStatus.Approved).FirstOrDefaultAsync();
|
||||
var req = await ct.TrialRequest.Where(z => z.DbId == FetchRequestDbId && z.DtFetched == null && z.Status == TrialRequest.TrialRequestStatus.Approved).FirstOrDefaultAsync();
|
||||
if (req == null)
|
||||
{
|
||||
return NotFound();
|
||||
|
||||
Reference in New Issue
Block a user