diff --git a/Wonky.Client/Helpers/Utils.cs b/Wonky.Client/Helpers/Utils.cs
index 901f5122..c9af8164 100644
--- a/Wonky.Client/Helpers/Utils.cs
+++ b/Wonky.Client/Helpers/Utils.cs
@@ -14,6 +14,7 @@
//
using System.Net.Mail;
+using System.Text.RegularExpressions;
using Wonky.Client.Models;
namespace Wonky.Client.Helpers;
@@ -23,6 +24,29 @@ namespace Wonky.Client.Helpers;
///
public static class Utils
{
+ ///
+ /// Sanitize string by removing everything but digits
+ ///
+ ///
+ ///
+ public static string StringToDigits(string digitString)
+ {
+ if (string.IsNullOrWhiteSpace(digitString))
+ return "";
+ var regexObj = new Regex(@"[^\d]");
+ return regexObj.Replace(digitString, "");
+ }
+
+ ///
+ /// Validate string is only numbers
+ ///
+ ///
+ ///
+ private static bool IsDigitsOnly(string check)
+ {
+ return check.All(c => c is >= '0' and <= '9');
+ }
+
public static bool Validate(ValidateType validateType, string toValidate)
{
return validateType switch
diff --git a/Wonky.Client/Helpers/VatUtils.cs b/Wonky.Client/Helpers/VatUtils.cs
index c0678466..27a40c9a 100644
--- a/Wonky.Client/Helpers/VatUtils.cs
+++ b/Wonky.Client/Helpers/VatUtils.cs
@@ -32,7 +32,7 @@ public class VatUtils
if (string.IsNullOrWhiteSpace(vatNumber) || string.IsNullOrWhiteSpace(countryCode))
return false;
- var sanitisedVat = SanitizeVatNumber(vatNumber);
+ var sanitisedVat = Utils.StringToDigits(vatNumber);
return countryCode.ToUpperInvariant() switch
{
@@ -42,30 +42,7 @@ public class VatUtils
_ => false
};
}
-
- ///
- /// Sanitize Vat remove everything but digits
- ///
- ///
- ///
- public static string SanitizeVatNumber(string vatNumber)
- {
- if (string.IsNullOrWhiteSpace(vatNumber))
- return "";
- var regexObj = new Regex(@"[^\d]");
- return regexObj.Replace(vatNumber, "");
- }
- ///
- /// Validate string is only numbers
- ///
- ///
- ///
- private static bool IsDigitsOnly(string check)
- {
- return check.All(c => c is >= '0' and <= '9');
- }
-
///
/// Validate Danish Vat number format
///
diff --git a/Wonky.Client/HttpRepository/ISystemSendSmsService.cs b/Wonky.Client/HttpRepository/ISystemSendSmsService.cs
new file mode 100644
index 00000000..c7867caf
--- /dev/null
+++ b/Wonky.Client/HttpRepository/ISystemSendSmsService.cs
@@ -0,0 +1,33 @@
+// Copyright (C) 2022 FCS Frede's Computer Services.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
+//
+
+using Wonky.Entity.DTO;
+using Wonky.Entity.Views;
+
+namespace Wonky.Client.HttpRepository;
+
+///
+/// Interface for sending emai
+///
+public interface ISystemSendSmsService
+{
+ ///
+ /// Send Mail
+ ///
+ ///
+ ///
+ ///
+ Task SendSms(ShortMessage message);
+}
\ No newline at end of file
diff --git a/Wonky.Client/HttpRepository/SystemSendSmsService.cs b/Wonky.Client/HttpRepository/SystemSendSmsService.cs
new file mode 100644
index 00000000..8ae5a48c
--- /dev/null
+++ b/Wonky.Client/HttpRepository/SystemSendSmsService.cs
@@ -0,0 +1,66 @@
+// Copyright (C) 2022 FCS Frede's Computer Services.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
+//
+
+using System.Net.Http.Json;
+using System.Text.Json;
+using Microsoft.AspNetCore.Components;
+using Microsoft.Extensions.Options;
+using Wonky.Entity.Configuration;
+using Wonky.Entity.DTO;
+using Wonky.Entity.Views;
+
+namespace Wonky.Client.HttpRepository;
+
+public class SystemSendSmsService : ISystemSendSmsService
+{
+ private readonly JsonSerializerOptions? _options = new JsonSerializerOptions
+ {
+ PropertyNameCaseInsensitive = true
+ };
+
+ private readonly NavigationManager _navigation;
+ private ILogger _logger;
+ private readonly HttpClient _client;
+ private readonly ApiConfig _api;
+
+ public SystemSendSmsService(HttpClient client, ILogger logger,
+ NavigationManager navigation, IOptions configuration)
+ {
+ _client = client;
+ _logger = logger;
+ _navigation = navigation;
+ _api = configuration.Value;
+ }
+
+ ///
+ /// Send Mail
+ ///
+ ///
+ ///
+ public async Task SendSms(ShortMessage message)
+ {
+ var response = await _client.PostAsJsonAsync($"{_api.ServicesSms}", message, _options);
+ if (!response.IsSuccessStatusCode)
+ return new ApiResponseView
+ {
+ Code = (int)response.StatusCode,
+ Message = $"{response.ReasonPhrase}: {await response.Content.ReadAsStringAsync()}",
+ IsSuccess = false,
+ Id = ""
+ };
+ var content = await response.Content.ReadAsStringAsync();
+ return JsonSerializer.Deserialize(content, _options);
+ }
+}
\ No newline at end of file
diff --git a/Wonky.Client/OverlayCustomer/CustomerActivityViewOverlay.razor b/Wonky.Client/OverlayCustomer/CustomerActivityViewOverlay.razor
index 80dd4a2a..e7b88e7e 100644
--- a/Wonky.Client/OverlayCustomer/CustomerActivityViewOverlay.razor
+++ b/Wonky.Client/OverlayCustomer/CustomerActivityViewOverlay.razor
@@ -63,12 +63,12 @@
-
+
-
+
diff --git a/Wonky.Client/Pages/AdvisorActivityCreatePage.razor.cs b/Wonky.Client/Pages/AdvisorActivityCreatePage.razor.cs
index f838fdf3..21cbcb89 100644
--- a/Wonky.Client/Pages/AdvisorActivityCreatePage.razor.cs
+++ b/Wonky.Client/Pages/AdvisorActivityCreatePage.razor.cs
@@ -257,7 +257,7 @@ public partial class AdvisorActivityCreatePage : IDisposable
if (OrgWarning)
return;
OrgWarning = true;
- if (Company.CountryCode.ToLower() == "se" && VatUtils.SanitizeVatNumber(Activity.VatNumber).Length < 10 &&
+ if (Company.CountryCode.ToLower() == "se" && Utils.StringToDigits(Activity.VatNumber).Length < 10 &&
Activity.ActivityStatusEnum == "order")
{
Toaster.ShowWarning("Org nummer er ufuldstændig. Skal opdateres før bestilling kan sendes. ", "ADVARSEL");
@@ -573,7 +573,7 @@ public partial class AdvisorActivityCreatePage : IDisposable
if (Activity.ActivityStatusEnum.ToLower() is "order" or "quote"
&& Company.CountryCode.ToLower() == "se"
- && VatUtils.SanitizeVatNumber(Activity.VatNumber).Length < 10)
+ && Utils.StringToDigits(Activity.VatNumber).Length < 10)
{
ShowOrgWarning();
PoFormInvalid = true;
diff --git a/Wonky.Client/Pages/OfficeOrderViewPage.razor b/Wonky.Client/Pages/OfficeOrderViewPage.razor
index 8c68008c..ebebe2ec 100644
--- a/Wonky.Client/Pages/OfficeOrderViewPage.razor
+++ b/Wonky.Client/Pages/OfficeOrderViewPage.razor
@@ -101,6 +101,10 @@
Lev.Postnr By
@ReportItem.DlvZipCity
+
+
Email
+
@ReportItem.Company.Email
+
diff --git a/Wonky.Client/Pages/SystemMaintenanceMessage.razor b/Wonky.Client/Pages/SystemMaintenanceMessage.razor
new file mode 100644
index 00000000..e2380fe7
--- /dev/null
+++ b/Wonky.Client/Pages/SystemMaintenanceMessage.razor
@@ -0,0 +1,65 @@
+@* Copyright (C) 2022 FCS Frede's Computer Services.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
+*@
+@using Microsoft.AspNetCore.Authorization
+@using Wonky.Client.Helpers
+@using System.Text.Json
+@attribute [Authorize(Roles = "Admin")]
+@page "/system/sms"
+
+
+
+
+
+ Drift Meddelelse (SMS)
+
+
+
+
+ Loading...
+
+
+
+
+
+
+
+
+
+
+
+ @foreach (var recipient in Recipients)
+ {
+
+
+
+
+ }
+
+
+
+
+
+
+
+
+
+
+ Status Kode: @SmsResponse.Code
+
+
+ Meddelelse: @SmsResponse.Message
+
+
+
\ No newline at end of file
diff --git a/Wonky.Client/Pages/SystemMaintenanceMessage.razor.cs b/Wonky.Client/Pages/SystemMaintenanceMessage.razor.cs
new file mode 100644
index 00000000..4075407f
--- /dev/null
+++ b/Wonky.Client/Pages/SystemMaintenanceMessage.razor.cs
@@ -0,0 +1,85 @@
+using System.Text.Json;
+using Blazored.Toast.Services;
+using Microsoft.AspNetCore.Components;
+using Wonky.Client.Helpers;
+using Wonky.Client.HttpInterceptors;
+using Wonky.Client.HttpRepository;
+using Wonky.Entity.DTO;
+using Wonky.Entity.Views;
+
+namespace Wonky.Client.Pages;
+
+public partial class SystemMaintenanceMessage
+{
+ [Inject] public HttpInterceptorService Interceptor { get; set; }
+ [Inject] public ISystemUserRepository UserRepo { get; set; }
+ [Inject] public ISystemSendSmsService SmsService { get; set; }
+ [Inject] public ILogger Logger { get; set; }
+ [Inject] public IToastService Toaster { get; set; }
+
+ private List Users { get; set; }
+ private ShortMessage Message { get; set; } = new();
+ private List Recipients { get; set; } = new();
+ private ApiResponseView SmsResponse { get; set; } = new();
+ private bool Working { get; set; } = true;
+ private bool MsgSent { get; set; }
+
+ private readonly JsonSerializerOptions _options = new JsonSerializerOptions
+ {
+ PropertyNameCaseInsensitive = true
+ };
+
+ protected override async Task OnInitializedAsync()
+ {
+ Interceptor.RegisterEvent();
+ Interceptor.RegisterBeforeSendEvent();
+
+ Users = await UserRepo.GetUsers();
+
+ var allRecipients = Users.Where(x => Utils.StringToDigits(x.PhoneNumber) != string.Empty)
+ .Select(x => new Recipient
+ {
+ Mobile = Utils.StringToDigits(x.PhoneNumber),
+ Name = x.FullName
+ }).ToList();
+ Recipients = (from r in allRecipients select r).DistinctBy(x => x.Mobile).ToList();
+
+ Working = false;
+ }
+
+ private async Task SendMessage()
+ {
+ Working = true;
+ var recipients = (from recipient in Recipients where recipient.Enabled select recipient.Mobile).ToList();
+ if (!recipients.Any())
+ {
+ Toaster.ShowError("Der er ingen modtagere valgt!");
+ return;
+ }
+
+ if (string.IsNullOrWhiteSpace(Message.Body))
+ {
+ Toaster.ShowError("Meddelelsesfeltet er tomt!");
+ return;
+ }
+ Message.From = "Innotec IT";
+ Message.To = string.Join(",", recipients);
+
+ Logger.LogDebug("{}", JsonSerializer.Serialize(Message, _options));
+
+ SmsResponse = await SmsService.SendSms(Message);
+ if (SmsResponse.Code == 201)
+ {
+ MsgSent = true;
+ }
+ Working = false;
+
+ }
+}
+
+internal sealed class Recipient
+{
+ public bool Enabled { get; set; }
+ public string Name { get; set; }
+ public string Mobile { get; set; }
+}
\ No newline at end of file
diff --git a/Wonky.Client/Pages/SystemUserViewEditPage.razor b/Wonky.Client/Pages/SystemUserViewEditPage.razor
index 13eb0ef6..7225d541 100644
--- a/Wonky.Client/Pages/SystemUserViewEditPage.razor
+++ b/Wonky.Client/Pages/SystemUserViewEditPage.razor
@@ -15,7 +15,10 @@
@using Microsoft.AspNetCore.Authorization
+@using Microsoft.AspNetCore.Authorization.Infrastructure
@using Wonky.Client.Components
+@using System.Security.Principal
+@using Wonky.Client.Models
@attribute [Authorize(Roles = "Admin")]
@page "/system/users/{UserId}"
@@ -27,7 +30,7 @@