Benachrichtigung Aviso Kunde erstellt
This commit is contained in:
@@ -740,8 +740,78 @@ Namespace ApiController.Controllers
|
|||||||
|
|
||||||
Return PostValue
|
Return PostValue
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
''' <summary>
|
||||||
|
''' Send AVISO_ERSTELLT notification for a specific Aviso and User
|
||||||
|
''' </summary>
|
||||||
|
''' <param name="avisoId">The ID of the Aviso that was created</param>
|
||||||
|
''' <param name="username">The username who should receive the notification</param>
|
||||||
|
''' <returns>OK if notification was sent successfully, or ERROR-Code if something went wrong</returns>
|
||||||
|
''' <response code="200">Returns 200 if notification is sent successfully</response>
|
||||||
|
''' <response code="400">Returns 400 if parameters are invalid</response>
|
||||||
|
''' <response code="404">Returns 404 if Aviso is not found</response>
|
||||||
|
''' <response code="500">Returns 500 if notification sending failed</response>
|
||||||
|
<ApiVersion("1")>
|
||||||
|
<System.Web.Http.Route("api/v{version:apiVersion}/sendAvisoErstelltNotification")>
|
||||||
|
<BasicAuthentication>
|
||||||
|
Public Function sendAvisoErstelltNotification(avisoId As Integer, username As String) As HttpResponseMessage
|
||||||
|
' Globale Fehlerbehandlung einstellen
|
||||||
|
VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = False
|
||||||
|
VERAG_PROG_ALLGEMEIN.cAllgemein.ERR_OP_GLOBAL = VERAG_PROG_ALLGEMEIN.ERROR_OP.LOG
|
||||||
|
|
||||||
|
Dim response As HttpResponseMessage
|
||||||
|
|
||||||
|
Try
|
||||||
|
' Eingabevalidierung
|
||||||
|
If avisoId <= 0 Then
|
||||||
|
Return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Der Parameter 'avisoId' muss eine gültige positive Zahl sein.")
|
||||||
|
End If
|
||||||
|
|
||||||
|
If String.IsNullOrWhiteSpace(username) Then
|
||||||
|
Return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Der Parameter 'username' darf nicht leer sein.")
|
||||||
|
End If
|
||||||
|
|
||||||
|
' Aviso laden und prüfen ob es existiert
|
||||||
|
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
|
||||||
|
|
||||||
|
' Benachrichtigung senden
|
||||||
|
Dim code As Integer = AvisoNotificationCodes.AVISO_ERSTELLT
|
||||||
|
Dim TXT_Titel As String = "Neues Aviso erstellt"
|
||||||
|
Dim TXT_Mitteilung As String = "Ein neues Aviso mit der ID " & avisoId & " wurde von " & username & " erstellt und ist bereit zur Bearbeitung."
|
||||||
|
|
||||||
|
Dim benachrichtigungErfolg As Boolean = cAvisoBenachrichtigungen.send_BENACHRICHTIGUNG_AKTIV_AVISOUSER(
|
||||||
|
avisoId,
|
||||||
|
-1, ' sendungsId nicht relevant für AVISO_ERSTELLT
|
||||||
|
TXT_Titel,
|
||||||
|
TXT_Mitteilung,
|
||||||
|
code,
|
||||||
|
avisoObjekt.FIRMA
|
||||||
|
)
|
||||||
|
|
||||||
|
If benachrichtigungErfolg Then
|
||||||
|
response = Request.CreateResponse(HttpStatusCode.OK, "Die AVISO_ERSTELLT")
|
||||||
|
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
|
||||||
|
|
||||||
|
''' <summary>
|
||||||
|
''' Local notification codes for Aviso notifications
|
||||||
|
''' </summary>
|
||||||
|
Public Class AvisoNotificationCodes
|
||||||
|
Public Const AVISO_ERSTELLT As Integer = 1001 ' Neuer Code für AVISO_ERSTELLT
|
||||||
|
End Class
|
||||||
|
|
||||||
Class VERAG_IN_AVISO_Exceptions
|
Class VERAG_IN_AVISO_Exceptions
|
||||||
Public Const ERR_01_Wrong_Format As String = "ERR_01"
|
Public Const ERR_01_Wrong_Format As String = "ERR_01"
|
||||||
|
|||||||
Reference in New Issue
Block a user