MVC完整日历错误

时间:2018-05-14 10:02:03

标签: asp.net-mvc fullcalendar

当我运行我的日历时,我收到了这个错误...我已经在另一个日历中使用了这些方法与另一个表...并且它有效。 ObjectContext实例已被删除,不能再用于需要连接 ...引用GetEvents方法的操作。

模型

public partial class Reserva
{
    public int ID_Reserva { get; set; }
    public int ID_Cliente { get; set; }
    public int ID_Quarto { get; set; }
    public System.DateTime DataEntrada { get; set; }
    public Nullable<System.DateTime> DataSaida { get; set; }
    public int NumeroPessoas { get; set; }
    public Nullable<int> NumeroNoites { get; set; }
    public Nullable<decimal> Preço { get; set; }
    public string Observaçoes { get; set; }

    public virtual Cliente Cliente { get; set; }
    public virtual Quarto Quarto { get; set; }
}

控制器

public JsonResult GetEvents()
{
    using (HotelEntities dc = new HotelEntities())
    {
        var events = dc.Reserva.ToList();
        return new JsonResult { Data = events, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
    }
}

查看

 $(document).ready(function () {
            var events = [];
            var selectedEvent = null;
            FetchEventAndRenderCalendar();
            function FetchEventAndRenderCalendar() {
                events = [];
                $.ajax({
                    type: "GET",
                    url: "/CalendárioReservas/GetEvents",
                    success: function (data) {
                        $.each(data, function (i, v) {
                            events.push({
                                eventID: v.ID_Reserva,
                                clienteID: v.ID_Cliente,
                                quartoID: v.ID_Quarto,
                                inicio: moment(v.DataEntrada),
                                fim: v.DataSaida != null ? moment(v.DataSaida) : null,
                                noites: v.NumeroNoites,
                                pessoas: v.NumeroPessoas,
                                preço: v.Preço,
                                obs: v.Observaçoes
                            });
                        })

                        GenerateCalender(events);
                    },
                    error: function (error) {
                        alert('failed');
                    }
                })
            }

....................................

Error Image

0 个答案:

没有答案