Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fahrtenbuch
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWP WS21_22 - Fahrtenbuch
Team Einhorn
fahrtenbuch
Commits
bb13fb92
Commit
bb13fb92
authored
3 years ago
by
elit04
Browse files
Options
Downloads
Patches
Plain Diff
check if minP is bigger than maxP then error in update boat controller
parent
d2a132e8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/src/controllers/boat.controllers.ts
+22
-0
22 additions, 0 deletions
server/src/controllers/boat.controllers.ts
with
22 additions
and
0 deletions
server/src/controllers/boat.controllers.ts
+
22
−
0
View file @
bb13fb92
...
...
@@ -267,6 +267,28 @@ const updateBoatById = async (req: Request, res: Response) => {
}
}
//check if minP is bigger than maxP => error
if
(
!
(
input
.
minP
===
undefined
)
||
!
(
input
.
maxP
===
undefined
))
{
//compare only when the two values are given (minP AND maxP)
if
(
!
(
input
.
minP
===
undefined
)
&&
!
(
input
.
maxP
===
undefined
))
{
if
(
input
.
maxP
<
input
.
minP
)
{
return
res
.
status
(
409
).
json
({
success
:
false
,
error
:
"
maximumNumberOfSeatsMustBeBiggerOrEqualMinimalNumberOfSeats
"
,
});
}
}
//if only one entry is given for updated(minP OR maxP) we compare them with the values of minP and maxP already assigned to Boat.
if
(
input
.
minP
>
foundBoat
.
maxP
||
input
.
maxP
<
foundBoat
.
minP
)
{
return
res
.
status
(
409
).
json
({
success
:
false
,
error
:
"
maximumNumberOfSeatsMustBeBiggerOrEqualMinimalNumberOfSeats
"
,
});
}
}
//try to update the attributes, which are in Boat table
const
updatedBoat
=
await
Boat
.
update
(
input
,
{
where
:
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment