BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
function onActionBegin(args) {
if (args.requestType == "eventCreate") {
// Server validation post
var UserData = args.data[0];
$.ajax({
url: '/Home/CRUDData/',
data: JSON.stringify(UserData),
type: 'POST',
async: false,
traditional: true,
contentType: 'application/json',
success: function (data) {
if (data.status && data.status != "") {
if (data.status != "Validation Passed") {
// If server validation fail we prevent the appointment save in db by using args.cancel = true
args.cancel = true;
if (!ej.base.isNullOrUndefined(document.querySelector('.e-schedule-dialog'))) {
var schObj = document.querySelector('.e-schedule').ej2_instances[0];
schObj.uiStateValues.isBlock = true;
}
}
// Show the message in dialog
dlgObj.content = data.status;
dlgObj.show();
}
},
failure: function (data) {
alert("Failure occurred")
},
error: function (data) {
alert("Error Occurred")
}
});
}
}
function onActionComplete(args) {
if (!ej.base.isNullOrUndefined(document.querySelector('.e-schedule-dialog'))) {
var diaObj = document.querySelector('.e-schedule-dialog').ej2_instances[0];
var schObj = document.querySelector('.e-schedule').ej2_instances[0];
schObj.uiStateValues.isBlock = false;
diaObj.hide();
}
} |
[HttpPost]
public ActionResult CRUDData([FromBody]ScheduleEvent model)
{
var status = "";
if (model != null)
{
var data = _context.ScheduleEvents.Where(app => (app.Subject == model.Subject)).ToList();
if (data.Count > 0)
{
status = "Please Save the appointment with differnt Subject. The provided subject already exist in db";
}
else
{
status = "Validation Passed";
}
}
else
{
status = "failure";
}
return Json(new { status = status });
} |