After saving my event calender I need to refresh the page.
in index:
function SaveEvent(data) {
$.ajax({
type: "POST",
url: '/home/SaveEvent',
data: data,
success: function (data) {
if (data.status) {
//Refresh the calender
FetchEventAndRenderCalendar();
$('#myModalSave').modal('hide');
}
},
error: function () {
alert('Failed');
}
})
}
in home controller:
[HttpPost]
public JsonResult SaveEvent(CalEvents e)
{
var status = false;
if (e.EventId > 0)
{
var v = this.Context.CalEvents.Where(a => a.EventId == e.EventId).FirstOrDefault();
if (v != null)
{
v.theSubject = e.theSubject;
v.theDescription = e.theDescription;
v.theStart = e.theStart;
v.theEnd = e.theEnd;
v.theThemeColor = e.theThemeColor;
v.theIsFullDay = e.theIsFullDay;
}
}
else
{
this.Context.CalEvents.Add(e);
}
this.Context.SaveChanges();
status = true;
return new JsonResult(new {status = status});
}