Member 10875212 Ответов: 0

Не удается привязать планировщик fullcalendar-ресурсы из базы данных и entity framework


i succeed in binding events at full calendar but i want to bind the data by Rooms or Classes but i can't i am using Entity Framework - ASP.Net - SQL Server
so any one can help me to Bind Resources as this Example but by code and Entity 
<a href="https://fullcalendar.io/scheduler/">Scheduler | FullCalendar</a>[<a href="https://fullcalendar.io/scheduler/" target="_blank" title="New Window">^</a>]

Мое Кодирование
<asp:Content ID="Content5" ContentPlaceHolderID="maincontent" runat="server">

    <script type="text/javascript">
        $(document).ready(function () {
            $.ajax({
                type: "POST",
                contentType: "application/json",
                data: "{}",
                url: "Default.aspx/GetEvents",
                dataType: "json",
                success: function (data) {
                    $('div[id*=fullcal]').fullCalendar({
                        header: {
                            left: 'prev,next today',
                            center: 'title',
                            // right: 'timelineDay,agendaTwoDay,timelineThreeDays,month,agendaWeek,agendaDay,listWeek'//New1-agendaTwoDay
                            right: 'timelineDay,timelineThreeDays,agendaWeek,month,listWeek'
                        },
                        aspectRatio: 1.8,//New4
                        scrollTime: '00:00', //New5 undo default 6am scrollTime
                        // defaultView: 'agendaDay',//New2
                        defaultView: 'timelineDay',//New2
                        views: {//New3
                            timelineThreeDays: {
                                type: 'timeline',
                                duration: { days: 3 }
                            }
                        },

                        //views: {//New3
                        //    agendaTwoDay: {
                        //        type: 'agenda',
                        //        duration: { days: 2 },

                                // views that are more than a day will NOT do this behavior by default
                                // so, we need to explicitly enable it
                        //        groupByResource: true

                        //        //// uncomment this line to group by day FIRST with resources underneath
                        //        //groupByDateAndResource: true
                        //    }
                        //},

                        //// uncomment this line to hide the all-day slot
                        //allDaySlot: false,
                        schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives',//New for Licence
                        eventLimit: true, // allow "more" link when too many events
                        editable: true,
                        //new Resourses
                        resourceLabelText: 'Rooms',
                        resources: [
                            { id: 'a', title: 'Auditorium A' },
                            { id: 'b', title: 'Auditorium B', eventColor: 'green' },
                            { id: 'c', title: 'Auditorium C', eventColor: 'orange' },
                          
                        ],
                        //Resourses
                        events: $.map(data.d, function (item, i) {
                            var event = new Object();
                            event.id = item.EventID;
                            event.start = new Date(item.StartDate);
                            event.end = new Date(item.EndDate);
                            event.title = item.EventName;
                            event.url = item.Url;
                            event.ImageType = item.ImageType;
                            //new 
                            event.resourceId = item.resourceId;
                            return event;
                        }), eventRender: function (event, eventElement) {
                            if (event.ImageType) {
                                if (eventElement.find('span.fc-event-time').length) {
                                    eventElement.find('span.fc-event-time').before($(GetImage(event.ImageType)));
                                } else {
                                    eventElement.find('span.fc-event-title').before($(GetImage(event.ImageType)));
                                }
                            }
                        },
                        loading: function (bool) {
                            if (bool) $('#loading').show();
                            else $('#loading').hide();
                        }
                    });
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    debugger;
                }
            });
            $('#loading').hide();
            $('div[id*=fullcal]').show();
        });
        function GetImage(type) {
            if (type == 0) {
                return "<br/><img src = 'Styles/Images/attendance.png' style='width:24px;height:24px'/><br/>"
            }
            else if (type == 1) {
                return "<br/><img src = 'Styles/Images/not_available.png' style='width:24px;height:24px'/><br/>"
            }
            else
                return "<br/><img src = 'Styles/Images/not_available.png' style='width:24px;height:24px'/><br/>"
        }

    </script>
    <div id="loading">
        <img src="Styles/images/loading_wh.gif" />
    </div>
    <div id="fullcal">
    </div>
</asp:Content>




Код C#
[WebMethod]
      public static IList GetEvents()
      {
          BMTSContext dbcontecxt = new BMTSContext();

          var events = from ev in dbcontecxt.SchedualedCourses
                       select new
                       {
                           ev.CourseLevels.EnName,
                           // Convert.ToDateTime(ev.StartDate.ToString()).ToString("MM/dd/yyyy HH:mm:ss"),
                           ev.StartDate,
                           ev.EndDate,
                           //ev.ImageType,
                           //ev.Url
                       };
          return events.ToList();

      }
  }


Что я уже пробовал:

so any one can help me to Bind Resources Full Calander 

0 Ответов