/// <summary>
        /// Saves a task to the database. Creates a new or updates exisitng record depending on Id value.
        /// </summary>
        /// <param name="task">Task to save.</param>
        public void saveEvent(Event eventRecord)
        {
            if (eventRecord.Id > 0)
            {
                var entity = getEvent(eventRecord.Id);
                if (entity == null) throw new CrudException("Cannot find event #" + eventRecord.Id, SchedulerCodes.EVENT_NOT_FOUND);

                // update record
                entity.Name = eventRecord.Name;
                entity.StartDate = eventRecord.StartDate;
                entity.EndDate = eventRecord.EndDate;
                entity.Сls = eventRecord.Сls;
                entity.Draggable = eventRecord.Draggable;
                entity.Resizable = eventRecord.Resizable;
                context.SaveChanges();
            }
            else
            {
                // create new record
                context.Events.Add(eventRecord);
                //saveTaskSegments(task, task.Segments);
                context.SaveChanges();
                // let's keep mapping from phantom to real Id
                AddedIds["events"].Add(eventRecord.PhantomId, eventRecord.Id);
            }

            updateRevision();
        }
 /// <summary>
 /// Removes event from the database.
 /// </summary>
 /// <param name="event">Event to remove.</param>
 public void removeEvent(Event eventRecord, bool force = false)
 {
     Event entity = getEvent(eventRecord.Id);
     if (entity != null)
     {
         context.Events.Remove(entity);
         context.SaveChanges();
         updateRevision();
     }
 }