This commit is contained in:
@@ -22,7 +22,7 @@ namespace rockfishCore.Controllers
|
|||||||
|
|
||||||
[HttpGet("{dbid}")]
|
[HttpGet("{dbid}")]
|
||||||
public async Task<IActionResult> Get([FromRoute] Guid dbid)
|
public async Task<IActionResult> Get([FromRoute] Guid dbid)
|
||||||
{
|
{
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
{
|
{
|
||||||
return BadRequest(ModelState);
|
return BadRequest(ModelState);
|
||||||
@@ -40,10 +40,10 @@ namespace rockfishCore.Controllers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//is it a trial request
|
//is there a valid trial request
|
||||||
var TrialRequest = await ct.TrialRequest.Where(z => z.DbId == dbid && z.DtFetched == null).FirstOrDefaultAsync();
|
var req = await ct.TrialRequest.Where(z => z.DbId == dbid && z.DtFetched == null && z.Status == TrialRequest.TrialRequestStatus.Approved).FirstOrDefaultAsync();
|
||||||
LicenseKey = TrialRequest.Key;
|
LicenseKey = req.Key;
|
||||||
TrialRequest.DtFetched = DateUtil.NowAsEpoch();
|
req.DtFetched = DateUtil.NowAsEpoch();
|
||||||
await ct.SaveChangesAsync();
|
await ct.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,26 +45,30 @@ namespace rockfishCore.Controllers
|
|||||||
|
|
||||||
if (r.DbId == Guid.Empty)
|
if (r.DbId == Guid.Empty)
|
||||||
{
|
{
|
||||||
return BadRequest("DBId invalid");
|
return BadRequest("E1000 - DBId invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
//can't do this if there is a purchased license with this dbid already
|
//can't do this if there is a purchased license with this dbid already
|
||||||
if (await ct.License.Where(z => z.DbId == r.DbId).AnyAsync())
|
if (await ct.License.Where(z => z.DbId == r.DbId).AnyAsync())
|
||||||
{
|
{
|
||||||
return BadRequest("E1000 - Can't trial; there is already a purchased license issued for this database ID");
|
return BadRequest("E1000 - Can't trial; there is already a purchased license issued for this database Id");
|
||||||
}
|
}
|
||||||
|
|
||||||
//if there is an active trial then can't do this
|
System.Diagnostics.Debug.WriteLine("RvRController:Post - TODO: Test MustBeOlderThan date code");
|
||||||
var MustBeOlderThan=DateUtil.DateToEpoch(DateTime.Now.AddDays(-45))
|
|
||||||
if (await ct.TrialRequest.Where(z => z.DbId == r.DbId && z.DtProcessed != null && z.DtProcessed < MustBeOlderThan).AnyAsync())
|
//if there is an active trial for this db then can't do this they must request we re-release it or completely zap the database instead
|
||||||
{
|
var MustBeOlderThan = DateUtil.DateToEpoch(DateTime.Now.AddDays(-45));
|
||||||
|
if (await ct.TrialRequest.Where(z => z.DbId == r.DbId && z.DtProcessed != null && z.DtProcessed > MustBeOlderThan).AnyAsync())
|
||||||
|
{
|
||||||
|
return BadRequest("E1000 - Can't trial; there is already an active trial license issued for this database Id");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Everything seems to be in order, save the request and return ok
|
||||||
|
var NewRequest=new TrialRequest();
|
||||||
|
NewRequest.Email=r.Email;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// //is it a trial request
|
|
||||||
// var TrialRequest = await ct.TrialRequest.Where(z => z.DbId == dbid && z.DtFetched == null).FirstOrDefaultAsync();
|
|
||||||
// LicenseKey = TrialRequest.Key;
|
|
||||||
// TrialRequest.DtFetched = DateUtil.NowAsEpoch();
|
|
||||||
// await ct.SaveChangesAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: closer to release as ROCKFISH might change before then
|
//TODO: closer to release as ROCKFISH might change before then
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using rockfishCore.Util;
|
||||||
|
|
||||||
|
|
||||||
namespace rockfishCore.Models
|
namespace rockfishCore.Models
|
||||||
@@ -11,8 +12,21 @@ namespace rockfishCore.Models
|
|||||||
"dtprocessed integer, status integer default 0 not null, rejectreason text, key text, dtfetched integer" +
|
"dtprocessed integer, status integer default 0 not null, rejectreason text, key text, dtfetched integer" +
|
||||||
")");
|
")");
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
public partial class TrialRequest
|
public partial class TrialRequest
|
||||||
{
|
{
|
||||||
|
public enum TrialRequestStatus{
|
||||||
|
NotSet=0,
|
||||||
|
Approved=1,
|
||||||
|
Rejected=2
|
||||||
|
}
|
||||||
|
public TrialRequest()
|
||||||
|
{
|
||||||
|
DtRequested=DateUtil.NowAsEpoch();
|
||||||
|
EmailValidated=false;
|
||||||
|
Status=TrialRequestStatus.NotSet;
|
||||||
|
}
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public Guid DbId { get; set; }
|
public Guid DbId { get; set; }
|
||||||
public string CompanyName { get; set; }
|
public string CompanyName { get; set; }
|
||||||
@@ -22,7 +36,7 @@ namespace rockfishCore.Models
|
|||||||
public bool EmailValidated { get; set; }
|
public bool EmailValidated { get; set; }
|
||||||
public long? DtRequested { get; set; }
|
public long? DtRequested { get; set; }
|
||||||
public long? DtProcessed { get; set; }
|
public long? DtProcessed { get; set; }
|
||||||
public int Status { get; set; }
|
public TrialRequestStatus Status { get; set; }// status enum 0=notset, 1=approved, 2=rejected
|
||||||
public string RejectReason { get; set; }
|
public string RejectReason { get; set; }
|
||||||
public string Key { get; set; }
|
public string Key { get; set; }
|
||||||
public long? DtFetched { get; set; }
|
public long? DtFetched { get; set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user