From a8d827eace0dd2d7b5e06932dcb2ed6d32361ace Mon Sep 17 00:00:00 2001 From: SysAdmin Date: Sun, 22 Feb 2026 16:03:32 +0000 Subject: [PATCH] feat(developers): create DeveloperApplication record on signup After registering the user and creating the ticket, call the SilverDESK developer-program API to create a proper application record linking the user and ticket. This ensures applications appear in the /developer-program/applications dashboard. Co-Authored-By: Claude Opus 4.6 --- .../Services/DeveloperApplicationService.cs | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/BlazorApp/Services/DeveloperApplicationService.cs b/BlazorApp/Services/DeveloperApplicationService.cs index 40f8ce3..1b1c48b 100644 --- a/BlazorApp/Services/DeveloperApplicationService.cs +++ b/BlazorApp/Services/DeveloperApplicationService.cs @@ -86,6 +86,48 @@ public class DeveloperApplicationService return (true, "Your account has been created, but we had trouble submitting your application ticket. Please log in to SilverDESK and create a support ticket.", token); } + // 3. Create DeveloperApplication record linking user + ticket + try + { + var userId = authResult.GetProperty("user").GetProperty("id").GetString(); + var ticketResult = await ticketResponse.Content.ReadFromJsonAsync(); + var ticketId = ticketResult.GetProperty("id").GetInt32(); + + var applicationPayload = new + { + userId, + ticketId, + fullName = application.FullName, + email = application.Email, + desiredUsername = application.DesiredUsername, + timezone = application.Timezone, + appliedRole = (int)application.Role, + platforms = application.Platforms, + skills = application.Skills ?? "", + motivation = application.Motivation, + status = 0, // Pending + silverDeskProvisioned = true + }; + + var appResponse = await _httpClient.PostAsJsonAsync("/api/developer-program/applications", applicationPayload); + + if (appResponse.IsSuccessStatusCode) + { + _logger.LogInformation("DeveloperApplication record created for {Email}", application.Email); + } + else + { + var appError = await appResponse.Content.ReadAsStringAsync(); + _logger.LogWarning("Failed to create DeveloperApplication record for {Email}: {StatusCode} - {Body}", + application.Email, appResponse.StatusCode, appError); + } + } + catch (Exception ex) + { + _logger.LogWarning(ex, "Failed to create DeveloperApplication record for {Email} — user and ticket were created successfully", + application.Email); + } + _logger.LogInformation("Developer application submitted for {Email} as {Role} — user registered and ticket created", application.Email, application.Role);