Finish GenresAdminPanel

This commit is contained in:
2024-11-06 17:55:18 +01:00
parent 33880069a0
commit c2a337e051
17 changed files with 181 additions and 21 deletions

View File

@@ -14,4 +14,54 @@ genre.get("/", (req: Request, res: Response) => {
.then(genres => {
res.status(200).json(genres)
})
.catch(error => {
res.status(500).send()
})
})
/**
* Update a Genre entry
*/
genre.patch("/", (req: Request, res: Response) => {
Genre.update(req.body, {
where: {
id: req.body.id
}
})
.then(result => {
res.status(200).json(result)
})
.catch(error => {
res.status(500).send()
})
})
/**
* Create a new Genre entry
*/
genre.post("/", (req: Request, res: Response) => {
Genre.create(req.body)
.then(result => {
res.status(200).json(result)
})
.catch(error => {
res.status(500).send()
})
})
/**
* Delete a Genre entry
*/
genre.delete("/", (req: Request, res: Response) => {
Genre.destroy({
where: {
id: req.body.id
}
})
.then(result => {
res.status(200).json(result)
})
.catch(error => {
res.status(500).send()
})
})

View File

@@ -88,6 +88,8 @@ export async function prepopulateDatabase() {
{
location["cityId"] = cityDataset.id
location["urlName"] = location.name.replaceAll(" ", "-").toLowerCase()
location["imageIndoor"] = "http://localhost:3000/static/" + location["imageIndoor"]
location["imageOutdoor"] = "http://localhost:3000/static/" + location["imageOutdoor"]
await Location.create(location)
.then(async locationDataset => {
@@ -193,14 +195,14 @@ export async function prepopulateDatabase() {
})
}
for (let payment of account.payments) {
await Payment.create({
accountId: dataset.dataValues.id,
bankName: payment.bankName,
iban: payment.iban
})
}
})
for (let payment of account.payments) {
await Payment.create({
accountId: dataset.dataValues.id,
bankName: payment.bankName,
iban: payment.iban
})
}
})
}
@@ -208,6 +210,10 @@ export async function prepopulateDatabase() {
////////// Band and Concert Tables //////////
for(let band of bandsConcerts.bands) {
band.imageMembers = "http://localhost:3000/static/" + band.imageMembers
band.images = band.images.map(image => "http://localhost:3000/static/" + image)
band.logo = "http://localhost:3000/static/" + band.logo
// Create a band dataset
await Band.create(band)
.then(async dataset => {
@@ -245,6 +251,8 @@ export async function prepopulateDatabase() {
}
for (let member of band.members) {
member.image = "http://localhost:3000/static/" + member.image
await Member.create({
name: member.name,
image: member.image,