title: How to check if there is already an appointment booked for request date
body: <p>I want to make a condition to check if start date and end date exist or not 
  if exist display message error </p>
  
  <pre><code>[HttpPost]
  public JsonResult SaveEvent(Event e)
  {
          var status = false;
  
          using (CalendarDBEntities1 db = new CalendarDBEntities1())
          {
              if (e.EventID &gt; 0)
              {
                  // Update the event
                  var v = db.Events.Where(a =&gt; a.EventID == e.EventID).FirstOrDefault();
  
                  if (v != null)
                  {
                      v.EventTitle = e.EventTitle;
                      v.StartDate = e.StartDate;
                      v.EndDate = e.EndDate;
                      v.EventDescription = e.EventDescription;
                      v.ThemeColor = e.ThemeColor;
                  }
              }
              else
              {
                  db.Events.Add(e);
              }
  
              db.SaveChanges();
              status = true;
          }
  }
  </code></pre>
  
  <p>Can someone help me? I want to add this condition :</p>
  
  <pre><code>var exist = db.Events.Where(a =&gt; a.StartDate &gt;= e.StartDate &amp;&amp; 
                              a =&gt; a.EndDate &gt;= e.EndDate).FirstOrDefault();
  
  
  function SaveEvent(data) {
      $.ajax({
                  type: "POST",
                  url: '/home/SaveEvent',
                  data: data,
                  success: function (data) {
                      if (data.status) {
                          //Refresh the calender
                          FetchEventAndRenderCalendar();
                          $('#myModalSave').modal('hide');
                      }
                  },
                  error: function () {
                      alert('Failed');
                  },
                  success: function (response) {
                      alert('rendez-vous added');
                      window.location.href = "/Home/Calendar";
                  }
      });
  }
  </code></pre>
  
  <p>This is code to get events in jQuery:</p>
  
  <pre><code>$(document).ready(function () {
          var events = [];
          var selectedEvent = null;
          FetchEventAndRenderCalendar();
  
          function FetchEventAndRenderCalendar() {
              events = [];
              $.ajax({
                  type: "GET",
                  url: "/home/GetEvents",
                  success: function (data) {
                      $.each(data, function (i, v) {
                          events.push({
                              eventID: v.EventID,
                              title: v.EventTitle,
                              description: v.EventDescription,
                              start: moment(v.StartDate),
                              end: v.End != null ? moment(v.EndDate) : null,
                              color: v.ThemeColor,
                              allDay: v.IsFullDay
                          });
                      })
  </code></pre>
  
  <p>This is code to save events in jQuery :</p>
  
  <pre><code>$('#btnSave').click(function () {
              //Validation/
              if ($('#txtSubject').val().trim() == "") {
                  alert('Subject required');
                  return;
              }
  
              if ($('#txtStart').val().trim() == "") {
                  alert('Start date required');
                  return;
              }
  
              if ($('#chkIsFullDay').is(':checked') == false &amp;&amp; $('#txtEnd').val().trim() == "") {
                  alert('End date required');
                  return;
              }
              else {
                  var startDate = moment($('#txtStart').val(), "DD/MM/YYYY HH:mm A").toDate();
                  var endDate = moment($('#txtEnd').val(), "DD/MM/YYYY HH:mm A").toDate();
  </code></pre>
  
  <p>I want to write a function like this when start date exist or end date get error</p>
  
  <pre><code>if (startDate &gt; endDate) {
      alert('Invalid end date');
      return;
  }
  </code></pre>