且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

删除完整日历的事件

更新时间:2023-12-03 14:33:28

' #btnPopupDelete')。click(function(){


function DeleteEvent(EventID){

var dataRow = {
' Id':EventID


}
('#btnPopupDelete').click(function () { function DeleteEvent(EventID) { var dataRow = { 'Id': EventID }


.ajax({
类型:' POST'
url: / Calendar / DeleteEvent
dataType: json
contentType: application / json
data:JSON.stringify(dataRow)
});

}
});
.ajax({ type: 'POST', url: "/Calendar/DeleteEvent", dataType: "json", contentType: "application/json", data: JSON.stringify(dataRow) }); } });





这在CalenderController中:





this in the CalenderController:

public bool DeleteEvent(int Id)
       {
           return DiaryEvent.DeleteEvent(Id);
       }





这个在DiaryEvents中:





and this in the DiaryEvents:

public static bool DeleteEvent(int Id)
        {
            try
            {
                LolaBikeContext db = new LolaBikeContext();
                AppointmentDiary diary = db.AppointmentDiarys.Find(Id);
                db.AppointmentDiarys.Remove(diary);
                db.SaveChanges();
            }
            catch (Exception)
            {
                
                throw;
            }


            return true;
        
        
        }





这个按钮:





this the button:

<button type="button" id="btnPopupDelete" data-dismiss="modal" class="btn btn-danger right ">Delete event</button>





但它没有击中控制器



谢谢



But it doesnt hit the Controller

Thank you






请尝试如下:



Hi

Please try like below: