Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jay Mehta
/
strapi-setup-file
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Registry
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 29949a91
authored
2022-10-06 13:21:07 +0530
by
kashif ansari
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added condition for checking existign channel partner with the given reara number
1 parent
f560a3e9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
3 deletions
src/api/channel-partner/controllers/channel-partner.js
src/api/channel-partner/controllers/channel-partner.js
View file @
29949a9
'use strict'
;
"use strict"
;
/**
/**
* channel-partner controller
* channel-partner controller
*/
*/
const
{
createCoreController
}
=
require
(
'@strapi/strapi'
).
factories
;
const
{
createCoreController
}
=
require
(
"@strapi/strapi"
).
factories
;
module
.
exports
=
createCoreController
(
'api::channel-partner.channel-partner'
);
module
.
exports
=
createCoreController
(
"api::channel-partner.channel-partner"
,
({
strapi
:
Strapi
})
=>
({
async
create
(
ctx
)
{
// const currentChannelPartner = ctx.state.user;
const
reraNumber
=
ctx
.
request
.
body
?.
data
?.
reraNumber
;
console
.
log
(
`Rera Number
${
reraNumber
}
`
);
if
(
!
reraNumber
)
{
return
ctx
.
bad
(
`Please specify your rera number.`
);
}
// 1. check if the channel partner already exist
const
existingChannelPartner
=
await
strapi
.
entityService
.
findMany
(
"api::channel-partner.channel-partner"
,
{
filters
:
{
reraNumber
:
reraNumber
},
}
);
console
.
log
(
'Existing Channel Partner'
);
console
.
log
(
existingChannelPartner
);
if
(
existingChannelPartner
&&
existingChannelPartner
.
length
!==
0
)
{
return
ctx
.
badRequest
(
`Channel Partner Already Exist with the Given rera number
${
reraNumber
}
`
);
}
return
await
super
.
create
(
ctx
);
},
})
);
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment