I have Problem with UI schedule.when I try to enter new Meeting to the room the create event will fire 4 times
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using TelerikScheduler.Entities;
using TelerikScheduler.Services;
using TelerikScheduler.ViewModels;
using Kendo.Mvc.UI;
using Kendo.Mvc.Extensions;
namespace TelerikScheduler.Controllers
{
public class HomeController : Controller
{
private IMeetingData meetingData;
public HomeController(IMeetingData meetingData)
{
this.meetingData = meetingData;
}
public IActionResult Index()
{
var model = new HomePageViewModel();
model.Rooms = meetingData.GetAll();
return View(model);
}
public virtual JsonResult ReadMeeting([DataSourceRequest] DataSourceRequest request)
{
return Json(meetingData.GetAll().ToDataSourceResult(request));
}
public virtual JsonResult DestroyMeeting([DataSourceRequest] DataSourceRequest request, Meeting meeting)
{
if (ModelState.IsValid)
{
// meetingData.Delete(meeting);
}
return Json(new[] { meeting }.ToDataSourceResult(request, ModelState));
}
public virtual JsonResult CreateMeeting([DataSourceRequest] DataSourceRequest request, Meeting meeting)
{
if (ModelState.IsValid)
{
meetingData.Insert(meeting, ModelState);
}
return Json(new[] { meeting }.ToDataSourceResult(request, ModelState));
}
public virtual JsonResult UpdateMeeting([DataSourceRequest] DataSourceRequest request, Meeting meeting)
{
if (ModelState.IsValid)
{
//meetingData.Update(meeting);
}
return Json(new[] { meeting }.ToDataSourceResult(request, ModelState));
}
public IActionResult Error()
{
return View();
}
}
}
@using TelerikScheduler.Entities
@using Kendo.Mvc.UI
@using Microsoft.AspNetCore.Mvc.ModelBinding
@model TelerikScheduler.ViewModels.HomePageViewModel
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
>
<
title
>Home</
title
>
</
head
>
<
body
>
<
h1
>Welcome!</
h1
>
@(Html.Kendo().Scheduler<
Meeting
>().Name("Meeting").Date(new DateTime(2017, 5, 13))
.StartTime(new DateTime(2017, 5,13, 7, 00, 00))
.Views(views=>{
views.DayView();
views.AgendaView();
})
.Height(600)
.Timezone("Etc/UTC")
.Group(group => { group.Resources("Rooms"); group.Date(true); })
.Resources(resource =>
{
resource.Add(m => m.RoomId).Title("Room").Name("Rooms").DataTextField("Text").DataValueField("Value").DataColorField("Color").BindTo(new[] {
new { Text = "Meeting Room 101", Value = 1, Color = "#6eb3fa" },
new { Text = "Meeting Room 201", Value = 2, Color = "#f58a8a" }
});
resource.Add(m => m.Attendees)
.Title("Attendees")
.Multiple(true)
.DataTextField("Text")
.DataValueField("Value")
.DataColorField("Color")
.BindTo(new[] {
new { Text = "Alex", Value = 1, Color = "#f8a398" } ,
new { Text = "Bob", Value = 2, Color = "#51a0ed" } ,
new { Text = "Charlie", Value = 3, Color = "#56ca85" }
});
}).DataSource(d => d
.Model(m =>
{
m.Id(f => f.RecordId);
m.Field(f => f.Title).DefaultValue("No title");
m.Field(f => f.Title).DefaultValue("No title");
})
.Read("ReadMeeting", "Home")
.Create("CreateMeeting", "Home")
.Destroy("DestroyMeeting", "Home")
.Update("UpdateMeeting", "Home")
).BindTo(Model.Rooms).Deferred())
@section scripts {
@Html.Kendo().DeferredScripts()
}
</
body
>
</
html
>