Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
C4Ai_DR-P
public-service-provider
Commits
895cf924
Commit
895cf924
authored
Jul 08, 2020
by
Mahdi Sellami
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
verify existance of the service before accepting application
parent
c9e94d53
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
+14
-6
service/ApplicationService.js
service/ApplicationService.js
+14
-6
No files found.
service/ApplicationService.js
View file @
895cf924
'
use strict
'
;
const
Application
=
require
(
'
../models/application
'
);
const
Service
=
require
(
'
../models/service
'
);
/**
* Submit a new application including the application documents for an administration case
...
...
@@ -10,12 +11,19 @@ const Application = require('../models/application');
exports
.
postCaseApplication
=
function
(
body
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
// TODO maybe remove VerfahrensId later (discuss with Peter)
var
applicationRecord
=
Application
.
create
(
body
).
then
(
function
(
doc
)
{
doc
.
verfahrensId
=
doc
.
id
doc
.
save
()
return
doc
});
resolve
(
applicationRecord
);
//Verify if the leikaId exists
const
serviceRecord
=
Service
.
findOne
({
leikaId
:
body
.
leikaId
},
function
(
err
,
result
)
{
if
(
!
result
)
{
reject
({
error
:
'
The service with ID
'
+
body
.
leikaId
+
'
is not available here.
'
})
}
else
{
var
applicationRecord
=
Application
.
create
(
body
).
then
(
function
(
doc
)
{
doc
.
verfahrensId
=
doc
.
id
doc
.
save
()
return
doc
});
resolve
(
applicationRecord
);
}
});
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment