This commit is contained in:
2020-06-23 18:45:06 +00:00
parent 93db555bb7
commit 2a4e493814

View File

@@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using rockfishCore.Models; using rockfishCore.Models;
using rockfishCore.Util; using rockfishCore.Util;
using System.ComponentModel.DataAnnotations;
namespace rockfishCore.Controllers namespace rockfishCore.Controllers
{ {
@@ -20,19 +21,26 @@ namespace rockfishCore.Controllers
ct = context; ct = context;
} }
public class dtoFetchRequest
{
[Required]
public string DbId { get; set; }
}
//### CUSTOMER ROUTE CALLED FROM RAVEN #### //### CUSTOMER ROUTE CALLED FROM RAVEN ####
[HttpGet("{dbid}")] [HttpPost]
public async Task<IActionResult> Get([FromRoute] string dbid) public async Task<IActionResult> PostLicenseFetchRequest([FromBody] dtoFetchRequest fetchRequest)
{ {
if (!ModelState.IsValid) if (!ModelState.IsValid)
{ {
return BadRequest(ModelState); return BadRequest(ModelState);
} }
string FetchRequestDbId=fetchRequest.DbId;
string LicenseKey = null; string LicenseKey = null;
//check for a key for this dbid, first check licensed then check trial //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) if (PurchasedLicense != null)
{ {
LicenseKey = PurchasedLicense.Key; LicenseKey = PurchasedLicense.Key;
@@ -43,7 +51,7 @@ namespace rockfishCore.Controllers
else else
{ {
//is there an Approved UnFetched trial request for this DB ID? //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) if (req == null)
{ {
return NotFound(); return NotFound();