@page "/get-support/{deviceId?}" @using System.ComponentModel.DataAnnotations @inject IDataService DataService @inject IEmailSenderEx EmailSender @if (string.IsNullOrWhiteSpace(DeviceId)) {

Get Support

Device ID is missing. Please use a valid shortcut to the support page, which will include the device ID.

} else {
@if (!string.IsNullOrWhiteSpace(_statusMessage)) { }

Get Support

} @code { private string? _statusMessage; private string _alertClass = "alert-success"; [Parameter] public string? DeviceId { get; init; } [SupplyParameterFromForm] private InputModel Input { get; set; } = new(); private void CloseAlert() { _statusMessage = null; } private async Task OnValidSubmitAsync() { if (string.IsNullOrWhiteSpace(DeviceId)) { return; } var deviceResult = await DataService.GetDevice(DeviceId); if (!deviceResult.IsSuccess) { _alertClass = "alert-danger"; _statusMessage = "Device not found."; return; } var orgId = deviceResult.Value.OrganizationID; var alertParts = new string[] { $"{Input.Name} is requesting support.", $"Device ID: {DeviceId}", $"Email: {Input.Email}.", $"Phone: {Input.Phone}.", $"Chat OK: {Input.ChatResponseOk}." }; var alertMessage = string.Join(" ", alertParts); await DataService.AddAlert(DeviceId, orgId, alertMessage); var orgUsers = await DataService.GetAllUsersInOrganization(orgId); var emailMessage = string.Join("
", alertParts); foreach (var user in orgUsers) { if (string.IsNullOrWhiteSpace(user.Email)) { continue; } await EmailSender.SendEmailAsync(user.Email, "Support Request", emailMessage); } _alertClass = "alert-success"; _statusMessage = "We got it! Someone will contact you soon."; } private class InputModel { [StringLength(150)] [Required] public string Name { get; set; } = string.Empty; [Required] [EmailAddress] public string Email { get; set; } = string.Empty; public string? Phone { get; set; } public bool ChatResponseOk { get; set; } } }