asp.net-mvc - mvc 完整日历删除事件
问题描述
我正在实现一个日历,但在删除日历事件的部分,它给了我一个错误,我无法删除这个相同的事件。
JavaScript 代码
$('#btnDelete').click(function () {
if (selectedEvent != null && confirm('Are you sure?')) {
$.ajax({
type: "POST",
url: '/CalendárioReservas/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 (HotelEntities dc = new HotelEntities())
{
var v = dc.Reserva.Where(a => a.ID_Reserva == eventID).FirstOrDefault();
if (v != null)
{
dc.Reserva.Remove(v);
dc.SaveChanges();
status = true;
}
}
return new JsonResult { Data = new { status = status } };
}
解决方案
推荐阅读
- python - 如何从另一个文件设置另一个文件上的字典的值?
- vba - 如何使用 vba 脚本检查 MS Word 页边距?
- mysql - Mysql返回所有部门的所有状态计数如果为null则返回0
- visual-studio-2017 - Visual Studio 2017 在代码编辑器中没有背景
- java - 无法启动 Nifi JAVA_HOME 无效或权限被拒绝错误
- angularjs - 没有得到对 html 视图页面的响应
- javascript - Service Worker 未在 gh-pages 托管网站上注册
- python - App Engine 继续提供以前的 Python 版本
- c++ - C++ 智能指针错误
- javascript - 在 Angular 1.6 中使用外部库时的 ReferenceError