This commit is contained in:
@@ -76,7 +76,8 @@ namespace rockfishCore.Controllers
|
||||
return NotFound();
|
||||
//DO APPROVE
|
||||
//check not already processed and ignore if so
|
||||
if(trial.DtProcessed!=null){
|
||||
if (trial.DtProcessed != null)
|
||||
{
|
||||
//already processed, nothing to do here
|
||||
return BadRequest("Already processed");
|
||||
}
|
||||
@@ -97,7 +98,7 @@ namespace rockfishCore.Controllers
|
||||
}
|
||||
|
||||
|
||||
//Reject
|
||||
//Reject
|
||||
[HttpPost("reject/{id}")]
|
||||
public async Task<IActionResult> RejectTrial([FromRoute] long id, [FromQuery] string rejectReason)
|
||||
{
|
||||
@@ -108,24 +109,26 @@ namespace rockfishCore.Controllers
|
||||
return NotFound();
|
||||
//DO REJECT
|
||||
//check not already processed and ignore if so
|
||||
if(trial.DtProcessed!=null){
|
||||
if (trial.DtProcessed != null)
|
||||
{
|
||||
//already processed, nothing to do here
|
||||
return BadRequest("Already processed");
|
||||
}
|
||||
//generate license key and insert in record
|
||||
trial.RejectReason=rejectReason;
|
||||
trial.RejectReason = rejectReason;
|
||||
trial.Status = TrialRequest.TrialRequestStatus.Rejected;
|
||||
trial.DtProcessed = DateUtil.NowAsEpoch();
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//send approved email to user
|
||||
string reason=string.Empty;
|
||||
if(!string.IsNullOrWhiteSpace(rejectReason)){
|
||||
reason=$"The request was rejected due to:\r\n{rejectReason}";
|
||||
string reason = string.Empty;
|
||||
if (!string.IsNullOrWhiteSpace(rejectReason))
|
||||
{
|
||||
reason = $"The request was rejected due to:\r\n{rejectReason}";
|
||||
}
|
||||
var body = $"Your trial license request was not approved.\r\n{reason}";
|
||||
//send confirmation email
|
||||
RfMail.SendMessage("support@ayanova.com", trial.Email, "AyaNova trial request approved", body, false);
|
||||
RfMail.SendMessage("support@ayanova.com", trial.Email, "AyaNova trial request not approved", body, false);
|
||||
|
||||
return Ok(trial);
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ app.api = (function () {
|
||||
update,
|
||||
uploadFile,
|
||||
putAction,
|
||||
postAction,
|
||||
createLicense,
|
||||
getLicenseRequests,
|
||||
generateFromRequest,
|
||||
@@ -73,7 +74,7 @@ app.api = (function () {
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + errorThrown,
|
||||
msg: textStatus + "\n" + jqXHR.responseText + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
});
|
||||
}
|
||||
@@ -96,7 +97,7 @@ app.api = (function () {
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + errorThrown,
|
||||
msg: textStatus + "\n" + jqXHR.responseText + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
});
|
||||
}
|
||||
@@ -135,7 +136,7 @@ app.api = (function () {
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + errorThrown,
|
||||
msg: textStatus + "\n" + jqXHR.responseText + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
});
|
||||
}
|
||||
@@ -156,7 +157,7 @@ app.api = (function () {
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + errorThrown,
|
||||
msg: textStatus + "\n" + jqXHR.responseText + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
});
|
||||
}
|
||||
@@ -210,7 +211,7 @@ app.api = (function () {
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + errorThrown,
|
||||
msg: textStatus + "\n" + jqXHR.responseText + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
});
|
||||
}
|
||||
@@ -237,7 +238,7 @@ app.api = (function () {
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
callback({
|
||||
error: 1,
|
||||
msg: textStatus + "\n" + errorThrown,
|
||||
msg: textStatus + "\n" + jqXHR.responseText + "\n" + errorThrown,
|
||||
error_detail: {}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,128 +8,132 @@
|
||||
/*global $, app */
|
||||
|
||||
app.trialEdit = (function () {
|
||||
'use strict';
|
||||
//---------------- BEGIN MODULE SCOPE VARIABLES --------------
|
||||
var
|
||||
stateMap = {},
|
||||
onApprove, onReject, onDelete,
|
||||
configModule, initModule;
|
||||
//----------------- END MODULE SCOPE VARIABLES ---------------
|
||||
"use strict";
|
||||
//---------------- BEGIN MODULE SCOPE VARIABLES --------------
|
||||
var stateMap = {},
|
||||
onApprove,
|
||||
onReject,
|
||||
onDelete,
|
||||
configModule,
|
||||
initModule;
|
||||
//----------------- END MODULE SCOPE VARIABLES ---------------
|
||||
|
||||
//------------------- BEGIN EVENT HANDLERS -------------------
|
||||
|
||||
//------------------- BEGIN EVENT HANDLERS -------------------
|
||||
//ONAPPROVE
|
||||
//
|
||||
onApprove = function (event) {
|
||||
event.preventDefault();
|
||||
$.gevent.publish("app-clear-error");
|
||||
|
||||
//ONAPPROVE
|
||||
//
|
||||
onApprove = function (event) {
|
||||
event.preventDefault();
|
||||
$.gevent.publish('app-clear-error');
|
||||
|
||||
var isFetched=$('#fetched').prop('checked')
|
||||
app.api.postAction("trial/approve/" + stateMap.id, function (res) {
|
||||
if (res.error) {
|
||||
$.gevent.publish("app-show-error", res.msg);
|
||||
} else {
|
||||
app.utilB.formData(res);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
app.api.postAction('trial/fetched/' + stateMap.id + "/" + isFetched, function (res) {
|
||||
if (res.error) {
|
||||
$.gevent.publish('app-show-error', res.msg);
|
||||
}
|
||||
});
|
||||
return false; //prevent default?
|
||||
};
|
||||
|
||||
return false; //prevent default?
|
||||
};
|
||||
|
||||
//ONREJECT
|
||||
//
|
||||
onReject = function (event) {
|
||||
event.preventDefault();
|
||||
$.gevent.publish('app-clear-error');
|
||||
|
||||
var isFetched=$('#fetched').prop('checked')
|
||||
|
||||
// var submitData = { isFetched: isFetched };
|
||||
app.api.putAction('trial/fetched/' + stateMap.id + "/" + isFetched, function (res) {
|
||||
if (res.error) {
|
||||
$.gevent.publish('app-show-error', res.msg);
|
||||
}
|
||||
});
|
||||
|
||||
return false; //prevent default?
|
||||
};
|
||||
|
||||
|
||||
//ONDELETE
|
||||
//
|
||||
onDelete = function (event) {
|
||||
event.preventDefault();
|
||||
$.gevent.publish('app-clear-error');
|
||||
var r = confirm("Are you sure you want to delete this record?");
|
||||
if (r == true) {
|
||||
app.api.remove('trial/' + stateMap.id, function (res) {
|
||||
if (res.error) {
|
||||
$.gevent.publish('app-show-error', res.msg);
|
||||
} else {
|
||||
page('#!/trials');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
//ONREJECT
|
||||
//
|
||||
onReject = function (event) {
|
||||
event.preventDefault();
|
||||
$.gevent.publish("app-clear-error");
|
||||
|
||||
var reason = $("#rejectReason").val();
|
||||
if (reason) {
|
||||
reason = "?rejectReason=" + reason;
|
||||
}
|
||||
var r = confirm("Are you sure you want to reject this request?");
|
||||
if (r == true) {
|
||||
app.api.postAction("trial/reject/" + stateMap.id + reason, function (
|
||||
res
|
||||
) {
|
||||
if (res.error) {
|
||||
$.gevent.publish("app-show-error", res.msg);
|
||||
} else {
|
||||
return false;
|
||||
app.utilB.formData(res);
|
||||
}
|
||||
return false; //prevent default?
|
||||
};
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false; //prevent default?
|
||||
};
|
||||
|
||||
//-------------------- END EVENT HANDLERS --------------------
|
||||
|
||||
//------------------- BEGIN PUBLIC METHODS -------------------
|
||||
|
||||
|
||||
//CONFIGMODULE
|
||||
//
|
||||
configModule = function (context) {
|
||||
stateMap.context = context.context;
|
||||
if (stateMap.context.params.id) {
|
||||
stateMap.id = stateMap.context.params.id;
|
||||
//ONDELETE
|
||||
//
|
||||
onDelete = function (event) {
|
||||
event.preventDefault();
|
||||
$.gevent.publish("app-clear-error");
|
||||
var r = confirm("Are you sure you want to delete this record?");
|
||||
if (r == true) {
|
||||
app.api.remove("trial/" + stateMap.id, function (res) {
|
||||
if (res.error) {
|
||||
$.gevent.publish("app-show-error", res.msg);
|
||||
} else {
|
||||
page("#!/trials");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false; //prevent default?
|
||||
};
|
||||
|
||||
//INITMODULE
|
||||
//
|
||||
initModule = function ($container) {
|
||||
if (typeof $container === 'undefined') {
|
||||
$container = $('#app-shell-main-content');
|
||||
}
|
||||
//-------------------- END EVENT HANDLERS --------------------
|
||||
|
||||
$container.html(Handlebars.templates['app.trialEdit']({}));
|
||||
//------------------- BEGIN PUBLIC METHODS -------------------
|
||||
|
||||
document.title = 'trial ';
|
||||
//CONFIGMODULE
|
||||
//
|
||||
configModule = function (context) {
|
||||
stateMap.context = context.context;
|
||||
if (stateMap.context.params.id) {
|
||||
stateMap.id = stateMap.context.params.id;
|
||||
}
|
||||
};
|
||||
|
||||
//fetch existing record
|
||||
app.api.get('trial/' + stateMap.id, function (res) {
|
||||
if (res.error) {
|
||||
$.gevent.publish('app-show-error', res.msg);
|
||||
} else {
|
||||
//fill out form
|
||||
app.utilB.formData(res);
|
||||
}
|
||||
});
|
||||
//Context menu
|
||||
app.nav.contextClear();
|
||||
app.nav.contextAddLink("trials/", "List", "");
|
||||
//INITMODULE
|
||||
//
|
||||
initModule = function ($container) {
|
||||
if (typeof $container === "undefined") {
|
||||
$container = $("#app-shell-main-content");
|
||||
}
|
||||
|
||||
$container.html(Handlebars.templates["app.trialEdit"]({}));
|
||||
|
||||
document.title = "trial ";
|
||||
|
||||
// bind actions
|
||||
$('#btn-save').bind('click', onSave);
|
||||
$('#btn-delete').bind('click', onDelete);
|
||||
};
|
||||
//fetch existing record
|
||||
app.api.get("trial/" + stateMap.id, function (res) {
|
||||
if (res.error) {
|
||||
$.gevent.publish("app-show-error", res.msg);
|
||||
} else {
|
||||
//fill out form
|
||||
app.utilB.formData(res);
|
||||
}
|
||||
});
|
||||
//Context menu
|
||||
app.nav.contextClear();
|
||||
app.nav.contextAddLink("trials/", "List", "");
|
||||
|
||||
// bind actions
|
||||
$("#btn-reject").bind("click", onReject);
|
||||
$("#btn-approve").bind("click", onApprove);
|
||||
$("#btn-delete").bind("click", onDelete);
|
||||
};
|
||||
|
||||
// RETURN PUBLIC METHODS
|
||||
//
|
||||
return {
|
||||
configModule: configModule,
|
||||
initModule: initModule
|
||||
};
|
||||
//------------------- END PUBLIC METHODS ---------------------
|
||||
}());
|
||||
// RETURN PUBLIC METHODS
|
||||
//
|
||||
return {
|
||||
configModule: configModule,
|
||||
initModule: initModule
|
||||
};
|
||||
//------------------- END PUBLIC METHODS ---------------------
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user