我在View中具有Bootstrap模式。
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><span id="eventTitle"></span></h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<button id="btnDelete" class="btn btn-default btn-sm pull-right">
<span class="fa fa-remove"></span> Sil
</button>
<button id="btnEdit" class="btn btn-default btn-sm pull-right" style="margin-right:5px;">
<span class="fa fa-edit"></span> Düzenle
</button>
<p id="pDetails"></p>
</div>
</div>
</div>
</div>
删除按钮的脚本。
$('#btnDelete').click(function () {
if (selectedEvent != null && confirm('Are you sure?')) {
$.ajax({
type: "POST",
url: '/Planner/DeleteEvent',
data: { 'eventID': selectedEvent.eventID },
success: function (data) {
if (data.status) {
//Refresh the calender
FetchEventAndRenderCalendar();
$('#myModal').modal('hide');
}
},
error: function () {
alert('Failed');
}
})
}
})
这是删除操作的控制器
[HttpPost]
public JsonResult DeleteEvent(int eventID)
{
var status = false;
using (eteklifn_netEntities dc = new eteklifn_netEntities())
{
var v = dc.TBLEVENTS.Where(a => a.EventID == eventID).FirstOrDefault();
if (v != null)
{
dc.TBLEVENTS.Remove(v);
dc.SaveChanges();
status = true;
}
}
return new JsonResult { Data = new { status = status } };
}
单击事件时,模式将打开。单击btnDelete按钮时,事件ID进入DeleteEvent Controller。控制器成功从数据库中删除事件,并返回status = true。但是仍然会失败警报。而且在某种程度上我不了解页面刷新。
答案 0 :(得分:0)
var troposLogs = new List<TroposLog>();
var log = new TroposLog();
log.Created = DateTime.ParseExact("2018.07.26 10:35:06:7889", @"yyyy\.MM\.dd HH\:mm\:ss\:ffff", CultureInfo.InvariantCulture);
log.SessionId = "4d50b064-d269-4256-a187-82a3f9402735";
log.Message = "Client successfully got the transaction result";
troposLogs.Add(log);
log = new TroposLog();
log.Created = DateTime.ParseExact("2018.07.26 10:35:07:1219", @"yyyy\.MM\.dd HH\:mm\:ss\:ffff", CultureInfo.InvariantCulture);
log.SessionId = "4d50b064-d269-4256-a187-82a3f9402735";
log.Message = "Start Session ThreadSuccess (c0c2311a-b509-4e6e-a236-80e2d86f2647)";
log.UserName = "DAIW";
troposLogs.Add(log);
log = new TroposLog();
log.Created = DateTime.ParseExact("2018.07.26 10:35:06:9169", @"yyyy\.MM\.dd HH\:mm\:ss\:ffff", CultureInfo.InvariantCulture);
log.SessionId = "4d50b064-d269-4256-a187-82a3f9402735";
log.Message = "Run Transaction Thread (SOCS)... Success";
log.ActionName = "SOCS";
troposLogs.Add(log);
var ordered = troposLogs.OrderBy(m => m.UserName == null)
.ThenBy(m => m.UserName)
.ThenBy(m => m.SessionId)
.ThenBy(m => m.Created)
.ToArray();