/**
  * Edit a task specified by $id and write it to the database.
  *
  * @param int $id
  * @return RedirectResponse
  */
 public function editTask($id)
 {
     // first we fill objects with data
     // if there is an error, we have not saved yet, so we need no rollback
     $schedule = $this->editSchedule($id);
     $entries = ScheduleController::editScheduleEntries($id);
     // capture showInWeekView-checkbox
     $schedule->schdl_show_in_week_view = !is_null(Input::get('showInWeekView'));
     // log the action
     Log::info('Edit task: User ' . Session::get('userId') . ' with rigths ' . Session::get('userGroup') . ' edits task ' . $schedule->schdl_title . ' with id ' . $schedule->id . '.');
     // at least save all data in the database
     $schedule->save();
     foreach ($entries as $entry) {
         $entry->save();
     }
     // show task
     return Redirect::action('ScheduleController@showSchedule', array('id' => $id));
 }
 /**
  * Edit an event specified by $id with schedule and write it to the database.
  *
  * @param int $id
  * @return RedirectResponse
  */
 public function editEvent($id)
 {
     //validate passwords
     if (Input::get('password') != Input::get('passwordDouble')) {
         Session::put('message', Config::get('messages_de.password-mismatch'));
         Session::put('msgType', 'danger');
         return Redirect::back()->withInput();
     }
     // first we fill objects with data
     // if there is an error, we have not saved yet, so we need no rollback
     $event = $this->editClubEvent($id);
     $schedule = $this->editSchedule($event->getSchedule()->GetResults()->id);
     $entries = ScheduleController::editScheduleEntries($schedule->id);
     // log the action
     Log::info('Edit event: User ' . Session::get('userName') . '(' . Session::get('userId') . ', ' . Session::get('userGroup') . ') edited ' . $event->evnt_title . ' (ID:' . $event->id . ').');
     // save all data in the database
     $event->save();
     $schedule->save();
     foreach ($entries as $entry) {
         $entry->save();
     }
     // show event
     return Redirect::action('CalendarController@showId', array('id' => $id));
 }