Skip to content

Commit aaaad64

Browse files
Refactor: move message handlers to Messages namespace (#637)
Reorganized MediatR command handlers related to message token generation and notifications into the new Grand.Business.Messages.Commands.Handlers namespaces. Also moved common handlers (ClearMostViewed, GetSitemapXml) to Grand.Business.Messages.Commands.Handlers.Common. Updated using statements and project references accordingly. Improved test assertions in CustomerTagServiceTests for clarity. No functional changes to handler logic.
1 parent 3895932 commit aaaad64

17 files changed

+29
-19
lines changed

src/Modules/Grand.Module.ScheduledTasks/Commands/Handlers/Catalog/SendNotificationsToSubscribersCommandHandler.cs renamed to src/Business/Grand.Business.Messages/Commands/Handlers/Catalog/SendNotificationsToSubscribersCommandHandler.cs

File renamed without changes.

src/Modules/Grand.Module.ScheduledTasks/Commands/Handlers/Catalog/SendOutBidCustomerNotificationCommandHandler.cs renamed to src/Business/Grand.Business.Messages/Commands/Handlers/Catalog/SendOutBidCustomerNotificationCommandHandler.cs

File renamed without changes.

src/Modules/Grand.Module.ScheduledTasks/Commands/Handlers/Catalog/SendQuantityBelowStoreOwnerNotificationCommandHandler.cs renamed to src/Business/Grand.Business.Messages/Commands/Handlers/Catalog/SendQuantityBelowStoreOwnerNotificationCommandHandler.cs

File renamed without changes.

src/Modules/Grand.Module.ScheduledTasks/Commands/Handlers/Common/ClearMostViewedCommandHandler.cs renamed to src/Business/Grand.Business.Messages/Commands/Handlers/Common/ClearMostViewedCommandHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using Grand.Domain.Catalog;
44
using MediatR;
55

6-
namespace Grand.Business.System.Commands.Handlers.Common;
6+
namespace Grand.Business.Messages.Commands.Handlers.Common;
77

88
public class ClearMostViewedCommandHandler : IRequestHandler<ClearMostViewedCommand, bool>
99
{

src/Modules/Grand.Module.ScheduledTasks/Commands/Handlers/Common/GetSitemapXMLCommandHandler.cs renamed to src/Business/Grand.Business.Messages/Commands/Handlers/Common/GetSitemapXMLCommandHandler.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
using System.Text.RegularExpressions;
2020
using System.Xml;
2121

22-
namespace Grand.Business.System.Commands.Handlers.Common;
22+
namespace Grand.Business.Messages.Commands.Handlers.Common;
2323

2424
public class GetSitemapXmlCommandHandler : IRequestHandler<GetSitemapXmlCommand, string>
2525
{
@@ -216,8 +216,11 @@ private async Task<IEnumerable<SitemapUrl>> GetCategoryUrls(string parentCategor
216216
var imageurl = string.Empty;
217217
if (_commonSettings.SitemapIncludeImage)
218218
if (!string.IsNullOrEmpty(category.PictureId))
219+
{
219220
imageurl = await _pictureService.GetPictureUrl(category.PictureId, showDefaultPicture: false,
220221
storeLocation: storeLocation);
222+
}
223+
221224
categories.Add(new SitemapUrl(url, imageurl, UpdateFrequency.Weekly,
222225
category.UpdatedOnUtc ?? category.CreatedOnUtc));
223226
categories.AddRange(await GetCategoryUrls(category.Id, language));
@@ -244,8 +247,11 @@ private async Task<IEnumerable<SitemapUrl>> GetBrandUrls(Language language, Stor
244247
var imageUrl = string.Empty;
245248
if (_commonSettings.SitemapIncludeImage)
246249
if (!string.IsNullOrEmpty(brand.PictureId))
250+
{
247251
imageUrl = await _pictureService.GetPictureUrl(brand.PictureId, showDefaultPicture: false,
248252
storeLocation: storeLocation);
253+
}
254+
249255
brandUrls.Add(new SitemapUrl(url, imageUrl, UpdateFrequency.Weekly,
250256
brand.UpdatedOnUtc ?? brand.CreatedOnUtc));
251257
}
@@ -272,8 +278,11 @@ private async Task<IEnumerable<SitemapUrl>> GetProductUrls(Language language, St
272278
var imageUrl = string.Empty;
273279
if (_commonSettings.SitemapIncludeImage)
274280
if (!string.IsNullOrEmpty(product.ProductPictures.FirstOrDefault()?.PictureId))
281+
{
275282
imageUrl = await _pictureService.GetPictureUrl(product.ProductPictures.FirstOrDefault()?.PictureId,
276283
showDefaultPicture: false, storeLocation: storeLocation);
284+
}
285+
277286
products.Add(new SitemapUrl(url, imageUrl, UpdateFrequency.Weekly,
278287
product.UpdatedOnUtc ?? product.CreatedOnUtc));
279288
}
@@ -319,8 +328,11 @@ private async Task<IEnumerable<SitemapUrl>> GetBlogPostsUrls(Language language,
319328
var imageurl = string.Empty;
320329
if (_commonSettings.SitemapIncludeImage)
321330
if (!string.IsNullOrEmpty(blogpost.PictureId))
331+
{
322332
imageurl = await _pictureService.GetPictureUrl(blogpost.PictureId, showDefaultPicture: false,
323333
storeLocation: storeLocation);
334+
}
335+
324336
blog.Add(new SitemapUrl(url, imageurl, UpdateFrequency.Weekly, DateTime.UtcNow));
325337
}
326338

src/Modules/Grand.Module.ScheduledTasks/Commands/Handlers/Messages/GetAttributeCombinationTokensCommandHandler.cs renamed to src/Business/Grand.Business.Messages/Commands/Handlers/Messages/GetAttributeCombinationTokensCommandHandler.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
using Grand.Domain.Catalog;
55
using MediatR;
66

7-
namespace Grand.Business.System.Commands.Handlers.Messages;
7+
namespace Grand.Business.Messages.Commands.Handlers.Messages;
88

9-
public class
10-
GetAttributeCombinationTokensCommandHandler : IRequestHandler<GetAttributeCombinationTokensCommand,
11-
LiquidAttributeCombination>
9+
public class GetAttributeCombinationTokensCommandHandler : IRequestHandler<GetAttributeCombinationTokensCommand, LiquidAttributeCombination>
1210
{
1311
private readonly IProductAttributeFormatter _productAttributeFormatter;
1412

src/Modules/Grand.Module.ScheduledTasks/Commands/Handlers/Messages/GetAuctionTokensCommandHandler.cs renamed to src/Business/Grand.Business.Messages/Commands/Handlers/Messages/GetAuctionTokensCommandHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using MediatR;
66
using System.Globalization;
77

8-
namespace Grand.Business.System.Commands.Handlers.Messages;
8+
namespace Grand.Business.Messages.Commands.Handlers.Messages;
99

1010
public class GetAuctionTokensCommandHandler : IRequestHandler<GetAuctionTokensCommand, LiquidAuctions>
1111
{

src/Modules/Grand.Module.ScheduledTasks/Commands/Handlers/Messages/GetGiftVoucherTokensCommandHandler.cs renamed to src/Business/Grand.Business.Messages/Commands/Handlers/Messages/GetGiftVoucherTokensCommandHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using Grand.Business.Core.Utilities.Messages.DotLiquidDrops;
55
using MediatR;
66

7-
namespace Grand.Business.System.Commands.Handlers.Messages;
7+
namespace Grand.Business.Messages.Commands.Handlers.Messages;
88

99
public class GetGiftVoucherTokensCommandHandler : IRequestHandler<GetGiftVoucherTokensCommand, LiquidGiftVoucher>
1010
{

src/Modules/Grand.Module.ScheduledTasks/Commands/Handlers/Messages/GetMerchandiseReturnTokensCommandHandler.cs renamed to src/Business/Grand.Business.Messages/Commands/Handlers/Messages/GetMerchandiseReturnTokensCommandHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using Grand.Business.Core.Utilities.Messages.DotLiquidDrops;
66
using MediatR;
77

8-
namespace Grand.Business.System.Commands.Handlers.Messages;
8+
namespace Grand.Business.Messages.Commands.Handlers.Messages;
99

1010
public class
1111
GetMerchandiseReturnTokensCommandHandler : IRequestHandler<GetMerchandiseReturnTokensCommand,

src/Modules/Grand.Module.ScheduledTasks/Commands/Handlers/Messages/GetOrderTokensCommandHandler.cs renamed to src/Business/Grand.Business.Messages/Commands/Handlers/Messages/GetOrderTokensCommandHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
using System.Globalization;
1717
using System.Net;
1818

19-
namespace Grand.Business.System.Commands.Handlers.Messages;
19+
namespace Grand.Business.Messages.Commands.Handlers.Messages;
2020

2121
public class GetOrderTokensCommandHandler : IRequestHandler<GetOrderTokensCommand, LiquidOrder>
2222
{

0 commit comments

Comments
 (0)