Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

PushNotificationsService.cs - remove translationService

support7add529203ba
diff --git a/src/Business/Grand.Business.Marketing/Services/PushNotifications/PushNotificationsService.cs b/src/Business/Grand.Business.Marketing/Services/PushNotifications/PushNotificationsService.cs
index 821d55cf4..ccea57e32 100644
--- a/src/Business/Grand.Business.Marketing/Services/PushNotifications/PushNotificationsService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/PushNotifications/PushNotificationsService.cs
@@ -1,5 +1,4 @@
-using Grand.Business.Core.Interfaces.Common.Localization;
-using Grand.Business.Core.Interfaces.Common.Logging;
+using Grand.Business.Core.Interfaces.Common.Logging;
using Grand.Business.Core.Interfaces.Marketing.PushNotifications;
using Grand.Business.Marketing.Utilities;
using Grand.Domain;
@@ -18,7 +17,6 @@ namespace Grand.Business.Marketing.Services.PushNotifications
private readonly IRepository<PushMessage> _pushMessagesRepository;
private readonly IMediator _mediator;
private readonly PushNotificationsSettings _pushNotificationsSettings;
- private readonly ITranslationService _translationService;
private readonly ILogger _logger;
private readonly HttpClient _httpClient;
@@ -29,7 +27,6 @@ namespace Grand.Business.Marketing.Services.PushNotifications
IRepository<PushMessage> pushMessagesRepository,
IMediator mediator,
PushNotificationsSettings pushNotificationsSettings,
- ITranslationService translationService,
ILogger logger,
HttpClient httpClient)
{
@@ -37,7 +34,6 @@ namespace Grand.Business.Marketing.Services.PushNotifications
_pushMessagesRepository = pushMessagesRepository;
_mediator = mediator;
_pushNotificationsSettings = pushNotificationsSettings;
- _translationService = translationService;
_logger = logger;
_httpClient = httpClient;
}
@@ -156,7 +152,7 @@ namespace Grand.Business.Marketing.Services.PushNotifications
var receivers = await GetPushReceivers();
if (!receivers.Any())
{
- return (false, _translationService.GetResource("Admin.PushNotifications.Error.NoReceivers"));
+ return (false, "Admin.PushNotifications.Error.NoReceivers");
}
const int batchSize = 1000;
@@ -210,7 +206,7 @@ namespace Grand.Business.Marketing.Services.PushNotifications
Title = title
});
- return (true, string.Format(_translationService.GetResource("Admin.PushNotifications.MessageSent"), responseMessage.success, responseMessage.failure));
+ return (true, "Admin.PushNotifications.MessageSent");
}
catch (Exception ex)
{
diff --git a/src/Tests/Grand.Business.Marketing.Tests/Services/PushNotifications/PushNotificationsServiceTests.cs b/src/Tests/Grand.Business.Marketing.Tests/Services/PushNotifications/PushNotificationsServiceTests.cs
index dfe6a5042..2961523fe 100644
--- a/src/Tests/Grand.Business.Marketing.Tests/Services/PushNotifications/PushNotificationsServiceTests.cs
+++ b/src/Tests/Grand.Business.Marketing.Tests/Services/PushNotifications/PushNotificationsServiceTests.cs
@@ -1,5 +1,4 @@
-using Grand.Business.Core.Interfaces.Common.Localization;
-using Grand.Business.Core.Interfaces.Common.Logging;
+using Grand.Business.Core.Interfaces.Common.Logging;
using Grand.Business.Marketing.Services.PushNotifications;
using Grand.Business.Marketing.Utilities;
using Grand.Data.Tests.MongoDb;
@@ -22,7 +21,6 @@ namespace Grand.Business.Marketing.Tests.Services.PushNotifications
private IRepository<PushRegistration> _repositoryPushRegistration;
private IRepository<PushMessage> _repositoryPushMessage;
private Mock<IMediator> _mediatorMock;
- private Mock<ITranslationService> _translationServiceMock;
private Mock<ILogger> _loggerMock;
@@ -32,8 +30,6 @@ namespace Grand.Business.Marketing.Tests.Services.PushNotifications
_repositoryPushRegistration = new MongoDBRepositoryTest<PushRegistration>();
_repositoryPushMessage = new MongoDBRepositoryTest<PushMessage>();
_mediatorMock = new Mock<IMediator>();
- _translationServiceMock = new Mock<ITranslationService>();
- _translationServiceMock.Setup(x => x.GetResource(It.IsAny<string>())).Returns("translate");
_loggerMock = new Mock<ILogger>();
var mockMessageHandler = new Mock<HttpMessageHandler>();
@@ -48,7 +44,7 @@ namespace Grand.Business.Marketing.Tests.Services.PushNotifications
});
var httpClient = new HttpClient(mockMessageHandler.Object);
- _pushNotificationsService = new PushNotificationsService(_repositoryPushRegistration, _repositoryPushMessage, _mediatorMock.Object, new PushNotificationsSettings(), _translationServiceMock.Object,
+ _pushNotificationsService = new PushNotificationsService(_repositoryPushRegistration, _repositoryPushMessage, _mediatorMock.Object, new PushNotificationsSettings(),
_loggerMock.Object, httpClient);
}
diff --git a/src/Web/Grand.Web.Admin/Controllers/PushNotificationsController.cs b/src/Web/Grand.Web.Admin/Controllers/PushNotificationsController.cs
index a246b5594..73ba16fab 100644
--- a/src/Web/Grand.Web.Admin/Controllers/PushNotificationsController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/PushNotificationsController.cs
@@ -68,11 +68,11 @@ namespace Grand.Web.Admin.Controllers
var result = await _pushNotificationsService.SendPushNotification(model.Title, model.MessageText, pictureUrl, model.ClickUrl);
if (result.Item1)
{
- Success(result.Item2);
+ Success(_translationService.GetResource(result.Item2));
}
else
{
- Error(result.Item2);
+ Error(_translationService.GetResource(result.Item2));
}
}
else