public virtual SchedulerTaskViewModel Destroy(SchedulerTaskViewModel task)
        {
            this.Data.SchedulerTasks.Delete(task.Id);
            this.Data.SaveChanges();

            return task;
        }
        public virtual JsonResult Update([DataSourceRequest] DataSourceRequest request, SchedulerTaskViewModel task)
        {
            if (!ModelState.IsValid)
            {
                return Json(new[] { task }.ToDataSourceResult(request, ModelState));
            }

            var schedulerTaskFromDb = this.profile.Update(task);
            task.Id = schedulerTaskFromDb.Id;

            return Json(new[] { task }.ToDataSourceResult(request, ModelState));
        }
        public virtual JsonResult Destroy([DataSourceRequest] DataSourceRequest request, SchedulerTaskViewModel task)
        {
            if (!ModelState.IsValid)
            {
                return Json(new[] { task }.ToDataSourceResult(request, ModelState));
            }

            var deletedTask = this.profile.Destroy(task);
            task.Id = deletedTask.Id;

            return Json(new[] { task }.ToDataSourceResult(request, ModelState));
        }
        public virtual SchedulerTaskViewModel Create(SchedulerTaskViewModel task)
        {
            var schedulerTask = new SchedulerTask()
            {
                Title = task.Title,
                Start = task.Start,
                End = task.End,
                StartTimezone = task.StartTimezone,
                EndTimezone = task.EndTimezone,
                Description = task.Description,
                IsAllDay = task.IsAllDay,
                RecurrenceRule = task.RecurrenceRule,
                RecurrenceException = task.RecurrenceException,
                RecurrenceId = task.RecurrenceId,
                UserId = task.UserId,
                IsFinished = task.IsFinished
            };

            this.Data.SchedulerTasks.Add(schedulerTask);
            this.Data.SaveChanges();

            return task;
        }
        public virtual SchedulerTaskViewModel Update(SchedulerTaskViewModel task)
        {
            var schedulerTaskFromDb = this.Data.SchedulerTasks
                .GetById(task.Id);

            schedulerTaskFromDb.Title = task.Title;
            schedulerTaskFromDb.Start = task.Start;
            schedulerTaskFromDb.End = task.End;
            schedulerTaskFromDb.StartTimezone = task.StartTimezone;
            schedulerTaskFromDb.EndTimezone = task.EndTimezone;
            schedulerTaskFromDb.Description = task.Description;
            schedulerTaskFromDb.IsAllDay = task.IsAllDay;
            schedulerTaskFromDb.RecurrenceRule = task.RecurrenceRule;
            schedulerTaskFromDb.RecurrenceException = task.RecurrenceException;
            schedulerTaskFromDb.RecurrenceId = task.RecurrenceId;
            schedulerTaskFromDb.UserId = task.UserId;
            schedulerTaskFromDb.IsFinished = task.IsFinished;

            this.Data.SaveChanges();

            return task;
        }