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.

Refactoring - use repository extensions

KrzysztofPajakd9e74709f4b2
diff --git a/src/API/Grand.Api/Filters/AuthorizeApiAdminAttribute.cs b/src/API/Grand.Api/Filters/AuthorizeApiAdminAttribute.cs
index f76ba73f6..a7d0e5f4a 100644
--- a/src/API/Grand.Api/Filters/AuthorizeApiAdminAttribute.cs
+++ b/src/API/Grand.Api/Filters/AuthorizeApiAdminAttribute.cs
@@ -1,7 +1,7 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
+using Grand.Domain.Data;
using Grand.Domain.Security;
-using Grand.Infrastructure.Data;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
diff --git a/src/Business/Grand.Business.Common/Services/Pdf/WkPdfService.cs b/src/Business/Grand.Business.Common/Services/Pdf/WkPdfService.cs
index 2e1a898b4..fadff600a 100644
--- a/src/Business/Grand.Business.Common/Services/Pdf/WkPdfService.cs
+++ b/src/Business/Grand.Business.Common/Services/Pdf/WkPdfService.cs
@@ -26,14 +26,16 @@ namespace Grand.Business.Common.Services.Pdf
private readonly IViewRenderService _viewRenderService;
private readonly ILanguageService _languageService;
private readonly IRepository<Download> _downloadRepository;
+ private readonly IMongoDBContext _mongoDBContext;
public WkPdfService(IGeneratePdf generatePdf, IViewRenderService viewRenderService, IRepository<Download> downloadRepository,
- ILanguageService languageService)
+ ILanguageService languageService, IMongoDBContext mongoDBContext)
{
_generatePdf = generatePdf;
_viewRenderService = viewRenderService;
_languageService = languageService;
_downloadRepository = downloadRepository;
+ _mongoDBContext = mongoDBContext;
}
public async Task PrintOrdersToPdf(Stream stream, IList<Order> orders, string languageId = "", string vendorId = "")
@@ -119,9 +121,8 @@ namespace Grand.Business.Common.Services.Pdf
Extension = ".pdf",
ContentType = "application/pdf",
};
- var bucket = new MongoDB.Driver.GridFS.GridFSBucket(_downloadRepository.Database);
- var id = await bucket.UploadFromBytesAsync(download.Filename, ms.ToArray());
- download.DownloadObjectId = id.ToString();
+
+ download.DownloadObjectId = await _mongoDBContext.GridFSBucketUploadFromBytesAsync(download.Filename, ms.ToArray());
await _downloadRepository.InsertAsync(download);
//TODO
diff --git a/src/Business/Grand.Business.Storage/Services/DownloadService.cs b/src/Business/Grand.Business.Storage/Services/DownloadService.cs
index 5aa730a83..8170c1d40 100644
--- a/src/Business/Grand.Business.Storage/Services/DownloadService.cs
+++ b/src/Business/Grand.Business.Storage/Services/DownloadService.cs
@@ -17,6 +17,7 @@ namespace Grand.Business.Storage.Services
#region Fields
private readonly IRepository<Download> _downloadRepository;
+ private readonly IMongoDBContext _mongoDBContext;
private readonly IMediator _mediator;
#endregion
@@ -27,11 +28,14 @@ namespace Grand.Business.Storage.Services
/// Ctor
/// </summary>
/// <param name="downloadRepository">Download repository</param>
+ /// <param name="mongoDBContext">DbContext</param>
/// <param name="mediator">Mediator</param>
public DownloadService(IRepository<Download> downloadRepository,
+ IMongoDBContext mongoDBContext,
IMediator mediator)
{
_downloadRepository = downloadRepository;
+ _mongoDBContext = mongoDBContext;
_mediator = mediator;
}
@@ -58,8 +62,7 @@ namespace Grand.Business.Storage.Services
protected virtual async Task<byte[]> DownloadAsBytes(string objectId)
{
- var bucket = new MongoDB.Driver.GridFS.GridFSBucket(_downloadRepository.Database);
- var binary = await bucket.DownloadAsBytesAsync(new MongoDB.Bson.ObjectId(objectId), new MongoDB.Driver.GridFS.GridFSDownloadOptions() { CheckMD5 = true, Seekable = true });
+ var binary = await _mongoDBContext.GridFSBucketDownload(objectId);
return binary;
}
/// <summary>
@@ -93,9 +96,7 @@ namespace Grand.Business.Storage.Services
throw new ArgumentNullException(nameof(download));
if (!download.UseDownloadUrl)
{
- var bucket = new MongoDB.Driver.GridFS.GridFSBucket(_downloadRepository.Database);
- var id = await bucket.UploadFromBytesAsync(download.Filename, download.DownloadBinary);
- download.DownloadObjectId = id.ToString();
+ download.DownloadObjectId = await _mongoDBContext.GridFSBucketUploadFromBytesAsync(download.Filename, download.DownloadBinary);
}
download.DownloadBinary = null;
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallationService.cs b/src/Business/Grand.Business.System/Services/Installation/InstallationService.cs
index 33a3dda0d..8c7aa75ba 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallationService.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallationService.cs
@@ -463,7 +463,7 @@ namespace Grand.Business.System.Services.Installation
var databaseName = mongourl.DatabaseName;
var mongodb = new MongoClient(connectionString).GetDatabase(databaseName);
var mongoDBContext = new MongoDBContext(mongodb);
-
+
var typeSearcher = _serviceProvider.GetRequiredService<ITypeSearcher>();
var q = typeSearcher.GetAssemblies().FirstOrDefault(x => x.GetName().Name == "Grand.Domain");
foreach (var item in q.GetTypes())
diff --git a/src/Business/Grand.Business.System/Startup/StartupApplication.cs b/src/Business/Grand.Business.System/Startup/StartupApplication.cs
index a2c28d998..b7fd364a4 100644
--- a/src/Business/Grand.Business.System/Startup/StartupApplication.cs
+++ b/src/Business/Grand.Business.System/Startup/StartupApplication.cs
@@ -10,6 +10,7 @@ using Grand.Business.System.Services.ExportImport;
using Grand.Business.System.Services.Installation;
using Grand.Business.System.Services.MachineNameProvider;
using Grand.Business.System.Services.Reports;
+using Grand.Domain.Data;
using Grand.Infrastructure;
using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Data;
diff --git a/src/Core/Grand.Domain/MongoDB/BsonUtcDateTimeSerializer.cs b/src/Core/Grand.Domain/Data/BsonUtcDateTimeSerializer.cs
similarity index 95%
rename from src/Core/Grand.Domain/MongoDB/BsonUtcDateTimeSerializer.cs
rename to src/Core/Grand.Domain/Data/BsonUtcDateTimeSerializer.cs
index 189105021..3d6d2bcac 100644
--- a/src/Core/Grand.Domain/MongoDB/BsonUtcDateTimeSerializer.cs
+++ b/src/Core/Grand.Domain/Data/BsonUtcDateTimeSerializer.cs
@@ -2,7 +2,7 @@
using MongoDB.Bson.Serialization.Serializers;
using System;
-namespace Grand.Domain.MongoDB
+namespace Grand.Domain.Data
{
public class BsonUtcDateTimeSerializer : DateTimeSerializer
{
diff --git a/src/Core/Grand.Infrastructure/Data/DataSettingsHelper.cs b/src/Core/Grand.Domain/Data/DataSettingsHelper.cs
similarity index 96%
rename from src/Core/Grand.Infrastructure/Data/DataSettingsHelper.cs
rename to src/Core/Grand.Domain/Data/DataSettingsHelper.cs
index a2638c2ea..82108034c 100644
--- a/src/Core/Grand.Infrastructure/Data/DataSettingsHelper.cs
+++ b/src/Core/Grand.Domain/Data/DataSettingsHelper.cs
@@ -1,4 +1,4 @@
-namespace Grand.Infrastructure.Data
+namespace Grand.Domain.Data
{
/// <summary>
/// Data settings helper
@@ -34,7 +34,7 @@
{
return _connectionString;
}
-
+
public static void ResetCache()
{
_databaseIsInstalled = false;
diff --git a/src/Core/Grand.Infrastructure/Data/DataSettingsManager.cs b/src/Core/Grand.Domain/Data/DataSettingsManager.cs
similarity index 97%
rename from src/Core/Grand.Infrastructure/Data/DataSettingsManager.cs
rename to src/Core/Grand.Domain/Data/DataSettingsManager.cs
index d6c669d9b..d23433a40 100644
--- a/src/Core/Grand.Infrastructure/Data/DataSettingsManager.cs
+++ b/src/Core/Grand.Domain/Data/DataSettingsManager.cs
@@ -4,7 +4,7 @@ using System.IO;
using System.Linq;
using System.Threading.Tasks;
-namespace Grand.Infrastructure.Data
+namespace Grand.Domain.Data
{
/// <summary>
/// Manager of data settings (connection string)
diff --git a/src/Core/Grand.Domain/Data/IMongoDBContext.cs b/src/Core/Grand.Domain/Data/IMongoDBContext.cs
index f57857a12..53af2a18b 100644
--- a/src/Core/Grand.Domain/Data/IMongoDBContext.cs
+++ b/src/Core/Grand.Domain/Data/IMongoDBContext.cs
@@ -9,6 +9,8 @@ namespace Grand.Domain.Data
public interface IMongoDBContext
{
IMongoDatabase Database();
+ Task<byte[]> GridFSBucketDownload(string id);
+ Task<string> GridFSBucketUploadFromBytesAsync(string filename, byte[] source);
Task<bool> DatabaseExist(string connectionString);
TResult RunCommand<TResult>(string command);
BsonDocument RunCommand(string command);
diff --git a/src/Core/Grand.Domain/Data/MongoDBContext.cs b/src/Core/Grand.Domain/Data/MongoDBContext.cs
index 9c154e64f..3e7ee3607 100644
--- a/src/Core/Grand.Domain/Data/MongoDBContext.cs
+++ b/src/Core/Grand.Domain/Data/MongoDBContext.cs
@@ -27,6 +27,31 @@ namespace Grand.Domain.Data
return _database;
}
+ protected IMongoDatabase TryReadMongoDatabase()
+ {
+ var dataSettingsManager = new DataSettingsManager();
+ var connectionString = dataSettingsManager.LoadSettings().DataConnectionString;
+
+ var mongourl = new MongoUrl(connectionString);
+ var databaseName = mongourl.DatabaseName;
+ var mongodb = new MongoClient(connectionString).GetDatabase(databaseName);
+ return mongodb;
+ }
+
+ public async Task<byte[]> GridFSBucketDownload(string id)
+ {
+ var bucket = new MongoDB.Driver.GridFS.GridFSBucket(_database);
+ var binary = await bucket.DownloadAsBytesAsync(new ObjectId(id), new MongoDB.Driver.GridFS.GridFSDownloadOptions() { CheckMD5 = true, Seekable = true });
+ return binary;
+
+ }
+ public async Task<string> GridFSBucketUploadFromBytesAsync(string filename, byte[] source)
+ {
+ var database = _database ?? TryReadMongoDatabase();
+ var bucket = new MongoDB.Driver.GridFS.GridFSBucket(database);
+ var id = await bucket.UploadFromBytesAsync(filename, source);
+ return id.ToString();
+ }
public async Task<bool> DatabaseExist(string connectionString)
{
var client = new MongoClient(connectionString);
diff --git a/src/Core/Grand.Domain/MongoDB/MongoDBMapperConfiguration.cs b/src/Core/Grand.Domain/Data/MongoDBMapperConfiguration.cs
similarity index 97%
rename from src/Core/Grand.Domain/MongoDB/MongoDBMapperConfiguration.cs
rename to src/Core/Grand.Domain/Data/MongoDBMapperConfiguration.cs
index 404f0b884..e75d0bfd9 100644
--- a/src/Core/Grand.Domain/MongoDB/MongoDBMapperConfiguration.cs
+++ b/src/Core/Grand.Domain/Data/MongoDBMapperConfiguration.cs
@@ -6,7 +6,7 @@ using MongoDB.Bson.Serialization.Serializers;
using System;
using System.Collections.Generic;
-namespace Grand.Domain.MongoDB
+namespace Grand.Domain.Data
{
public static class MongoDBMapperConfiguration
{
diff --git a/src/Core/Grand.Infrastructure/StartupBase.cs b/src/Core/Grand.Infrastructure/StartupBase.cs
index 57d966861..53d79320f 100644
--- a/src/Core/Grand.Infrastructure/StartupBase.cs
+++ b/src/Core/Grand.Infrastructure/StartupBase.cs
@@ -1,6 +1,6 @@
using AutoMapper;
using FluentValidation.AspNetCore;
-using Grand.Domain.MongoDB;
+using Grand.Domain.Data;
using Grand.Infrastructure.Caching.RabbitMq;
using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Mapper;
diff --git a/src/Tests/Grand.Business.Storage.Tests/Services/DownloadServiceTests.cs b/src/Tests/Grand.Business.Storage.Tests/Services/DownloadServiceTests.cs
index 646c0c239..b6f213385 100644
--- a/src/Tests/Grand.Business.Storage.Tests/Services/DownloadServiceTests.cs
+++ b/src/Tests/Grand.Business.Storage.Tests/Services/DownloadServiceTests.cs
@@ -18,6 +18,7 @@ namespace Grand.Business.Storage.Tests.Services
{
private Mock<IMediator> _mediatorMock;
private Mock<IRepository<Download>> _repositoryMock;
+ private Mock<IMongoDBContext> _mongoDBContext;
private DownloadService _service;
[TestInitialize]
@@ -25,7 +26,8 @@ namespace Grand.Business.Storage.Tests.Services
{
_mediatorMock = new Mock<IMediator>();
_repositoryMock = new Mock<IRepository<Download>>();
- _service = new DownloadService(_repositoryMock.Object,_mediatorMock.Object);
+ _mongoDBContext = new Mock<IMongoDBContext>();
+ _service = new DownloadService(_repositoryMock.Object, _mongoDBContext.Object, _mediatorMock.Object);
}
[TestMethod]
diff --git a/src/Web/Grand.Web.Common/Filters/AffiliateAttribute.cs b/src/Web/Grand.Web.Common/Filters/AffiliateAttribute.cs
index 1f4d7f1a0..d4060bb90 100644
--- a/src/Web/Grand.Web.Common/Filters/AffiliateAttribute.cs
+++ b/src/Web/Grand.Web.Common/Filters/AffiliateAttribute.cs
@@ -1,7 +1,7 @@
using Grand.Business.Customers.Interfaces;
-using Grand.Infrastructure;
-using Grand.Infrastructure.Data;
using Grand.Domain.Affiliates;
+using Grand.Domain.Data;
+using Grand.Infrastructure;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using System.Linq;
diff --git a/src/Web/Grand.Web.Common/Filters/AuthorizeAdminAttribute.cs b/src/Web/Grand.Web.Common/Filters/AuthorizeAdminAttribute.cs
index 9b8947e3b..a544d8acb 100644
--- a/src/Web/Grand.Web.Common/Filters/AuthorizeAdminAttribute.cs
+++ b/src/Web/Grand.Web.Common/Filters/AuthorizeAdminAttribute.cs
@@ -1,7 +1,7 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
+using Grand.Domain.Data;
using Grand.Domain.Security;
-using Grand.Infrastructure.Data;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Routing;
diff --git a/src/Web/Grand.Web.Common/Filters/AuthorizeVendorAttribute.cs b/src/Web/Grand.Web.Common/Filters/AuthorizeVendorAttribute.cs
index e8e4de1c8..1297dfd54 100644
--- a/src/Web/Grand.Web.Common/Filters/AuthorizeVendorAttribute.cs
+++ b/src/Web/Grand.Web.Common/Filters/AuthorizeVendorAttribute.cs
@@ -1,6 +1,6 @@
using Grand.Business.Common.Interfaces.Directory;
+using Grand.Domain.Data;
using Grand.Infrastructure;
-using Grand.Infrastructure.Data;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using System;
diff --git a/src/Web/Grand.Web.Common/Filters/ClosedStoreAttribute.cs b/src/Web/Grand.Web.Common/Filters/ClosedStoreAttribute.cs
index 51da2e359..f50650936 100644
--- a/src/Web/Grand.Web.Common/Filters/ClosedStoreAttribute.cs
+++ b/src/Web/Grand.Web.Common/Filters/ClosedStoreAttribute.cs
@@ -1,9 +1,9 @@
using Grand.Business.Cms.Interfaces;
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
-using Grand.Infrastructure;
-using Grand.Infrastructure.Data;
+using Grand.Domain.Data;
using Grand.Domain.Stores;
+using Grand.Infrastructure;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Filters;
diff --git a/src/Web/Grand.Web.Common/Filters/CustomerActivityAttribute.cs b/src/Web/Grand.Web.Common/Filters/CustomerActivityAttribute.cs
index 3575eff46..42c78916b 100644
--- a/src/Web/Grand.Web.Common/Filters/CustomerActivityAttribute.cs
+++ b/src/Web/Grand.Web.Common/Filters/CustomerActivityAttribute.cs
@@ -5,8 +5,8 @@ using Grand.Business.Customers.Interfaces;
using Grand.Business.Marketing.Interfaces.Customers;
using Grand.Domain.Common;
using Grand.Domain.Customers;
+using Grand.Domain.Data;
using Grand.Infrastructure;
-using Grand.Infrastructure.Data;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Mvc;
diff --git a/src/Web/Grand.Web.Common/Filters/LanguageAttribute.cs b/src/Web/Grand.Web.Common/Filters/LanguageAttribute.cs
index 903d58c92..3283604bd 100644
--- a/src/Web/Grand.Web.Common/Filters/LanguageAttribute.cs
+++ b/src/Web/Grand.Web.Common/Filters/LanguageAttribute.cs
@@ -1,8 +1,8 @@
using Grand.Business.Common.Interfaces.Localization;
+using Grand.Domain.Data;
using Grand.Domain.Localization;
using Grand.Infrastructure;
using Grand.Infrastructure.Configuration;
-using Grand.Infrastructure.Data;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Mvc;
diff --git a/src/Web/Grand.Web.Common/Filters/PasswordExpiredAttribute.cs b/src/Web/Grand.Web.Common/Filters/PasswordExpiredAttribute.cs
index 439eb26b6..d8a0a59ea 100644
--- a/src/Web/Grand.Web.Common/Filters/PasswordExpiredAttribute.cs
+++ b/src/Web/Grand.Web.Common/Filters/PasswordExpiredAttribute.cs
@@ -1,6 +1,6 @@
using Grand.Business.Customers.Queries.Models;
+using Grand.Domain.Data;
using Grand.Infrastructure;
-using Grand.Infrastructure.Data;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Controllers;
diff --git a/src/Web/Grand.Web.Common/Filters/PublicStoreAttribute.cs b/src/Web/Grand.Web.Common/Filters/PublicStoreAttribute.cs
index dbe3de850..144bcd601 100644
--- a/src/Web/Grand.Web.Common/Filters/PublicStoreAttribute.cs
+++ b/src/Web/Grand.Web.Common/Filters/PublicStoreAttribute.cs
@@ -1,6 +1,6 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
-using Grand.Infrastructure.Data;
+using Grand.Domain.Data;
using Grand.Domain.Stores;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
@@ -91,7 +91,7 @@ namespace Grand.Web.Common.Filters
else
//customer has not access to a public store
filterContext.Result = new RedirectToRouteResult("Login", new RouteValueDictionary());
-
+
}
#endregion
diff --git a/src/Web/Grand.Web.Common/Infrastructure/ApplicationBuilderExtensions.cs b/src/Web/Grand.Web.Common/Infrastructure/ApplicationBuilderExtensions.cs
index 31f08ca92..0756c21b5 100644
--- a/src/Web/Grand.Web.Common/Infrastructure/ApplicationBuilderExtensions.cs
+++ b/src/Web/Grand.Web.Common/Infrastructure/ApplicationBuilderExtensions.cs
@@ -1,14 +1,14 @@
using Grand.Business.Common.Extensions;
using Grand.Business.Common.Interfaces.Logging;
-using Grand.Web.Common.Middleware;
using Grand.Domain.Common;
+using Grand.Domain.Data;
using Grand.Infrastructure;
using Grand.Infrastructure.Configuration;
-using Grand.Infrastructure.Data;
using Grand.Infrastructure.Endpoints;
using Grand.Infrastructure.Plugins;
using Grand.Infrastructure.TypeSearchers;
using Grand.SharedKernel.Extensions;
+using Grand.Web.Common.Middleware;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics;
@@ -191,8 +191,7 @@ namespace Grand.Web.Common.Infrastructure
public static void UseGrandStaticFiles(this IApplicationBuilder application, AppConfig appConfig)
{
//static files
- application.UseStaticFiles(new StaticFileOptions
- {
+ application.UseStaticFiles(new StaticFileOptions {
OnPrepareResponse = ctx =>
{
@@ -203,8 +202,7 @@ namespace Grand.Web.Common.Infrastructure
});
//themes
- application.UseStaticFiles(new StaticFileOptions
- {
+ application.UseStaticFiles(new StaticFileOptions {
FileProvider = new PhysicalFileProvider(CommonPath.ThemePath),
RequestPath = new PathString("/Themes"),
OnPrepareResponse = ctx =>
@@ -214,8 +212,7 @@ namespace Grand.Web.Common.Infrastructure
}
});
//plugins
- application.UseStaticFiles(new StaticFileOptions
- {
+ application.UseStaticFiles(new StaticFileOptions {
FileProvider = new PhysicalFileProvider(CommonPath.PluginsPath),
RequestPath = new PathString("/Plugins"),
OnPrepareResponse = ctx =>
@@ -266,8 +263,7 @@ namespace Grand.Web.Common.Infrastructure
/// <param name="application">Builder for configuring an application's request pipeline</param>
public static void UseGrandForwardedHeaders(this IApplicationBuilder application)
{
- application.UseForwardedHeaders(new ForwardedHeadersOptions
- {
+ application.UseForwardedHeaders(new ForwardedHeadersOptions {
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
}
diff --git a/src/Web/Grand.Web.Common/Infrastructure/ServiceCollectionExtensions.cs b/src/Web/Grand.Web.Common/Infrastructure/ServiceCollectionExtensions.cs
index 2d60278e8..fb0b42f89 100644
--- a/src/Web/Grand.Web.Common/Infrastructure/ServiceCollectionExtensions.cs
+++ b/src/Web/Grand.Web.Common/Infrastructure/ServiceCollectionExtensions.cs
@@ -3,16 +3,16 @@ using Grand.Business.Authentication.Utilities;
using Grand.Business.Common.Interfaces.Configuration;
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
-using Grand.Web.Common.Extensions;
-using Grand.Web.Common.Routing;
-using Grand.Web.Common.Themes;
using Grand.Domain.Configuration;
+using Grand.Domain.Data;
using Grand.Infrastructure;
using Grand.Infrastructure.Configuration;
-using Grand.Infrastructure.Data;
using Grand.Infrastructure.Plugins;
using Grand.Infrastructure.TypeSearchers;
using Grand.SharedKernel.Extensions;
+using Grand.Web.Common.Extensions;
+using Grand.Web.Common.Routing;
+using Grand.Web.Common.Themes;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Http;
@@ -28,17 +28,17 @@ using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.IO;
+using System.IO.Compression;
using System.Linq;
using System.Text.Encodings.Web;
using System.Text.Unicode;
+using WebMarkupMin.AspNet.Common.Compressors;
using WebMarkupMin.AspNet.Common.UrlMatchers;
using WebMarkupMin.AspNetCore5;
+using WebMarkupMin.NUglify;
using IWmmLogger = WebMarkupMin.Core.Loggers.ILogger;
using WmmThrowExceptionLogger = WebMarkupMin.Core.Loggers.ThrowExceptionLogger;
-using WebMarkupMin.NUglify;
-using WebMarkupMin.AspNet.Common.Compressors;
-using System.IO.Compression;
namespace Grand.Web.Common.Infrastructure
{
@@ -57,8 +57,7 @@ namespace Grand.Web.Common.Infrastructure
//override cookie name
services.AddAntiforgery(options =>
{
- options.Cookie = new CookieBuilder()
- {
+ options.Cookie = new CookieBuilder() {
Name = $"{config.CookiePrefix}Antiforgery"
};
if (DataSettingsHelper.DatabaseIsInstalled())
@@ -78,8 +77,7 @@ namespace Grand.Web.Common.Infrastructure
{
services.AddSession(options =>
{
- options.Cookie = new CookieBuilder()
- {
+ options.Cookie = new CookieBuilder() {
Name = $"{config.CookiePrefix}Session",
HttpOnly = true,
};
@@ -393,8 +391,7 @@ namespace Grand.Web.Common.Infrastructure
configuration.GetSection("Application").Bind(config);
if (config.EnableProgressiveWebApp)
{
- var options = new WebEssentials.AspNetCore.Pwa.PwaOptions
- {
+ var options = new WebEssentials.AspNetCore.Pwa.PwaOptions {
Strategy = (WebEssentials.AspNetCore.Pwa.ServiceWorkerStrategy)config.ServiceWorkerStrategy,
RoutesToIgnore = "/admin/*"
};
diff --git a/src/Web/Grand.Web.Common/Middleware/InstallUrlMiddleware.cs b/src/Web/Grand.Web.Common/Middleware/InstallUrlMiddleware.cs
index b391dd517..2a4a6ebf0 100644
--- a/src/Web/Grand.Web.Common/Middleware/InstallUrlMiddleware.cs
+++ b/src/Web/Grand.Web.Common/Middleware/InstallUrlMiddleware.cs
@@ -1,4 +1,4 @@
-using Grand.Infrastructure.Data;
+using Grand.Domain.Data;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
using System;
diff --git a/src/Web/Grand.Web.Common/Startup/AuthenticationStartup.cs b/src/Web/Grand.Web.Common/Startup/AuthenticationStartup.cs
index adb89dae9..ee8b59522 100644
--- a/src/Web/Grand.Web.Common/Startup/AuthenticationStartup.cs
+++ b/src/Web/Grand.Web.Common/Startup/AuthenticationStartup.cs
@@ -1,8 +1,8 @@
-using Grand.Web.Common.Infrastructure;
-using Grand.Web.Common.Middleware;
+using Grand.Domain.Data;
using Grand.Infrastructure;
using Grand.Infrastructure.Configuration;
-using Grand.Infrastructure.Data;
+using Grand.Web.Common.Infrastructure;
+using Grand.Web.Common.Middleware;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
diff --git a/src/Web/Grand.Web.Common/Startup/DbCheckStartup.cs b/src/Web/Grand.Web.Common/Startup/DbCheckStartup.cs
index d6eb07d47..0ff86936e 100644
--- a/src/Web/Grand.Web.Common/Startup/DbCheckStartup.cs
+++ b/src/Web/Grand.Web.Common/Startup/DbCheckStartup.cs
@@ -1,6 +1,6 @@
-using Grand.Web.Common.Middleware;
+using Grand.Domain.Data;
using Grand.Infrastructure;
-using Grand.Infrastructure.Data;
+using Grand.Web.Common.Middleware;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
diff --git a/src/Web/Grand.Web.Common/Startup/ForwardedHeadersStartup.cs b/src/Web/Grand.Web.Common/Startup/ForwardedHeadersStartup.cs
index 13fd2415d..fb2f7e102 100644
--- a/src/Web/Grand.Web.Common/Startup/ForwardedHeadersStartup.cs
+++ b/src/Web/Grand.Web.Common/Startup/ForwardedHeadersStartup.cs
@@ -1,7 +1,7 @@
-using Grand.Web.Common.Infrastructure;
+using Grand.Domain.Data;
using Grand.Infrastructure;
using Grand.Infrastructure.Configuration;
-using Grand.Infrastructure.Data;
+using Grand.Web.Common.Infrastructure;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
diff --git a/src/Web/Grand.Web.Common/Startup/HostFilteringStartup.cs b/src/Web/Grand.Web.Common/Startup/HostFilteringStartup.cs
index 6896b19dd..58e62a7db 100644
--- a/src/Web/Grand.Web.Common/Startup/HostFilteringStartup.cs
+++ b/src/Web/Grand.Web.Common/Startup/HostFilteringStartup.cs
@@ -1,4 +1,5 @@
-using Grand.Infrastructure;
+using Grand.Domain.Data;
+using Grand.Infrastructure;
using Grand.Infrastructure.Data;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.HostFiltering;
diff --git a/src/Web/Grand.Web.Common/Startup/StartupApplication.cs b/src/Web/Grand.Web.Common/Startup/StartupApplication.cs
index 5a78cf6d5..392873d84 100644
--- a/src/Web/Grand.Web.Common/Startup/StartupApplication.cs
+++ b/src/Web/Grand.Web.Common/Startup/StartupApplication.cs
@@ -1,4 +1,5 @@
using FluentValidation;
+using Grand.Domain.Data;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Caching.Message;
diff --git a/src/Web/Grand.Web.Common/Startup/TaskHandlerStartup.cs b/src/Web/Grand.Web.Common/Startup/TaskHandlerStartup.cs
index 01fe1af46..54fbc1ed1 100644
--- a/src/Web/Grand.Web.Common/Startup/TaskHandlerStartup.cs
+++ b/src/Web/Grand.Web.Common/Startup/TaskHandlerStartup.cs
@@ -1,7 +1,7 @@
using Grand.Business.System.Interfaces.ScheduleTasks;
using Grand.Business.System.Services.BackgroundServices;
+using Grand.Domain.Data;
using Grand.Infrastructure;
-using Grand.Infrastructure.Data;
using Grand.Infrastructure.Plugins;
using Grand.Infrastructure.TypeSearchers;
using Microsoft.AspNetCore.Builder;
diff --git a/src/Web/Grand.Web/Endpoints/EndpointProvider.cs b/src/Web/Grand.Web/Endpoints/EndpointProvider.cs
index 0cc355ae9..54f23aafe 100644
--- a/src/Web/Grand.Web/Endpoints/EndpointProvider.cs
+++ b/src/Web/Grand.Web/Endpoints/EndpointProvider.cs
@@ -1,5 +1,5 @@
-using Grand.Infrastructure.Configuration;
-using Grand.Infrastructure.Data;
+using Grand.Domain.Data;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Endpoints;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
diff --git a/src/Web/Grand.Web/Endpoints/SlugEndpointProvider.cs b/src/Web/Grand.Web/Endpoints/SlugEndpointProvider.cs
index b55de329a..cd0d830ca 100644
--- a/src/Web/Grand.Web/Endpoints/SlugEndpointProvider.cs
+++ b/src/Web/Grand.Web/Endpoints/SlugEndpointProvider.cs
@@ -1,7 +1,7 @@
-using Grand.Web.Common.Routing;
+using Grand.Domain.Data;
using Grand.Infrastructure.Configuration;
-using Grand.Infrastructure.Data;
using Grand.Infrastructure.Endpoints;
+using Grand.Web.Common.Routing;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
@@ -93,10 +93,8 @@ namespace Grand.Web.Endpoints
}
- public int Priority
- {
- get
- {
+ public int Priority {
+ get {
//it should be the last route
//we do not set it to -int.MaxValue so it could be overridden (if required)
return -1000000;