Introduction
In my previous article working with scheduler widget in Kendo UI I explained how to implement the Kendo Scheduler in a web application. From this article we will learn how to remote bind the Kendo Scheduler using ASP.NET WEB PI and Entity Framework.
Remote Binding the Kendo Scheduler
- Open Visual Studio and create a new project.
- Select File, New and then Project.
- Select Web in the installed template and select ASP.NET Web Application.
- Provide the name for the project and click OK, as in the following figures.
My database schema is as in the following figure:
My table structure is as in the following figure:
Here is my code in EventController Class:
- public class EventsController : ApiController
- {
- private EventEntities db = new EventEntities();
- // GET: api/Events
- public IQueryable<Event> GetEvents()
- {
- return db.Events;
- }
- // GET: api/Events/5
- [ResponseType(typeof(Event))]
- public IHttpActionResult GetEvent(int id)
- {
- Event @event = db.Events.Find(id);
- if (@event == null)
- {
- return NotFound();
- }
- return Ok(@event);
- }
- // PUT: api/Events/5
- [ResponseType(typeof(void))]
- public IHttpActionResult PutEvent(int id, Event @event)
- {
- if (!ModelState.IsValid)
- {
- return BadRequest(ModelState);
- }
- if (id != @event.TaskID)
- {
- return BadRequest();
- }
- db.Entry(@event).State = EntityState.Modified;
- try
- {
- db.SaveChanges();
- }
- catch (DbUpdateConcurrencyException)
- {
- if (!EventExists(id))
- {
- return NotFound();
- }
- else
- {
- throw;
- }
- }
- return StatusCode(HttpStatusCode.NoContent);
- }
- // POST: api/Events
- [ResponseType(typeof(Event))]
- public IHttpActionResult PostEvent(Event @event)
- {
- if (!ModelState.IsValid)
- {
- return BadRequest(ModelState);
- }
- db.Events.Add(@event);
- db.SaveChanges();
- return CreatedAtRoute("DefaultApi", new { id = @event.TaskID }, @event);
- }
- // DELETE: api/Events/5
- [ResponseType(typeof(Event))]
- public IHttpActionResult DeleteEvent(int id)
- {
- Event @event = db.Events.Find(id);
- if (@event == null)
- {
- return NotFound();
- }
- db.Events.Remove(@event);
- db.SaveChanges();
- return Ok(@event);
- }
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- db.Dispose();
- }
- base.Dispose(disposing);
- }
- private bool EventExists(int id)
- {
- return db.Events.Count(e => e.TaskID == id) > 0;
- }
- }



Arul RPosted Jan 17, 2016, 10:50 AM
Thanks for nice article
Santhakumar MunuswamyPosted Nov 11, 2015, 2:39 AM
Good one
Sibeesh VenuPosted Nov 11, 2015, 12:40 AM
Nice Share
Mukesh KumarPosted Nov 10, 2015, 12:14 AM
Good Work