salutation CRUD and controller
This commit is contained in:
parent
b55d0554e4
commit
1ab4d93d2b
10 changed files with 288 additions and 3 deletions
|
@ -285,7 +285,7 @@ export async function createMemberPrintoutList(req: Request, res: Response): Pro
|
|||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function createMember(req: Request, res: Response): Promise<any> {
|
||||
const salutationId = req.body.salutationId;
|
||||
const salutationId = parseInt(req.body.salutationId);
|
||||
const firstname = req.body.firstname;
|
||||
const lastname = req.body.lastname;
|
||||
const nameaffix = req.body.nameaffix;
|
||||
|
@ -453,7 +453,7 @@ export async function addCommunicationToMember(req: Request, res: Response): Pro
|
|||
*/
|
||||
export async function updateMemberById(req: Request, res: Response): Promise<any> {
|
||||
const memberId = parseInt(req.params.id);
|
||||
const salutationId = req.body.salutationId;
|
||||
const salutationId = parseInt(req.body.salutationId);
|
||||
const firstname = req.body.firstname;
|
||||
const lastname = req.body.lastname;
|
||||
const nameaffix = req.body.nameaffix;
|
||||
|
|
87
src/controller/admin/settings/salutationController.ts
Normal file
87
src/controller/admin/settings/salutationController.ts
Normal file
|
@ -0,0 +1,87 @@
|
|||
import { Request, Response } from "express";
|
||||
import SalutationService from "../../../service/settings/salutationService";
|
||||
import SalutationFactory from "../../../factory/admin/settings/salutation";
|
||||
import {
|
||||
CreateSalutationCommand,
|
||||
DeleteSalutationCommand,
|
||||
UpdateSalutationCommand,
|
||||
} from "../../../command/settings/salutation/salutationCommand";
|
||||
import SalutationCommandHandler from "../../../command/settings/salutation/salutationCommandHandler";
|
||||
|
||||
/**
|
||||
* @description get all salutations
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getAllSalutations(req: Request, res: Response): Promise<any> {
|
||||
let salutations = await SalutationService.getAll();
|
||||
|
||||
res.json(SalutationFactory.mapToBase(salutations));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get salutation by id
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getSalutationById(req: Request, res: Response): Promise<any> {
|
||||
const id = parseInt(req.params.id);
|
||||
let salutation = await SalutationService.getById(id);
|
||||
|
||||
res.json(SalutationFactory.mapToSingle(salutation));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description create new salutation
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function createSalutation(req: Request, res: Response): Promise<any> {
|
||||
const salutation = req.body.salutation;
|
||||
|
||||
let createSalutation: CreateSalutationCommand = {
|
||||
salutation: salutation,
|
||||
};
|
||||
await SalutationCommandHandler.create(createSalutation);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description update salutation
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function updateSalutation(req: Request, res: Response): Promise<any> {
|
||||
const id = parseInt(req.params.id);
|
||||
const salutation = req.body.salutation;
|
||||
|
||||
let updateSalutation: UpdateSalutationCommand = {
|
||||
id: id,
|
||||
salutation: salutation,
|
||||
};
|
||||
await SalutationCommandHandler.update(updateSalutation);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description delete salutation
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function deleteSalutation(req: Request, res: Response): Promise<any> {
|
||||
const id = parseInt(req.params.id);
|
||||
|
||||
let deleteSalutation: DeleteSalutationCommand = {
|
||||
id: id,
|
||||
};
|
||||
await SalutationCommandHandler.delete(deleteSalutation);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue