From 2a4e493814f2ef666f1758cb5e2eca6046c47442 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 23 Jun 2020 18:45:06 +0000 Subject: [PATCH] --- Controllers/RvfController.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Controllers/RvfController.cs b/Controllers/RvfController.cs index 6c87a98..0956a76 100644 --- a/Controllers/RvfController.cs +++ b/Controllers/RvfController.cs @@ -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 Get([FromRoute] string dbid) + [HttpPost] + public async Task 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();