More subscription stuff

This commit is contained in:
2022-08-26 23:01:19 +00:00
parent adcc07c8b9
commit c9adfbb656
3 changed files with 71 additions and 27 deletions

View File

@@ -74,7 +74,13 @@ namespace rockfishCore.Controllers
//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((RavenKeyFactory.TRIAL_PERIOD_DAYS * -1)));
long MustBeOlderThan = 0;
if (r.Perpetual)
MustBeOlderThan = DateUtil.DateToEpoch(DateTime.Now.AddDays((RavenKeyFactory.PERPETUAL_TRIAL_PERIOD_DAYS * -1)));
else
MustBeOlderThan = DateUtil.DateToEpoch(DateTime.Now.AddHours((RavenKeyFactory.SUBSCRIPTION_TRIAL_PERIOD_HOURS * -1)));
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");
@@ -86,7 +92,7 @@ namespace rockfishCore.Controllers
NewRequest.DbId = r.DbId;
NewRequest.CompanyName = r.Company;
NewRequest.ContactName = r.Contact;
NewRequest.Perpetual=r.Perpetual;
NewRequest.Perpetual = r.Perpetual;
await ct.TrialRequest.AddAsync(NewRequest);
await ct.SaveChangesAsync();
NewRequest.EmailConfirmCode = NewRequest.Id.ToString() + FetchKeyCode.generate();