From c1efb235fe950f98a9860e8448bef121081ec14f Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 17 Jun 2020 23:28:05 +0000 Subject: [PATCH] --- Controllers/RvlController.cs | 9 +++++++- Controllers/SiteController.cs | 12 +++++++---- wwwroot/js/app.ravLicense.js | 21 ++++++++++--------- .../js/templates/app.ravLicense.handlebars | 2 +- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Controllers/RvlController.cs b/Controllers/RvlController.cs index 5bc4b65..de6553a 100644 --- a/Controllers/RvlController.cs +++ b/Controllers/RvlController.cs @@ -134,7 +134,14 @@ namespace rockfishCore.Controllers //inform customer and return no content var body = $"Thank you for your purchase!\nYour AyaNova license key is ready to be installed.\nAyaNova will fetch it automatically within 24 hours or you can force it to fetch immediately from the License page in AyaNova now.\n---\n{l}"; //send license email - RfMail.SendMessage("support@ayanova.com", Customer.AdminEmail, "AyaNova license key", body, false); +#if (DEBUG) + RfMail.SendMessage("support@ayanova.com", "cardjohn@ayanova.com", "AyaNova license key", body, false); +#else +throw new System.Exception("UNCOMMENT THIS FOR PRODUCTION"); + // RfMail.SendMessage("support@ayanova.com", Customer.AdminEmail, "AyaNova license key", body, false); +#endif + + return NoContent(); } catch (Exception ex) diff --git a/Controllers/SiteController.cs b/Controllers/SiteController.cs index 552e90f..d53f32d 100644 --- a/Controllers/SiteController.cs +++ b/Controllers/SiteController.cs @@ -102,15 +102,19 @@ namespace rockfishCore.Controllers } //Get api/site/77/name - [HttpGet("{id}/customerinfo")] - public async Task GetCustomerInfo([FromRoute] long id) + [HttpGet("{id}/newlicenseinfo")] + public async Task GetNewLicenseInfo([FromRoute] long id) { if (!ModelState.IsValid) { return BadRequest(ModelState); } - var custId = await ct.Site.AsNoTracking().Where(z => z.Id == id).Select(z => z.CustomerId).FirstAsync(); - var custInfo = await ct.Customer.AsNoTracking().Where(z => z.Id == custId).Select(z => new { z.Name, z.Id }).SingleAsync(); + var site = await ct.Site.AsNoTracking().Where(z => z.Id == id).FirstOrDefaultAsync(); + if (site == null) + { + return NotFound(); + } + var custInfo = await ct.Customer.AsNoTracking().Where(z => z.Id == site.CustomerId).Select(z => new { z.Name, z.Id, dbid = site.DbId }).SingleAsync(); return Ok(custInfo); } diff --git a/wwwroot/js/app.ravLicense.js b/wwwroot/js/app.ravLicense.js index 554bbd2..49aa351 100644 --- a/wwwroot/js/app.ravLicense.js +++ b/wwwroot/js/app.ravLicense.js @@ -68,15 +68,15 @@ app.ravLicense = (function () { //clean up the data before submit //submit - alert("STUB submit"); - // app.api.createRavLicense(submitData, function (res) { - // if (res.error) { - // $.gevent.publish('app-show-error', res.msg); - // } else { - // $('#key').val(res); - // return false; - // } - // }); + // alert("STUB submit"); + app.api.createRavLicense(submitData, function (res) { + if (res.error) { + $.gevent.publish('app-show-error', res.msg); + } else { + $('#key').val(res); + return false; + } + }); return false; //prevent default }; @@ -135,11 +135,12 @@ app.ravLicense = (function () { //get company name to pre-fill regto //api/site/77/name - app.api.get("site/" + stateMap.id + "/customerinfo", function (res) { + app.api.get("site/" + stateMap.id + "/newlicenseinfo", function (res) { if (res.error) { $.gevent.publish("app-show-error", res.msg); } else { $("#registeredTo").val(res.name); + $("#dbId").val(res.dbId); } }); diff --git a/wwwroot/js/templates/app.ravLicense.handlebars b/wwwroot/js/templates/app.ravLicense.handlebars index ecc8053..4726880 100644 --- a/wwwroot/js/templates/app.ravLicense.handlebars +++ b/wwwroot/js/templates/app.ravLicense.handlebars @@ -14,7 +14,7 @@
- +