This commit is contained in:
2020-06-11 21:28:36 +00:00
parent 9b467d9152
commit 9ebf44f9d5
3 changed files with 36 additions and 18 deletions

View File

@@ -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