Skip to content

Commit

Permalink
Merge pull request cyclic-software#11 from royyan005/local
Browse files Browse the repository at this point in the history
add validate duplicate matkul
  • Loading branch information
royyan005 authored Sep 15, 2022
2 parents 41038dc + 138419c commit 7c84827
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 3 deletions.
80 changes: 78 additions & 2 deletions controller/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ export const postMatkul1 = async (req, res) => {
idmahasiswa = mahasiswaExist.id
}

const nilaiExist = await Matkul1.findOne({
where: {
iduser: iduser,
idmahasiswa: idmahasiswa
}
})
if (nilaiExist) {
return res.status(400).json({
status: res.statusCode,
message: 'Nilai sudah ada !'
})
}

const Matkul1Post = new Matkul1({
sub1: sub1,
valuesub1: valuesub1,
Expand Down Expand Up @@ -160,6 +173,19 @@ export const postMatkul2 = async (req, res) => {
idmahasiswa = mahasiswaExist.id
}

const nilaiExist = await Matkul2.findOne({
where: {
iduser: iduser,
idmahasiswa: idmahasiswa
}
})
if (nilaiExist) {
return res.status(400).json({
status: res.statusCode,
message: 'Nilai sudah ada !'
})
}

const Matkul2Post = new Matkul2({
sub1: sub1,
valuesub1: valuesub1,
Expand Down Expand Up @@ -254,6 +280,19 @@ export const postMatkul3 = async (req, res) => {
idmahasiswa = mahasiswaExist.id
}

const nilaiExist = await Matkul3.findOne({
where: {
iduser: iduser,
idmahasiswa: idmahasiswa
}
})
if (nilaiExist) {
return res.status(400).json({
status: res.statusCode,
message: 'Nilai sudah ada !'
})
}

const Matkul3Post = new Matkul3({
sub1: sub1,
valuesub1: valuesub1,
Expand Down Expand Up @@ -351,6 +390,19 @@ export const postMatkul4 = async (req, res) => {
idmahasiswa = mahasiswaExist.id
}

const nilaiExist = await Matkul4.findOne({
where: {
iduser: iduser,
idmahasiswa: idmahasiswa
}
})
if (nilaiExist) {
return res.status(400).json({
status: res.statusCode,
message: 'Nilai sudah ada !'
})
}

const Matkul4Post = new Matkul4({
sub1: sub1,
sub11: sub11,
Expand Down Expand Up @@ -443,6 +495,19 @@ export const postMatkul5 = async (req, res) => {
idmahasiswa = mahasiswaExist.id
}

const nilaiExist = await Matkul5.findOne({
where: {
iduser: iduser,
idmahasiswa: idmahasiswa
}
})
if (nilaiExist) {
return res.status(400).json({
status: res.statusCode,
message: 'Nilai sudah ada !'
})
}

const Matkul5Post = new Matkul5({
sub1: sub1,
valuesub1: valuesub1,
Expand Down Expand Up @@ -528,6 +593,19 @@ export const postMatkul6 = async (req, res) => {
idmahasiswa = mahasiswaExist.id
}

const nilaiExist = await Matkul6.findOne({
where: {
iduser: iduser,
idmahasiswa: idmahasiswa
}
})
if (nilaiExist) {
return res.status(400).json({
status: res.statusCode,
message: 'Nilai sudah ada !'
})
}

const Matkul6Post = new Matkul6({
sub1: sub1,
valuesub1: valuesub1,
Expand Down Expand Up @@ -648,8 +726,6 @@ export const deleteMatkul = async (req, res) => {
}
})

console.log(mahasiswa)

if (mahasiswa[0].idpembimbing1 == req.params.iduser) {
const updateMahasiswa = await Mahasiswa.update({
idpembimbing1: null
Expand Down
1 change: 0 additions & 1 deletion controller/mahasiswa.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ export const postRolePenguji = async (req, res) => {
status: res.statusCode,
message: "Forbidden"
});
console.log(user)
try {
const updateMahasiswa = await Mahasiswa.update({
idpenguji: user[0].id,
Expand Down

0 comments on commit 7c84827

Please sign in to comment.