message: Refactor delete lecture Api Endpoint
diff: import {Request} from 'express';
  -import {Authorized, Body, Delete, Get, JsonController, Param, Post, Put, Req, UseBefore} from 'routing-controllers';
  +import {
  + Authorized,
  + Body, CurrentUser,
  + Delete, ForbiddenError,
  + Get,
  + JsonController,
  + NotFoundError,
  + Param,
  + Post,
  + Put,
  + Req,
  + UseBefore
  +} from 'routing-controllers';
  import passportJwtMiddleware from '../security/passportJwtMiddleware';
  import {Lecture} from '../models/Lecture';
  import {ILecture} from '../../../shared/models/ILecture';
  import {Course} from '../models/Course';
  import {Notification} from '../models/Notification';
  +import {IUser} from '../../../shared/models/IUser';
  @JsonController('/lecture')
  @UseBefore(passportJwtMiddleware)
  @@ -120,10 +133,18 @@ export class LectureController {
  * "result": true
  * }
  */
  + @Authorized(['teacher', 'admin'])
  @Delete('/:id')
  - deleteLecture(@Param('id') id: string) {
  - return Course.update({}, {$pull: {lectures: id}})
  - .then(() => Lecture.findById(id))
  - .then((lecture) => lecture.remove());
  + async deleteLecture(@Param('id') id: string, @CurrentUser() currentUser: IUser) {
  + const course = await Course.findOne({where: {lectures: id}});
  + if (!course) {
  + throw new NotFoundError();
  + }
  + if (!course.checkPrivileges(currentUser).userCanEditCourse()) {
  + throw new ForbiddenError();
  + }
  + const success = await course.update({}, {$pull: {lectures: id}});
  +
  + return Lecture.findByIdAndRemove(id) && success;
  }
  }
  