diff --git a/src/handler/nurse_handler.go b/src/handler/nurse_handler.go index f93964e..a10fb3f 100644 --- a/src/handler/nurse_handler.go +++ b/src/handler/nurse_handler.go @@ -177,6 +177,12 @@ func (h *NurseHandler) UpdateNurse(c *gin.Context) { c.JSON(404, gin.H{"status": "bad request", "message": "user not found"}) return } + exists, _ := h.iNurseUsecase.GetNurseByNIP(request.Nip) + if exists { + log.Println("Update bad request ", err) + c.JSON(409, gin.H{"status": "bad request", "message": "nip already exists"}) + return + } // Validate request payload err = ValidateRegisterNurseRequest(request.Nip, request.Name) @@ -185,15 +191,6 @@ func (h *NurseHandler) UpdateNurse(c *gin.Context) { c.JSON(400, gin.H{"status": "bad request", "message": err.Error()}) return } - - if (user.Nip != request.Nip) { - exists, _ := h.iNurseUsecase.GetNurseByNIP(request.Nip) - if exists { - log.Println("Update bad request ", err) - c.JSON(409, gin.H{"status": "bad request", "message": "nip already exists"}) - return - } - } statusCode := h.iNurseUsecase.UpdateNurse(userId, request)