This commit is contained in:
@@ -22,7 +22,7 @@ namespace rockfishCore.Controllers
|
||||
|
||||
[HttpGet("{dbid}")]
|
||||
public async Task<IActionResult> Get([FromRoute] Guid dbid)
|
||||
{
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
@@ -40,10 +40,10 @@ namespace rockfishCore.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
//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();
|
||||
//is there a valid trial request
|
||||
var req = await ct.TrialRequest.Where(z => z.DbId == dbid && z.DtFetched == null && z.Status == TrialRequest.TrialRequestStatus.Approved).FirstOrDefaultAsync();
|
||||
LicenseKey = req.Key;
|
||||
req.DtFetched = DateUtil.NowAsEpoch();
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
@@ -45,26 +45,30 @@ namespace rockfishCore.Controllers
|
||||
|
||||
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
|
||||
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
|
||||
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())
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("RvRController:Post - TODO: Test MustBeOlderThan date code");
|
||||
|
||||
//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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user