Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update event #19

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions Server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ app.use(cors());
const Event = require('./models/Event')
const User = require('./models/User')
const Ticket = require('./models/Ticket');
const Item = require("./models/Event");

// this will be your "database"
var database =[
const database =[
{
"name": "Event1",
"date": "2024-02-15T00:00:00Z",
Expand All @@ -57,7 +56,8 @@ var database =[
"price": [10.99, 15.99, 20.99],
"startTime": "2024-02-20T18:00:00Z",
"endTime": "2024-02-20T22:00:00Z",
"location": "Venue A"
"location": "Venue A",
"id": "1"
},
{
"name": "Event2",
Expand All @@ -67,7 +67,8 @@ var database =[
"price": [12.99, 18.99, 25.99],
"startTime": "2024-03-15T19:30:00Z",
"endTime": "2024-03-15T23:00:00Z",
"location": "Venue B"
"location": "Venue B",
"id": "2"
},
{
"name": "Event3",
Expand All @@ -77,7 +78,8 @@ var database =[
"price": [8.99, 14.99, 19.99],
"startTime": "2024-04-10T17:00:00Z",
"endTime": "2024-04-10T21:30:00Z",
"location": "Venue C"
"location": "Venue C",
"id": "3"
}
]

Expand Down Expand Up @@ -157,8 +159,7 @@ app.get('/getevent/:itemName', async (req, res, next) => {
const event = await Event.findOne({"name" : itemName});
res.json(event);
});




//Make Tickets --Neyida
app.post('/makeTicket', async (req, res, next) => {
Expand Down Expand Up @@ -195,9 +196,9 @@ app.post("/addevent", async (req, res, next) => {
});


// TODO ROUTE #3 - Remove an existing shopping item


//Delete Event Route:
app.delete("/remove", (req, res, next) => {
//console.log(req.body)
try {
Expand All @@ -211,17 +212,21 @@ app.delete("/remove", (req, res, next) => {
}
});

// TODO ROUTE #4 - Update event by time/name

app.put("/update", (req, res, next) => {
console.log(req)
//let newData = database
})

// TODO ROUTE #5 - Get shopping items that satisfy a condition/filter (harder)

// TODO ROUTE #4 - Update event
app.patch("/updateevent/:id", async(req, res) => {
const event = await Event.findById(req.params.id);

if (!event) return res.status(404).send("Event not found");

try {
const updatedEvent = await Event.findByIdAndUpdate(req.params.id, req.body, {new: true});
console.log(updatedEvent);
res.send({updatedEvent});
} catch (error) {
res.status(500).send(error.message);
console.log(error.message);
}
});


module.exports = app;
5 changes: 4 additions & 1 deletion Server/models/Event.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const eventSchema = new mongoose.Schema({
required: true,
},
photo: {
type: String,
type: String, //presumably a link to the picture
},
seatingChart: {
type: String,
Expand All @@ -46,6 +46,9 @@ const eventSchema = new mongoose.Schema({
tickets: {
type: [mongoose.Schema.Types.ObjectId], // Array of ObjectIds
ref: "Ticket", // Reference to 'User' model
},
id: {
type: String,
}
})

Expand Down
47 changes: 32 additions & 15 deletions Server/node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions Server/node_modules/@mongodb-js/saslprep/dist/node.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions Server/node_modules/@mongodb-js/saslprep/dist/node.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Server/node_modules/@mongodb-js/saslprep/dist/node.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Server/node_modules/@mongodb-js/saslprep/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Server/node_modules/@types/node/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions Server/node_modules/@types/node/buffer.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Server/node_modules/@types/node/child_process.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Server/node_modules/@types/node/crypto.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading