title: Full Calendar ASP.NET MVC update database eventDragStop
body: <p>Does anybody have any idea how I can update my underlying datasource (sql server DB) when making changes in a JQUERY UI Full Calendar? </p>
  
  <p>I have the FullCalendar plugin enabled and working, also being populated with data, I have enabled the dragging and dropping options and they work, obviously these changes are not being committed to the database and I am unsure how to go about it, perhaps some kind of AJAX call to a method in my controller? Although I am unsure how to go about implementing even that.</p>
  
  <p>Hope the question isn't too vague, just after a push in the right direction really.</p>
  
  <p>Cheers</p>
  
  <p>SOLUTION:</p>
  
  <p>So the final solution looked like this:</p>
  
  <p>ASP.NET MVC 5 CSHTML PAGE</p>
  
  <pre><code>@section scripts{
  
  &lt;script type="text/javascript"&gt;
  // &lt;![CDATA[
  $(document).ready(function () {
      $('#calendar').fullCalendar({
          header: {
              left: 'prev,next today',
              center: 'title',
              right: 'month,agendaWeek,agendaDay'
  
          },
          theme: false,
          defaultView: 'month',
          editable: false,
          events: "/controller/GetEvents/",
          editable: true,
          eventDrop: function (event, delta, revertFunc) {
              var id = event.id;
              var start = event.start;
              $.ajax({
                  url: "/controller/FullCalendarEventDrop/",
                  type: "POST",
                  data: {id: id, start: start}
              });
          }
      });
  
   });
  // ]]&gt;&lt;/script&gt;
  
  }
  </code></pre>
  
  <p>CONTROLLER:</p>
  
  <pre><code>[HttpPost]
  public void FullCalendarEventDrop(int id, string start)
  {
      DateTime startDt = DateTime.ParseExact(start, "ddd MMM d hh:mm:ss UTC yyyy", null).ToUniversalTime();
  
  
      OBJECT OBJECTNAME = db.OBJECT.Find(id);
      _OBJECTNAME.StartDate = startDt;
      _OBJECTNAME.EndDate = startDt;
  
      db.Entry(OBJECTNAME).State = EntityState.Modified;
      db.SaveChanges();
  
  }
  </code></pre>
  
  <p>So there is no error handling as yet but i'll put that in, most importantly the updates work.</p>
  
  <p>Thanks </p>
  
  <p>:D</p>