feat: DELETE op assignment geimplementeerd
This commit is contained in:
parent
d65bb1f4a6
commit
2ec5e02061
3 changed files with 26 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
import { Request, Response } from 'express';
|
||||
import { createAssignment, getAllAssignments, getAssignment, getAssignmentsSubmissions } from '../services/assignments.js';
|
||||
import { createAssignment, deleteAssignment, getAllAssignments, getAssignment, getAssignmentsSubmissions } from '../services/assignments.js';
|
||||
import { AssignmentDTO } from '@dwengo-1/common/interfaces/assignment';
|
||||
import {requireFields} from "./error-helper";
|
||||
import {BadRequestException} from "../exceptions/bad-request-exception";
|
||||
|
@ -42,6 +42,18 @@ export async function getAssignmentHandler(req: Request, res: Response): Promise
|
|||
res.json({ assignment });
|
||||
}
|
||||
|
||||
export async function deleteAssignmentHandler(req: Request, res: Response): Promise<void> {
|
||||
const id = Number(req.params.id);
|
||||
const classid = req.params.classid;
|
||||
requireFields({ id, classid });
|
||||
|
||||
if (isNaN(id)) {
|
||||
throw new BadRequestException("Assignment id should be a number");
|
||||
}
|
||||
|
||||
const assignment = await deleteAssignment(classid, id);
|
||||
}
|
||||
|
||||
export async function getAssignmentsSubmissionsHandler(req: Request, res: Response): Promise<void> {
|
||||
const classid = req.params.classid;
|
||||
const assignmentNumber = Number(req.params.id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue