This commit is contained in:
2025-10-22 15:54:52 +02:00
parent 66ef636306
commit e8e5f8610a

View File

@@ -16,6 +16,69 @@ Namespace ApiController.Controllers
Public Class AVISOController Public Class AVISOController
Inherits System.Web.Http.ApiController Inherits System.Web.Http.ApiController
<ApiVersion("1")>
<System.Web.Http.Route("api/v{version:apiVersion}/sendCustomNotification")>
<BasicAuthentication>
Public Function sendCustomNotification(avisoId As Integer, sendungsId As Integer, txtTitel As String, txtMitteilung As String, code As Integer) As HttpResponseMessage
VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = False
VERAG_PROG_ALLGEMEIN.cAllgemein.ERR_OP_GLOBAL = VERAG_PROG_ALLGEMEIN.ERROR_OP.LOG
Dim response As HttpResponseMessage
Try
If avisoId <= 0 Then
Return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Der Parameter 'avisoId' muss eine gültige positive Zahl sein.")
End If
If sendungsId <= 0 Then
sendungsId = -1
End If
If String.IsNullOrWhiteSpace(txtTitel) Then
Return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Der Parameter 'txtTitel' darf nicht leer sein.")
End If
If String.IsNullOrWhiteSpace(txtMitteilung) Then
Return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Der Parameter 'txtMitteilung' darf nicht leer sein.")
End If
If code <= 0 Then
Return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Der Parameter 'code' muss eine gültige positive Zahl sein.")
End If
Dim avisoObjekt As cAviso = cAviso.getAvisoById(avisoId)
If avisoObjekt Is Nothing Then
Return Request.CreateErrorResponse(HttpStatusCode.NotFound, "Das angegebene Aviso wurde nicht gefunden. ID: " & avisoId)
End If
Dim benachrichtigungErfolg As Boolean = cAvisoBenachrichtigungen.send_BENACHRICHTIGUNG_AKTIV_AVISOUSER(
avisoId,
sendungsId,
txtTitel,
txtMitteilung,
code,
avisoObjekt.FIRMA
)
If benachrichtigungErfolg Then
response = Request.CreateResponse(HttpStatusCode.OK, "Die Benachrichtigung wurde erfolgreich gesendet.")
Else
response = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Die Benachrichtigung konnte nicht gesendet werden.")
End If
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace & vbNewLine, System.Reflection.MethodInfo.GetCurrentMethod.Name)
response = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Ein unerwarteter Fehler ist aufgetreten: " & ex.Message)
End Try
Return response
End Function
<ApiVersion("1")> <ApiVersion("1")>
<System.Web.Http.Route("api/v{version:apiVersion}/sendAvisoErstelltNotification")> <System.Web.Http.Route("api/v{version:apiVersion}/sendAvisoErstelltNotification")>
@@ -796,68 +859,6 @@ Namespace ApiController.Controllers
End Function End Function
<ApiVersion("1")>
<System.Web.Http.Route("api/v{version:apiVersion}/sendCustomNotification")>
<BasicAuthentication>
Public Function sendCustomNotification(avisoId As Integer, sendungsId As Integer, txtTitel As String, txtMitteilung As String, code As Integer) As HttpResponseMessage
VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = True
VERAG_PROG_ALLGEMEIN.cAllgemein.ERR_OP_GLOBAL = VERAG_PROG_ALLGEMEIN.ERROR_OP.LOG
Dim response As HttpResponseMessage
Try
If avisoId <= 0 Then
Return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Der Parameter 'avisoId' muss eine gültige positive Zahl sein.")
End If
If sendungsId <= 0 Then
sendungsId = -1
End If
If String.IsNullOrWhiteSpace(txtTitel) Then
Return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Der Parameter 'txtTitel' darf nicht leer sein.")
End If
If String.IsNullOrWhiteSpace(txtMitteilung) Then
Return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Der Parameter 'txtMitteilung' darf nicht leer sein.")
End If
If code <= 0 Then
Return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Der Parameter 'code' muss eine gültige positive Zahl sein.")
End If
Dim avisoObjekt As cAviso = cAviso.getAvisoById(avisoId)
If avisoObjekt Is Nothing Then
Return Request.CreateErrorResponse(HttpStatusCode.NotFound, "Das angegebene Aviso wurde nicht gefunden. ID: " & avisoId)
End If
Dim benachrichtigungErfolg As Boolean = cAvisoBenachrichtigungen.send_BENACHRICHTIGUNG_AKTIV_AVISOUSER(
avisoId,
sendungsId,
txtTitel,
txtMitteilung,
code,
avisoObjekt.FIRMA
)
If benachrichtigungErfolg Then
response = Request.CreateResponse(HttpStatusCode.OK, "Die Benachrichtigung wurde erfolgreich gesendet.")
Else
response = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Die Benachrichtigung konnte nicht gesendet werden.")
End If
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace & vbNewLine, System.Reflection.MethodInfo.GetCurrentMethod.Name)
response = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Ein unerwarteter Fehler ist aufgetreten: " & ex.Message)
End Try
Return response
End Function
End Class End Class