首页 > 解决方案 > 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 } };
        }

标签: asp.net-mvcfullcalendarfullcalendar-scheduler

解决方案


推荐阅读