This is a migrated thread and some comments may be shown as answers.

How to bind scheduler via signalr and linq to sql

3 Answers 134 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 24 May 2016, 08:11 AM

I have seen the demo where you are using SignalR and entity framework to bind to a Kendo scheduler. I have tried using this but have all sorts of problems.

  1. I am using a Edit Template with Kendo drop downs (the data for the drop downs are in Resources section but don't bind - I raised this as a separate question.
  2. I have a number of extra fields in my model. When I click to edit only the standard fields Title, Start End are bound all others have no data

Is there a way to use Linq rather than EF as I'm more familiar with this?

This is my schedular initialisation code...

////initialise scheduler
$("#scheduler").kendoScheduler({
    date: Date.now(),
    timezone: "Europe/London",
    workDayStart: new Date("2013/1/1 08:00 AM"),
    workDayEnd: new Date("2013/1/1 8:00 PM"),
    dateHeaderTemplate: kendo.template("<strong>#=kendo.toString(date, 'ddd dd/M')#</strong>"),
    selectable: true,
    messages: {
        ariaSlotLabel: "Selected from {0:g} to {0:g}",
        showWorkDay: "Show core work hours"
    },
    editable: {
        window: {
            title: "Work Request",
            width: "720px"
        },
        template: $("#customEditorTemplate").html()
    },
    height: 400,
    views: [
        { type: "day", editable: { destroy: false } },
        { type: "week", editable: { destroy: false }, eventHeight: 40 },
        { type: "timeline", editable: { destroy: false }, eventHeight: 40 },
        { type: "timelineWeek", selected: true, majorTick: 1440, minorTickCount: 1, editable: { destroy: false }, eventHeight: 40 },
        { type: "agenda" },
        { type: "month", editable: { destroy: false }, eventHeight: 40 }
    ],
    timezone: "Etc/UTC",
    dataSource: {
        type: "signalr",
        push: function (e) {
            var notification = $("#notification").data("kendoNotification");
            notification.success(e.type);
        },
        transport: {
            signalr: {
                hub: sHub,
                promise: sHubStart,
                server: {
                    read: "read",
                    create: "create",
                    update: "update",
                    destroy: "destroy"
                },
                client: {
                    read: "read",
                    create: "create",
                    update: "update",
                    destroy: "destroy"
                }
            }
        },
        schema: {
            model: {
                id: "wRequestID",
                fields: {
                    wRequestId: {
                        editable: false,
                        from: "WRequestID",
                        type: "number",
                        defaultValue: 0
                    },
                    start: {
                        from: "Start",
                        type: "date",
                        culture: "en-GB"
                    },
                    end: {
                        from: "End",
                        type: "date",
                        culture: "en-GB" },
                    diary: {
                        from: "Diary",
                        type: "object",
                        defaultValue: "UIS"
                    },
                    team: {
                        from: "Team",
                        type: "object"
                    },
                    title: {
                        from: "Title",
                        type: "string",
                        validation: { required: true }
                    },
                    workManager: {
                        from: "WorkManager",
                        type: "object"
                    },
                    assignee: {
                        from: "Assignee",
                        type: "object"
                    },
                    changeRef: {
                        from: "ChangeRef",
                        type: "string",
                        validation: { required: true }
                    },
                    activity: {
                        from: "Activity",
                        type: "string",
                        validation: { required: true }
                    },
                    impactedServers: {
                        from: "ImpactedServers",
                        type: "string",
                        validation: { required: true }
                    },
                    impactedServices: {
                        from: "ImpactedServices",
                        type: "string",
                        validation: { required: true }
                    },
                    isBAU: {
                        from: "IsBAU",
                        type: "boolean",
                        defaultValue: false
                    },
                    projectRef: {
                        from: "ProjectRef",
                        type: "string",
                        validation: { required: true }
                    },
                    notes: {
                        from: "Notes",
                        type: "string"
                    },
                    isOOH: {
                        from: "IsOOH",
                        type: "boolean",
                        defaultValue: false
                    },
                    isAllDay: {
                        from: "IsAllDay",
                        type: "boolean",
                        defaultValue: false
                    },
                    recurrenceRule: {
                        from: "RecurrenceRule",
                        type: "string"
                    },
                    recurrenceId: {
                        from: "RecurrenceID",
                        type: "number"
                    },
                    recurrenceException: {
                        from: "RecurrenceException",
                        type: "string"
                    },
                    startTimezone: {
                        from: "StartTimezone",
                        type: "string"
                    },
                    endTimezone: {
                        from: "EndTimezone",
                        type: "string"
                    }
                }
            },
        },
    },
    resources: [
        {
            field: "team",
            dataSource: [
                { text: "Team 1", value: "Team 1", color: "#f8a398" },
                { text: "Team 2", value: "Team 2", color: "#51a0ed" },
                { text: "Team 3", value: "Team 3", color: "#56ca85" }
            ],
            title: "Team"
        },
        {
            field: "workManager",
            dataSource: [
                { text: "Manager 1", value: "12345", color: "#f8a398" },
                { text: "Manager 2", value: "23456", color: "#51a0ed" },
                { text: "Manager 3", value: "34567", color: "#56ca85" }
            ],
            title: "Work Manager",
        },
        {
            field: "assignee",
            dataSource: [
                { text: "Alex", value: "12345", color: "#f8a398" },
                { text: "Bob", value: "23456", color: "#51a0ed" },
                { text: "Charlie", value: "34567", color: "#56ca85" }
            ],
            title: "Assigned To"
        }
    ],
    edit: function(e) {
        var container = e.container;
 
        /* ACTION: ADD custom button */
        var newButton = $('<a class="k-button" href="#">New button</a>');
 
        //wire its click event
        newButton.click(function(e) { alert("Clicked"); });
 
        //add the button to the container
        var buttonsContainer = container.find(".k-edit-buttons");
        buttonsContainer.append(newButton);
    }
});     

3 Answers, 1 is accepted

Sort by
0
Jon
Top achievements
Rank 1
answered on 24 May 2016, 08:26 AM

#Still getting use to the fact that hitting enter will automatically post even though I just wanted an new line in editor!

 

This is my editor template...

<script id="customEditorTemplate" type="text/x-kendo-template">
    <div class="container-fluid">
        <div class="editor-row form-group-sm">
            <div class="col-sm-5">
                <label for="diary">Diary</label>
                <input type="text" class="form-control" id="diary" name="diary" readonly data-bind="value:diary" value="UIS">             
            </div>
            <div class="col-sm-5 form-group-sm">
                <label for="team">Team</label>
                <select id="team" data-bind="value:team" data-role="dropdownlist"
                        data-value-field="value" data-text-field="text"></select>
            </div>
        </div>
        <div class="editor-row form-group-sm">
            <div class="col-sm-10">
                <label for="title">Title</label>
                <input type="text" class="form-control" id="title" name="title" required="required" data-bind="value:title">
            </div>
        </div>
        <div class="editor-row form-group-sm">
            <div class="col-sm-5">
                <label for="start">Start</label>
                <input type="text"
                        data-role="datetimepicker"
                        data-interval="15"
                        data-type="date"
                        data-bind="value:start,invisible:isAllDay"
                        name="start"/>
                <input type="text"
                        data-type="date"
                        data-role="datepicker"
                        data-bind="value:start,visible:isAllDay"
                        name="start" />
                <span data-bind="text: startTimezone"></span>
                <span data-for="start" class="k-invalid-msg" style="display: none;"></span>
            </div>
            <div class="col-sm-5">
                <label for="end">End</label>
                <input type="text"
                        data-type="date"
                        data-role="datetimepicker"
                        data-bind="value:end,invisible:isAllDay"
                        name="end"
                        data-datecompare-msg="End date should be greater than or equal to the start date" />
                <input type="text"
                        data-type="date"
                        data-role="datepicker"
                        data-bind="value:end,visible:isAllDay"
                        name="end"
                        data-datecompare-msg="End date should be greater than or equal to the start date" />
                <span data-bind="text: endTimezone"></span>
                <span data-bind="text: startTimezone, invisible: endTimezone"></span>
                <span data-for="end" class="k-invalid-msg" style="display: none;"></span>
            </div>
        </div>
        <div class="editor-row form-group-sm">
            <div class="col-sm-3">
                <label for="isAllDay"><input type="checkbox" id="isAllDay" name="isAllDay" data-type="boolean" data-bind="checked:isAllDay"> Anytime</label>
            </div>
            <div class="col-sm-4">
                <label for="isOOH"><input type="checkbox" id="isOOH" name="isOOH" data-type="boolean" data-bind="checked:isOOH"> OOH</label>
            </div>
            <div class="col-sm-3">
                <label for="isBAU"><input type="checkbox" id="isBAU" name="isBAU" data-type="boolean" data-bind="checked:isBAU"> BAU</label>
            </div>
        </div>
        <div class="editor-row form-group-sm">
            <div class="col-sm-5">
                <label for="changeRef">Change Reference</label>
                <input type="text" class="form-control" id="changeRef" name="changeRef" required="required" data-bind="value:changeRef">
            </div>
            <div class="col-sm-5">
                <label for="projectRef">Project Reference</label>
                <input type="text" class="form-control" id="projectRef" name="projectRef" required="required" data-bind="value:projectRef">
            </div>
        </div>
        <div class="editor-row form-group-sm">
            <div class="col-sm-5">
                <label for="workManager">Work Manager</label>
                <select id="workManager" name="workManager" data-bind="value:workManager" data-role="dropdownlist"
                        data-value-field="value" data-text-field="text"></select>
            </div>
            <div class="col-sm-5">
                <label for="assignee">Assignee(s)</label>
                <select id="assignee" name="assignee" class="form-control" date-bind="value:assignee" data-role="dropdownlist"
                        data-value-field="value" data-text-field="text"></select>
            </div>
        </div>
        <div class="editor-row form-group-sm">
            <div class="col-sm-5">
                <label for="impactedServers">Impacted Servers</label>
                <input type="text" class="form-control" id="impactedServers" name="impactedServers" required="required" data-bind="value:impactedServers">
            </div>
            <div class="col-sm-5">
                <label for="impactedServices">ImpactedServices</label>
                <input type="text" class="form-control" id="impactedServices" name="impactedServices" required="required" data-bind="value:impactedServices">
            </div>
        </div>
        <div class="editor-row form-group-sm">
            <div class="col-sm-5">
                <label for="activity">Activity</label>
                <textarea id="activity" name="activity" class="form-control" required="required" data-bind="value:activity"></textarea>
            </div>
            <div class="col-sm-5 form-group-sm">
                <label for="notes">Notes</label>
                <textarea id="notes" name="notes" class="form-control" data-bind="value:notes"></textarea>
            </div>
        </div>
        <div class="editor-row form-group-sm">
            <div class="col-sm-10">
                <label for="recurrenceRule">Repeat</label>
                <div data-bind="value:recurrenceRule" name="recurrenceRule" data-role="recurrenceeditor"></div>  
            </div>
        </div>
    </div>
         
</script>

This my Work Request View Model

Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
 
Public Class WRequestViewModel
    Inherits SchedulerEvent
 
    'This class contains the remaining fields that make up a request but are not needed by the scheduler
 
    Private m_WRequestID As Integer
    Public Property WRequestID() As Integer
        Get
            Return m_WRequestID
        End Get
        Set(value As Integer)
            m_WRequestID = value
        End Set
    End Property
 
 
    Private m_Diary As String
    Public Property Diary() As String
        Get
            Return m_Diary
        End Get
        Set(value As String)
            m_Diary = value
        End Set
    End Property
 
    Private m_Team As String
    Public Property Team() As String
        Get
            Return m_Team
        End Get
        Set(value As String)
            m_Team = value
        End Set
    End Property
 
    Private m_WorkManager As String
    Public Property Workmanager() As String
        Get
            Return m_WorkManager
        End Get
        Set(value As String)
            m_WorkManager = value
        End Set
    End Property
 
 
    Private m_Assignee As String
    Public Property Assignee() As String
        Get
            Return m_Assignee
        End Get
        Set(value As String)
            m_Assignee = value
        End Set
    End Property
 
 
 
    Private m_ChangeRef As String
    Public Property ChangeRef() As String
        Get
            Return m_ChangeRef
        End Get
        Set(value As String)
            m_ChangeRef = value
        End Set
    End Property
 
 
    Private m_ImpactedServers As String
    Public Property ImpactedServers() As String
        Get
            Return m_ImpactedServers
        End Get
        Set(value As String)
            m_ImpactedServers = value
        End Set
    End Property
 
 
    Private m_ImpactedServices As String
    Public Property ImpactedServices() As String
        Get
            Return m_ImpactedServices
        End Get
        Set(value As String)
            m_ImpactedServices = value
        End Set
    End Property
 
 
    Private m_IsBAU As Boolean
    Public Property IsBAU() As Boolean
        Get
            Return m_IsBAU
        End Get
        Set(value As Boolean)
            m_IsBAU = value
        End Set
    End Property
 
 
    Private m_ProjectRef As String
    Public Property ProjectRef() As String
        Get
            Return m_ProjectRef
        End Get
        Set(value As String)
            m_ProjectRef = value
        End Set
    End Property
 
 
    Private m_IsOOH As Boolean
    Public Property IsOOH() As Boolean
        Get
            Return m_IsOOH
        End Get
        Set(value As Boolean)
            m_IsOOH = value
        End Set
    End Property
 
 
    Private m_Notes As String
    Public Property Notes() As String
        Get
            Return m_Notes
        End Get
        Set(value As String)
            m_Notes = value
        End Set
    End Property
 
    Public Function ToEntity() As WorkRequest
        Return New WorkRequest() With {
               .WRequestID = WRequestID,
               .Start = Start,
               .StartTimezone = StartTimezone,
               .[End] = [End],
               .EndTimezone = EndTimezone,
               .Diary = Diary,
               .Team = Team,
               .Title = Title,
               .WorkManager = Workmanager,
               .Assignee = Assignee,
               .ChangeRef = ChangeRef,
               .Description = Description,
               .ImpactedServers = ImpactedServers,
               .ImpactedServices = ImpactedServices,
               .IsBAU = IsBAU,
               .ProjectRef = ProjectRef,
               .Notes = Notes,
               .IsOOH = IsOOH,
               .IsAllDay = IsAllDay,
               .RecurrenceRule = RecurrenceRule,
               .RecurrenceException = RecurrenceException,
               .RecurrenceID = RecurrenceID
            }
    End Function
 
End Class

My Work request Controller

Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.Mvc
Imports Newtonsoft.Json
Imports SupportDiary.Common
 
Namespace Controllers
    Public Class WorkRequestController
        Inherits Controller
 
        ' GET: WorkRequest
        Public Function Index() As ActionResult
            Return Me.Json(WRequestsRepository.All())
        End Function
 
        Public Function Update() As JsonResult
            Dim workRequests = Me.DeserializeObject(Of IEnumerable(Of WRequestViewModel))("wRequests")
 
            If workRequests IsNot Nothing Then
                For Each wRequest In workRequests
                    WRequestsRepository.Update(wRequest)
                Next
            End If
 
            Return Me.Json(workRequests)
        End Function
 
        Public Function Destroy() As JsonResult
            Dim workRequests = Me.DeserializeObject(Of IEnumerable(Of WRequestViewModel))("wRequests")
 
            If workRequests IsNot Nothing Then
                For Each wRequest In workRequests
                    WRequestsRepository.Delete(wRequest)
                Next
            End If
 
            Return Me.Json(workRequests)
        End Function
 
        Public Function Create() As JsonResult
            Dim workRequests = Me.DeserializeObject(Of IEnumerable(Of WRequestViewModel))("wRequests")
 
            If workRequests IsNot Nothing Then
                For Each wRequest In workRequests
                    WRequestsRepository.Insert(wRequest)
                Next
            End If
 
            Return Me.Json(workRequests)
        End Function
 
    End Class
 
End Namespace

My Work Request Repository

Imports System.Collections.Generic
Imports System.Data
Imports System.Linq
Imports System.Web
 
Public NotInheritable Class WRequestsRepository
 
    Private Sub New()
    End Sub
 
    Private Shared UpdateDatabase As Boolean = True
 
    Public Shared Function All() As IList(Of WRequestViewModel)
 
        Dim result = TryCast(HttpContext.Current.Session("wRequests"), IList(Of WRequestViewModel))
 
        'Dim result As IList(Of WRequestViewModel)
 
        'If result Is Nothing OrElse UpdateDatabase Then
        If result Is Nothing Then
            Using dc = New SupportDiaryDataContext()
                result = (From wr In dc.WorkRequests
                          Select New WRequestViewModel With {
                                .WRequestID = wr.WRequestID,
                                .Start = DateTime.SpecifyKind(wr.Start, DateTimeKind.Utc),
                                .[End] = DateTime.SpecifyKind(wr.[End], DateTimeKind.Utc),
                                .StartTimezone = wr.StartTimezone,
                                .EndTimezone = wr.EndTimezone,
                                .Diary = wr.Diary,
                                .Team = wr.Team,
                                .Title = wr.Title,
                                .Workmanager = wr.WorkManager,
                                .Assignee = wr.Assignee,
                                .ChangeRef = wr.ChangeRef,
                                .Description = wr.Description,
                                .ImpactedServers = wr.ImpactedServers,
                                .ImpactedServices = wr.ImpactedServices,
                                .IsBAU = wr.IsBAU,
                                .ProjectRef = wr.ProjectRef,
                                .Notes = wr.Notes,
                                .IsOOH = wr.IsOOH,
                                .IsAllDay = wr.IsAllDay,
                                .RecurrenceRule = wr.RecurrenceRule,
                                .RecurrenceException = wr.RecurrenceException,
                                .RecurrenceID = wr.RecurrenceID
                            }).ToList()
            End Using
 
            HttpContext.Current.Session("wRequests") = result
        End If
 
        Return result
    End Function
 
    Public Shared Function One(predicate As Func(Of WRequestViewModel, Boolean)) As WRequestViewModel
        Return All().FirstOrDefault(predicate)
    End Function
 
    Public Shared Sub Insert(wR As WRequestViewModel)
 
        'If Not UpdateDatabase Then
 
        '    Dim first = All().OrderByDescending(Function(e) e.WRequestID).FirstOrDefault()
 
        '    Dim id = 0
 
        '    If first IsNot Nothing Then
        '        id = first.WRequestID
        '    End If
 
        '    wR.WRequestID = id + 1
 
        '    All().Insert(0, wR)
 
        'Else
        Using dc = New SupportDiaryDataContext()
 
            Dim entity = wR.ToEntity()
 
            dc.WorkRequests.InsertOnSubmit(entity)
            dc.SubmitChanges()
 
            wR.WRequestID = entity.WRequestID
 
        End Using
 
        'End If
 
    End Sub
 
    Public Shared Sub Update(wR As WRequestViewModel)
 
        'If Not UpdateDatabase Then
        Dim target = One(Function(e) e.WRequestID = wR.WRequestID)
 
            If target IsNot Nothing Then
                target.Diary = wR.Diary
                target.Start = wR.Start
                target.[End] = wR.[End]
                target.StartTimezone = wR.StartTimezone
                target.EndTimezone = wR.EndTimezone
                target.Diary = wR.Diary
                target.Team = wR.Team
                target.Title = wR.Title
                target.Workmanager = wR.Workmanager
                target.Assignee = wR.Assignee
                target.ChangeRef = wR.ChangeRef
                target.Description = wR.Description
                target.ImpactedServers = wR.ImpactedServers
                target.ImpactedServices = wR.ImpactedServices
                target.IsBAU = wR.IsBAU
                target.ProjectRef = wR.ProjectRef
                target.Notes = wR.Notes
                target.IsOOH = wR.IsOOH
                target.IsAllDay = wR.IsAllDay
                target.RecurrenceRule = wR.RecurrenceRule
                target.RecurrenceException = wR.RecurrenceException
                target.RecurrenceID = wR.RecurrenceID
            End If
        'Else
        '    Using dc = New SupportDiaryDataContext()
 
        '        Dim entity = wR.ToEntity()
 
        '        dc.WorkRequests.Attach(entity)
 
        '        dc.SubmitChanges()
 
        '    End Using
        'End If
    End Sub
 
    Public Shared Sub Delete(wR As WRequestViewModel)
 
        'If Not UpdateDatabase Then
 
        '    Dim target = One(Function(p) p.WRequestID = wR.WRequestID)
        '    If target IsNot Nothing Then
        '        All().Remove(target)
 
        '        Dim recurrenceExceptions = All().Where(Function(m) m.RecurrenceID = wR.WRequestID).ToList()
 
        '        For Each recurrenceException In recurrenceExceptions
        '            All().Remove(recurrenceException)
        '        Next
        '    End If
 
        'Else
 
        Using dc = New SupportDiaryDataContext()
 
            Dim entity = wR.ToEntity()
 
            dc.WorkRequests.DeleteOnSubmit(entity)
 
            Dim recurrenceExceptions = dc.WorkRequests.Where(Function(r) r.RecurrenceID = entity.WRequestID)
 
            For Each recurrenceException In recurrenceExceptions
                dc.WorkRequests.DeleteOnSubmit(recurrenceException)
            Next
 
            dc.SubmitChanges()
 
        End Using
 
        'End If
    End Sub
End Class

 

My Work Request SignalR

Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
 
Public Class WRequestsSignalR
    Inherits SchedulerEvent
 
    Private m_ID As System.Nullable(Of Guid)
    Public Property ID() As System.Nullable(Of Guid)
        Get
            Return m_ID
        End Get
        Set(value As System.Nullable(Of Guid))
            m_ID = value
        End Set
    End Property
 
    Private m_CreatedAt As System.Nullable(Of DateTime)
    Public Property CreatedAt() As System.Nullable(Of DateTime)
        Get
            Return m_CreatedAt
        End Get
        Set(value As System.Nullable(Of DateTime))
            m_CreatedAt = value
        End Set
    End Property
 
End Class

My Scheduler Event

Imports System.Collections.Generic
 
Public MustInherit Class SchedulerEvent
 
    'This class should contain all the necessary fields required to create a scheduled event
    'basically Title and Description + all the scheduling fields
 
    Private m_Title As String
    Public Property Title() As String
        Get
            Return m_Title
        End Get
        Set(value As String)
            m_Title = value
        End Set
    End Property
 
 
    Private m_Description As String
    Public Property Description() As String
        Get
            Return m_Description
        End Get
        Set(value As String)
            m_Description = value
        End Set
    End Property
 
 
    Private m_StartTimezone As String
    Public Property StartTimezone() As String
        Get
            Return m_StartTimezone
        End Get
        Set(value As String)
            m_StartTimezone = value
        End Set
    End Property
 
 
    Private m_start As DateTime
    Public Property Start() As DateTime
        Get
            Return m_start
        End Get
        Set(value As DateTime)
            m_start = value.ToUniversalTime()
        End Set
    End Property
 
 
    Private m_end As DateTime
    Public Property [End]() As DateTime
        Get
            Return m_end
        End Get
        Set(value As DateTime)
            m_end = value.ToUniversalTime()
        End Set
    End Property
 
 
    Private m_EndTimezone As String
    Public Property EndTimezone() As String
        Get
            Return m_EndTimezone
        End Get
        Set(value As String)
            m_EndTimezone = value
        End Set
    End Property
 
 
    Private m_RecurrenceRule As String
    Public Property RecurrenceRule() As String
        Get
            Return m_RecurrenceRule
        End Get
        Set(value As String)
            m_RecurrenceRule = value
        End Set
    End Property
 
    Private m_RecurrenceID As System.Nullable(Of Integer)
    Public Property RecurrenceID() As System.Nullable(Of Integer)
        Get
            Return m_RecurrenceID
        End Get
        Set(value As System.Nullable(Of Integer))
            m_RecurrenceID = value
        End Set
    End Property
 
 
    Private m_RecurrenceException As String
    Public Property RecurrenceException() As String
        Get
            Return m_RecurrenceException
        End Get
        Set(value As String)
            m_RecurrenceException = value
        End Set
    End Property
 
 
    Private m_IsAllDay As Boolean
    Public Property IsAllDay() As Boolean
        Get
            Return m_IsAllDay
        End Get
        Set(value As Boolean)
            m_IsAllDay = value
        End Set
    End Property
 
End Class

and My Hub

Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports Microsoft.AspNet.SignalR
Imports Microsoft.AspNet.SignalR.Hubs
Imports System.Web.Caching
 
Namespace SupportDiary
 
    <HubName("wRequestHub")>
    Public Class WRequestHub
        Inherits Hub
        Public Function Read() As IEnumerable(Of WRequestsSignalR)
 
            'Dim wRequests = TryCast(HttpContext.Current.Cache("wRequests"), IEnumerable(Of WRequestsSignalR))
 
            Dim wRequests As IEnumerable(Of WRequestsSignalR)
 
            'If wRequests Is Nothing Then
            Using dc = New SupportDiaryDataContext()
                Dim createdAt = DateTime.Now
 
                ' Execute the query because Linq to SQL doesn't get Guid.NewGuid()
                wRequests = dc.WorkRequests.ToList().[Select](Function(wR) New WRequestsSignalR() With {
                        .ID = Guid.NewGuid(),
                        .Start = DateTime.SpecifyKind(wR.Start, DateTimeKind.Utc),
                        .[End] = DateTime.SpecifyKind(wR.[End], DateTimeKind.Utc),
                        .Title = wR.Title,
                        .IsAllDay = wR.IsAllDay,
                        .RecurrenceRule = wR.RecurrenceRule,
                        .RecurrenceID = wR.RecurrenceID,
                        .RecurrenceException = wR.RecurrenceException,
                        .StartTimezone = wR.StartTimezone,
                        .EndTimezone = wR.EndTimezone,
                        .CreatedAt = InlineAssignHelper(createdAt, createdAt.AddMilliseconds(1))
                }).ToList()
            End Using
 
            'HttpContext.Current.Cache.Add("wRequests", wRequests, Nothing, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(30), System.Web.Caching.CacheItemPriority.Normal, Nothing)
            'End If
            '.ID = Guid.NewGuid(),
            Return wRequests
 
        End Function
 
        Public Sub Update(wRequest As WRequestsSignalR)
            Clients.Others.update(wRequest)
        End Sub
 
        Public Sub Destroy(wRequest As WRequestsSignalR)
            Clients.Others.destroy(wRequest)
        End Sub
 
        Public Function Create(wRequest As WRequestsSignalR) As WRequestsSignalR
 
            wRequest.ID = Guid.NewGuid()
            wRequest.CreatedAt = DateTime.Now
 
            Clients.Others.create(wRequest)
 
            Return wRequest
        End Function
        Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, value As T) As T
            target = value
            Return value
        End Function
    End Class
 
End Namespace

If I use code as is currently... Nothing is saved to database. The scheduler will display a new item with title and date. If i go to edit is the other fields that I entered eg Project Code, Change Ref etc are blank. If I continue to create new events then event are doubled up. so I start with 1 then I have 3, then 7, then 15....

 

0
Accepted
Vladimir Iliev
Telerik team
answered on 26 May 2016, 07:24 AM
Hello Jon,

From the provided information it's not clear for us what might be the reason for the described behavior. Could you please provide runable example where the issue is reproduced? 

Also feel free to use any technology that you need on the server side - the code demonstrated in the demo is only for demo purposes (server side implementations falls outside the scope of this support service). 

Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Jon
Top achievements
Rank 1
answered on 26 May 2016, 12:43 PM
I have created a support ticket and sent my VS Solution + sample data.
Tags
Scheduler
Asked by
Jon
Top achievements
Rank 1
Answers by
Jon
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Share this question
or