This commit is contained in:
@@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using rockfishCore.Models;
|
||||
using rockfishCore.Util;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace rockfishCore.Controllers
|
||||
{
|
||||
@@ -15,27 +16,56 @@ namespace rockfishCore.Controllers
|
||||
[Route("rvr")]
|
||||
public class RvrController : Controller //RAVEN trial license request
|
||||
{
|
||||
private readonly rockfishContext _context;
|
||||
private readonly rockfishContext ct;
|
||||
|
||||
public RvrController(rockfishContext context)
|
||||
{
|
||||
_context = context;
|
||||
ct = context;
|
||||
}
|
||||
|
||||
public class dtoRequest
|
||||
{
|
||||
[Required]
|
||||
public Guid DbId { get; set; }
|
||||
[Required, EmailAddress]
|
||||
public string Email { get; set; }
|
||||
[Required]
|
||||
public string Company { get; set; }
|
||||
[Required]
|
||||
public string Contact { get; set; }
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ActionResult Get([FromQuery] Guid dbid, [FromQuery] string email, [FromQuery] string regto)
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Post([FromBody] dtoRequest r)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (dbid == Guid.Empty)
|
||||
if (r.DbId == Guid.Empty)
|
||||
{
|
||||
return BadRequest("The requested DB ID was empty and not valid");
|
||||
return BadRequest("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");
|
||||
}
|
||||
|
||||
//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())
|
||||
{
|
||||
|
||||
// //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
|
||||
|
||||
//Attempt to match customer by dbid if not then create new customer of trial type for the indicated dbid and regto
|
||||
@@ -46,7 +76,7 @@ namespace rockfishCore.Controllers
|
||||
//If it's a new customer or an existing one with non-matching email then send a verification email to the customer
|
||||
|
||||
//When a response is spotted in email then Rockfish should see it and flag the customer as verified
|
||||
//Probably some general purpose email Verify code would be helpful here as it would likely be useful for all manner of things
|
||||
//Probably some general purpose email Verify code would be helpful here as it would likely be useful for all manner of things
|
||||
|
||||
//When user releases trial in Rockfish a license key will be generated ready for the customers RAVEN to retrieve
|
||||
|
||||
|
||||
Reference in New Issue
Block a user