This commit is contained in:
@@ -1,10 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using rockfishCore.Models;
|
using rockfishCore.Models;
|
||||||
using rockfishCore.Util;
|
using rockfishCore.Util;
|
||||||
@@ -25,8 +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)
|
||||||
{
|
{
|
||||||
//this is called after a successful check says there is a key below so it's not hammered (in theory)
|
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
{
|
{
|
||||||
return BadRequest(ModelState);
|
return BadRequest(ModelState);
|
||||||
@@ -81,32 +77,32 @@ namespace rockfishCore.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpGet("hello/{dbid}")]
|
// [HttpGet("hello/{dbid}")]
|
||||||
public ActionResult Hello([FromRoute] Guid dbid)
|
// public ActionResult Hello([FromRoute] Guid dbid)
|
||||||
{
|
// {
|
||||||
//check to see if there is anything of note for this server like a new key or a message etc
|
// //check to see if there is anything of note for this server like a new key or a message etc
|
||||||
if (!ModelState.IsValid)
|
// if (!ModelState.IsValid)
|
||||||
{
|
// {
|
||||||
return BadRequest(ModelState);
|
// return BadRequest(ModelState);
|
||||||
}
|
// }
|
||||||
|
|
||||||
//return a json object with results if anything to report
|
// //return a json object with results if anything to report
|
||||||
|
|
||||||
//This is to simulate the scenarios where there is no license to return
|
// //This is to simulate the scenarios where there is no license to return
|
||||||
//either due to no current account / canceled or simply no license exists
|
// //either due to no current account / canceled or simply no license exists
|
||||||
//Changes here must be reflected in RAVEN Util.License.Fetch block
|
// //Changes here must be reflected in RAVEN Util.License.Fetch block
|
||||||
bool bTestStatusOtherThanOk = false;
|
// bool bTestStatusOtherThanOk = false;
|
||||||
if (bTestStatusOtherThanOk)
|
// if (bTestStatusOtherThanOk)
|
||||||
{
|
// {
|
||||||
return Json(new { Status = "NONE", Reason = "No license" });
|
// return Json(new { Status = "NONE", Reason = "No license" });
|
||||||
//return Json(new {Status="Canceled", Reason="Non payment"});
|
// //return Json(new {Status="Canceled", Reason="Non payment"});
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
return Ok(RavenKeyFactory.GetRavenTestKey(dbid));
|
// return Ok(RavenKeyFactory.GetRavenTestKey(dbid));
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using rockfishCore.Models;
|
using rockfishCore.Models;
|
||||||
using rockfishCore.Util;
|
using rockfishCore.Util;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace rockfishCore.Controllers
|
namespace rockfishCore.Controllers
|
||||||
{
|
{
|
||||||
@@ -15,27 +16,56 @@ namespace rockfishCore.Controllers
|
|||||||
[Route("rvr")]
|
[Route("rvr")]
|
||||||
public class RvrController : Controller //RAVEN trial license request
|
public class RvrController : Controller //RAVEN trial license request
|
||||||
{
|
{
|
||||||
private readonly rockfishContext _context;
|
private readonly rockfishContext ct;
|
||||||
|
|
||||||
public RvrController(rockfishContext context)
|
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]
|
[HttpPost]
|
||||||
public ActionResult Get([FromQuery] Guid dbid, [FromQuery] string email, [FromQuery] string regto)
|
public async Task<IActionResult> Post([FromBody] dtoRequest r)
|
||||||
{
|
{
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
{
|
{
|
||||||
return BadRequest(ModelState);
|
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
|
//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
|
//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
|
//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
|
//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
|
//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