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.

Improvements/code (#585)

Krzysztof Pajak48640c3a80b1
diff --git a/src/Business/Grand.Business.Authentication/Services/TwoFactorAuthenticationService.cs b/src/Business/Grand.Business.Authentication/Services/TwoFactorAuthenticationService.cs
index d883a68b9..85b04ab6a 100644
--- a/src/Business/Grand.Business.Authentication/Services/TwoFactorAuthenticationService.cs
+++ b/src/Business/Grand.Business.Authentication/Services/TwoFactorAuthenticationService.cs
@@ -87,7 +87,7 @@ public class TwoFactorAuthenticationService : ITwoFactorAuthenticationService
return model;
}
- private string PrepareRandomCode()
+ private static string PrepareRandomCode()
{
var generator = new Random();
return generator.Next(0, 999999).ToString("D6");
diff --git a/src/Business/Grand.Business.Catalog/Services/ExportImport/BrandImportDataObject.cs b/src/Business/Grand.Business.Catalog/Services/ExportImport/BrandImportDataObject.cs
index 3c754ad48..b3198b193 100644
--- a/src/Business/Grand.Business.Catalog/Services/ExportImport/BrandImportDataObject.cs
+++ b/src/Business/Grand.Business.Catalog/Services/ExportImport/BrandImportDataObject.cs
@@ -81,7 +81,7 @@ public class BrandImportDataObject : IImportDataObject<BrandDto>
await _slugService.SaveSlug(brand, seName, "");
}
- private bool ValidBrand(Brand brand)
+ private static bool ValidBrand(Brand brand)
{
return !string.IsNullOrEmpty(brand.Name);
}
diff --git a/src/Business/Grand.Business.Catalog/Services/ExportImport/CategoryImportDataObject.cs b/src/Business/Grand.Business.Catalog/Services/ExportImport/CategoryImportDataObject.cs
index 8eae92e1e..8e49775ab 100644
--- a/src/Business/Grand.Business.Catalog/Services/ExportImport/CategoryImportDataObject.cs
+++ b/src/Business/Grand.Business.Catalog/Services/ExportImport/CategoryImportDataObject.cs
@@ -86,7 +86,7 @@ public class CategoryImportDataObject : IImportDataObject<CategoryDto>
await _slugService.SaveSlug(category, seName, "");
}
- private bool ValidCategory(Category category)
+ private static bool ValidCategory(Category category)
{
return !string.IsNullOrEmpty(category.Name);
}
diff --git a/src/Business/Grand.Business.Catalog/Services/ExportImport/CollectionImportDataObject.cs b/src/Business/Grand.Business.Catalog/Services/ExportImport/CollectionImportDataObject.cs
index 8591b4124..3ce18a156 100644
--- a/src/Business/Grand.Business.Catalog/Services/ExportImport/CollectionImportDataObject.cs
+++ b/src/Business/Grand.Business.Catalog/Services/ExportImport/CollectionImportDataObject.cs
@@ -83,7 +83,7 @@ public class CollectionImportDataObject : IImportDataObject<CollectionDto>
await _slugService.SaveSlug(collection, sename, "");
}
- private bool ValidCollection(Collection collection)
+ private static bool ValidCollection(Collection collection)
{
return !string.IsNullOrEmpty(collection.Name);
}
diff --git a/src/Business/Grand.Business.Catalog/Services/ExportImport/ProductImportDataObject.cs b/src/Business/Grand.Business.Catalog/Services/ExportImport/ProductImportDataObject.cs
index 0183a6e70..b02eb45c0 100644
--- a/src/Business/Grand.Business.Catalog/Services/ExportImport/ProductImportDataObject.cs
+++ b/src/Business/Grand.Business.Catalog/Services/ExportImport/ProductImportDataObject.cs
@@ -265,7 +265,7 @@ public class ProductImportDataObject : IImportDataObject<ProductDto>
}
}
- private bool ValidProduct(Product product)
+ private static bool ValidProduct(Product product)
{
return !string.IsNullOrEmpty(product.Name);
}
diff --git a/src/Business/Grand.Business.Catalog/Services/Products/ProductAttributeService.cs b/src/Business/Grand.Business.Catalog/Services/Products/ProductAttributeService.cs
index 49979cde4..74bc98650 100644
--- a/src/Business/Grand.Business.Catalog/Services/Products/ProductAttributeService.cs
+++ b/src/Business/Grand.Business.Catalog/Services/Products/ProductAttributeService.cs
@@ -258,10 +258,10 @@ public class ProductAttributeService : IProductAttributeService
ArgumentNullException.ThrowIfNull(productAttributeValue);
var p = await _productRepository.GetByIdAsync(productId);
- ArgumentNullException.ThrowIfNull(p, nameof(p));
+ ArgumentNullException.ThrowIfNull(p);
var pam = p.ProductAttributeMappings.FirstOrDefault(x => x.Id == productAttributeMappingId);
- ArgumentNullException.ThrowIfNull(pam, nameof(pam));
+ ArgumentNullException.ThrowIfNull(pam);
pam.ProductAttributeValues.Add(productAttributeValue);
await _productRepository.UpdateToSet(productId, x => x.ProductAttributeMappings, z => z.Id,
diff --git a/src/Business/Grand.Business.Catalog/Startup/StartupApplication.cs b/src/Business/Grand.Business.Catalog/Startup/StartupApplication.cs
index ad34e2d36..1c9b95f55 100644
--- a/src/Business/Grand.Business.Catalog/Startup/StartupApplication.cs
+++ b/src/Business/Grand.Business.Catalog/Startup/StartupApplication.cs
@@ -44,7 +44,7 @@ public class StartupApplication : IStartupApplication
public int Priority => 100;
public bool BeforeConfigure => false;
- private void RegisterCatalogService(IServiceCollection serviceCollection)
+ private static void RegisterCatalogService(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<IOutOfStockSubscriptionService, OutOfStockSubscriptionService>();
serviceCollection.AddScoped<ICategoryService, CategoryService>();
@@ -77,21 +77,21 @@ public class StartupApplication : IStartupApplication
serviceCollection.AddScoped<IMeasureService, MeasureService>();
}
- private void RegisterDiscountsService(IServiceCollection serviceCollection)
+ private static void RegisterDiscountsService(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<IDiscountService, DiscountService>();
serviceCollection.AddScoped<IDiscountValidationService, DiscountValidationService>();
serviceCollection.AddScoped<IDiscountProviderLoader, DiscountProviderLoader>();
}
- private void RegisterTaxService(IServiceCollection serviceCollection)
+ private static void RegisterTaxService(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<ITaxService, TaxService>();
serviceCollection.AddScoped<IVatService, VatService>();
serviceCollection.AddScoped<ITaxCategoryService, TaxCategoryService>();
}
- private void RegisterExportImport(IServiceCollection serviceCollection)
+ private static void RegisterExportImport(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<ISchemaProperty<Brand>, BrandSchemaProperty>();
serviceCollection.AddScoped<ISchemaProperty<Category>, CategorySchemaProperty>();
diff --git a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/PrepareOrderCodeCommandHandler.cs b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/PrepareOrderCodeCommandHandler.cs
index 25160a150..c515ff3c6 100644
--- a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/PrepareOrderCodeCommandHandler.cs
+++ b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/PrepareOrderCodeCommandHandler.cs
@@ -24,7 +24,7 @@ public class PrepareOrderCodeCommandHandler : IRequestHandler<PrepareOrderCodeCo
return await Task.FromResult(code);
}
- private string RandomString(int length)
+ private static string RandomString(int length)
{
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return new string(Enumerable.Repeat(chars, length)
diff --git a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/ValidateMinShoppingCartSubtotalAmountCommandHandler.cs b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/ValidateMinShoppingCartSubtotalAmountCommandHandler.cs
index 39d7d0f81..0432f53c6 100644
--- a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/ValidateMinShoppingCartSubtotalAmountCommandHandler.cs
+++ b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/ValidateMinShoppingCartSubtotalAmountCommandHandler.cs
@@ -38,7 +38,8 @@ public class
return false;
//min order amount sub-total validation
- if (!cart.Any() || !(_orderSettings.MinOrderSubtotalAmount > 0)) return true;
+ if (!(_orderSettings.MinOrderSubtotalAmount > 0)) return true;
+
//subtotal
var (_, _, subTotalWithoutDiscount, _, _) =
await _orderTotalCalculationService.GetShoppingCartSubTotal(cart, false);
diff --git a/src/Business/Grand.Business.Checkout/Services/Orders/OrderReportService.cs b/src/Business/Grand.Business.Checkout/Services/Orders/OrderReportService.cs
index 5753742c1..32e41653d 100644
--- a/src/Business/Grand.Business.Checkout/Services/Orders/OrderReportService.cs
+++ b/src/Business/Grand.Business.Checkout/Services/Orders/OrderReportService.cs
@@ -489,7 +489,8 @@ public class OrderReportService : IOrderReportService
group o by 1
into g
select new ReportPeriodOrder { Amount = g.Sum(x => x.OrderTotal / x.CurrencyRate), Count = g.Count() };
- var report = query.ToList()?.FirstOrDefault() ?? new ReportPeriodOrder();
+
+ var report = query.FirstOrDefault() ?? new ReportPeriodOrder();
report.Date = date;
return await Task.FromResult(report);
}
diff --git a/src/Business/Grand.Business.Checkout/Startup/StartupApplication.cs b/src/Business/Grand.Business.Checkout/Startup/StartupApplication.cs
index 7e6ee4a2c..10d1f067a 100644
--- a/src/Business/Grand.Business.Checkout/Startup/StartupApplication.cs
+++ b/src/Business/Grand.Business.Checkout/Startup/StartupApplication.cs
@@ -38,7 +38,7 @@ public class StartupApplication : IStartupApplication
public bool BeforeConfigure => false;
- private void RegisterOrdersService(IServiceCollection serviceCollection)
+ private static void RegisterOrdersService(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<ILoyaltyPointsService, LoyaltyPointsService>();
serviceCollection.AddScoped<IGiftVoucherService, GiftVoucherService>();
@@ -56,13 +56,13 @@ public class StartupApplication : IStartupApplication
serviceCollection.AddScoped<IOrderReportService, OrderReportService>();
}
- private void RegisterPaymentsService(IServiceCollection serviceCollection)
+ private static void RegisterPaymentsService(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<IPaymentService, PaymentService>();
serviceCollection.AddScoped<IPaymentTransactionService, PaymentTransactionService>();
}
- private void RegisterShippingService(IServiceCollection serviceCollection)
+ private static void RegisterShippingService(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<IShipmentService, ShipmentService>();
serviceCollection.AddScoped<IShippingService, ShippingService>();
@@ -72,7 +72,7 @@ public class StartupApplication : IStartupApplication
serviceCollection.AddScoped<IShippingMethodService, ShippingMethodService>();
}
- private void RegisterExportImport(IServiceCollection serviceCollection)
+ private static void RegisterExportImport(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<ISchemaProperty<Order>, OrderSchemaProperty>();
}
diff --git a/src/Business/Grand.Business.Common/Services/ExportImport/ExcelExportProvider.cs b/src/Business/Grand.Business.Common/Services/ExportImport/ExcelExportProvider.cs
index dfa27b1a5..ef152bb78 100644
--- a/src/Business/Grand.Business.Common/Services/ExportImport/ExcelExportProvider.cs
+++ b/src/Business/Grand.Business.Common/Services/ExportImport/ExcelExportProvider.cs
@@ -55,7 +55,7 @@ public class ExcelExportProvider : IExportProvider
/// </summary>
/// <param name="sheet"></param>
/// <param name="properties"></param>
- private void WriteCaption<T>(ISheet sheet, PropertyByName<T>[] properties)
+ private static void WriteCaption<T>(ISheet sheet, PropertyByName<T>[] properties)
{
var row = sheet.CreateRow(0);
foreach (var caption in properties)
@@ -69,7 +69,7 @@ public class ExcelExportProvider : IExportProvider
/// <param name="idrow">Row index</param>
/// <param name="properties"></param>
/// <param name="sheet"></param>
- private void WriteToXlsx<T>(PropertyByName<T>[] properties, ISheet sheet, T items, int idrow)
+ private static void WriteToXlsx<T>(PropertyByName<T>[] properties, ISheet sheet, T items, int idrow)
{
var row = sheet.CreateRow(idrow);
foreach (var prop in properties)
diff --git a/src/Business/Grand.Business.Common/Services/Security/EncryptionService.cs b/src/Business/Grand.Business.Common/Services/Security/EncryptionService.cs
index 5e4110cff..a961063f7 100644
--- a/src/Business/Grand.Business.Common/Services/Security/EncryptionService.cs
+++ b/src/Business/Grand.Business.Common/Services/Security/EncryptionService.cs
@@ -95,7 +95,7 @@ public class EncryptionService : IEncryptionService
#region Utilities
- private byte[] EncryptTextToMemory(string data, byte[] key, byte[] iv)
+ private static byte[] EncryptTextToMemory(string data, byte[] key, byte[] iv)
{
using var ms = new MemoryStream();
using (var cs = new CryptoStream(ms, TripleDES.Create().CreateEncryptor(key, iv), CryptoStreamMode.Write))
@@ -108,7 +108,7 @@ public class EncryptionService : IEncryptionService
return ms.ToArray();
}
- private string DecryptTextFromMemory(byte[] data, byte[] key, byte[] iv)
+ private static string DecryptTextFromMemory(byte[] data, byte[] key, byte[] iv)
{
using var ms = new MemoryStream(data);
using var cs = new CryptoStream(ms, TripleDES.Create().CreateDecryptor(key, iv), CryptoStreamMode.Read);
diff --git a/src/Business/Grand.Business.Common/Startup/StartupApplication.cs b/src/Business/Grand.Business.Common/Startup/StartupApplication.cs
index 824f9d488..6e9b9c91f 100644
--- a/src/Business/Grand.Business.Common/Startup/StartupApplication.cs
+++ b/src/Business/Grand.Business.Common/Startup/StartupApplication.cs
@@ -46,7 +46,7 @@ public class StartupApplication : IStartupApplication
public int Priority => 100;
public bool BeforeConfigure => false;
- private void RegisterCommonService(IServiceCollection serviceCollection)
+ private static void RegisterCommonService(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<IAddressAttributeParser, AddressAttributeParser>();
serviceCollection.AddScoped<IAddressAttributeService, AddressAttributeService>();
@@ -54,7 +54,7 @@ public class StartupApplication : IStartupApplication
serviceCollection.AddScoped<IPdfService, HtmlToPdfService>();
}
- private void RegisterDirectoryService(IServiceCollection serviceCollection)
+ private static void RegisterDirectoryService(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<IDateTimeService, DateTimeService>();
@@ -64,19 +64,19 @@ public class StartupApplication : IStartupApplication
serviceCollection.AddScoped<IGroupService, GroupService>();
}
- private void RegisterConfigurationService(IServiceCollection serviceCollection)
+ private static void RegisterConfigurationService(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<ISettingService, SettingService>();
}
- private void RegisterLocalizationService(IServiceCollection serviceCollection)
+ private static void RegisterLocalizationService(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<ITranslationService, TranslationService>();
serviceCollection.AddScoped<ILanguageService, LanguageService>();
serviceCollection.AddScoped<IPluginTranslateResource, PluginTranslateResource>();
}
- private void RegisterSecurityService(IServiceCollection serviceCollection)
+ private static void RegisterSecurityService(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<IPermissionService, PermissionService>();
serviceCollection.AddScoped<IAclService, AclService>();
@@ -84,19 +84,19 @@ public class StartupApplication : IStartupApplication
serviceCollection.AddScoped<IPermissionProvider, PermissionProvider>();
}
- private void RegisterSeoService(IServiceCollection serviceCollection)
+ private static void RegisterSeoService(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<ISlugService, SlugService>();
serviceCollection.AddScoped<ISeNameService, SeNameService>();
}
- private void RegisterStoresService(IServiceCollection serviceCollection)
+ private static void RegisterStoresService(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<IStoreService, StoreService>();
}
- private void RegisterExportImportService(IServiceCollection serviceCollection)
+ private static void RegisterExportImportService(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<ISchemaProperty<CountryStatesDto>, CountrySchemaProperty>();
diff --git a/src/Business/Grand.Business.Common/Utilities/PowerExcelMapper.cs b/src/Business/Grand.Business.Common/Utilities/PowerExcelMapper.cs
index 9c6a1f722..d1ca00146 100644
--- a/src/Business/Grand.Business.Common/Utilities/PowerExcelMapper.cs
+++ b/src/Business/Grand.Business.Common/Utilities/PowerExcelMapper.cs
@@ -241,7 +241,7 @@ public class PowerExcelMapper : ExcelMapper
return t.GetTypeInfo().IsValueType ? Activator.CreateInstance(t) : null;
}
- private void TriggerOrThrowParsingError(ExcelMapperConvertException excelMapperConvertException)
+ private static void TriggerOrThrowParsingError(ExcelMapperConvertException excelMapperConvertException)
{
var parsingError = new ParsingErrorEventArgs(excelMapperConvertException);
//ErrorParsingCell?.Invoke(this, parsingError);
diff --git a/src/Business/Grand.Business.Customers/Queries/Handlers/GetCustomerQueryHandler.cs b/src/Business/Grand.Business.Customers/Queries/Handlers/GetCustomerQueryHandler.cs
index 26fc6000a..6b00a282b 100644
--- a/src/Business/Grand.Business.Customers/Queries/Handlers/GetCustomerQueryHandler.cs
+++ b/src/Business/Grand.Business.Customers/Queries/Handlers/GetCustomerQueryHandler.cs
@@ -90,7 +90,7 @@ public class GetCustomerQueryHandler : IRequestHandler<GetCustomerQuery, IQuerya
return Task.FromResult(query);
}
- private string GetName(Expression<Func<Customer, object>> exp)
+ private static string GetName(Expression<Func<Customer, object>> exp)
{
if (exp.Body is MemberExpression body) return body.Member.Name;
var expBody = (UnaryExpression)exp.Body;
@@ -98,7 +98,7 @@ public class GetCustomerQueryHandler : IRequestHandler<GetCustomerQuery, IQuerya
return body?.Member.Name;
}
- private IOrderedQueryable<T> OrderingHelper<T>(IQueryable<T> source, string propertyName)
+ private static IOrderedQueryable<T> OrderingHelper<T>(IQueryable<T> source, string propertyName)
{
var param = Expression.Parameter(typeof(T), propertyName);
var property = Expression.PropertyOrField(param, propertyName);
diff --git a/src/Business/Grand.Business.Customers/Startup/StartupApplication.cs b/src/Business/Grand.Business.Customers/Startup/StartupApplication.cs
index 9179141ca..954aee0d8 100644
--- a/src/Business/Grand.Business.Customers/Startup/StartupApplication.cs
+++ b/src/Business/Grand.Business.Customers/Startup/StartupApplication.cs
@@ -27,7 +27,7 @@ public class StartupApplication : IStartupApplication
public int Priority => 100;
public bool BeforeConfigure => false;
- private void RegisterCustomerService(IServiceCollection serviceCollection)
+ private static void RegisterCustomerService(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<IVendorService, VendorService>();
serviceCollection.AddScoped<ICustomerAttributeParser, CustomerAttributeParser>();
diff --git a/src/Business/Grand.Business.Marketing/Startup/StartupApplication.cs b/src/Business/Grand.Business.Marketing/Startup/StartupApplication.cs
index 4caa13fe5..c04354b1b 100644
--- a/src/Business/Grand.Business.Marketing/Startup/StartupApplication.cs
+++ b/src/Business/Grand.Business.Marketing/Startup/StartupApplication.cs
@@ -37,14 +37,14 @@ public class StartupApplication : IStartupApplication
public int Priority => 100;
public bool BeforeConfigure => false;
- private void RegisterCustomer(IServiceCollection serviceCollection)
+ private static void RegisterCustomer(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<ICustomerTagService, CustomerTagService>();
serviceCollection.AddScoped<ICustomerProductService, CustomerProductService>();
serviceCollection.AddScoped<ICustomerCoordinatesService, CustomerCoordinatesService>();
}
- private void RegisterCommon(IServiceCollection serviceCollection)
+ private static void RegisterCommon(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<IContactAttributeParser, ContactAttributeParser>();
serviceCollection.AddScoped<IContactAttributeService, ContactAttributeService>();
@@ -56,7 +56,7 @@ public class StartupApplication : IStartupApplication
serviceCollection.AddHttpClient<IPushNotificationsService, PushNotificationsService>();
}
- private void RegisterCoursesService(IServiceCollection serviceCollection)
+ private static void RegisterCoursesService(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<ICourseActionService, CourseActionService>();
serviceCollection.AddScoped<ICourseLessonService, CourseLessonService>();
@@ -65,7 +65,7 @@ public class StartupApplication : IStartupApplication
serviceCollection.AddScoped<ICourseSubjectService, CourseSubjectService>();
}
- private void RegisterDocumentsService(IServiceCollection serviceCollection)
+ private static void RegisterDocumentsService(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<IDocumentTypeService, DocumentTypeService>();
serviceCollection.AddScoped<IDocumentService, DocumentService>();
diff --git a/src/Business/Grand.Business.Messages/Services/MessageProviderService.cs b/src/Business/Grand.Business.Messages/Services/MessageProviderService.cs
index 9c1166148..b72605454 100644
--- a/src/Business/Grand.Business.Messages/Services/MessageProviderService.cs
+++ b/src/Business/Grand.Business.Messages/Services/MessageProviderService.cs
@@ -871,7 +871,7 @@ public class MessageProviderService : IMessageProviderService
var toEmail = emailAccount.Email;
var toName = "";
- if (!string.IsNullOrEmpty(product?.VendorId))
+ if (!string.IsNullOrEmpty(product.VendorId))
{
var vendor = await _mediator.Send(new GetVendorByIdQuery { Id = product.VendorId });
if (vendor != null)
@@ -1679,7 +1679,7 @@ public class MessageProviderService : IMessageProviderService
subject: subject,
replyToEmailAddress: senderEmail,
replyToName: senderName,
- reference: Reference.Vendor, objectId: vendor?.Id);
+ reference: Reference.Vendor, objectId: vendor.Id);
}
#region Auction notification
@@ -1762,7 +1762,7 @@ public class MessageProviderService : IMessageProviderService
await SendNotification(messageTemplate, emailAccount,
languageId, liquidObject2,
toEmail, toName,
- reference: Reference.Customer, objectId: customer?.Id);
+ reference: Reference.Customer, objectId: customer.Id);
}
return 0;
@@ -1905,7 +1905,7 @@ public class MessageProviderService : IMessageProviderService
return await SendNotification(messageTemplate, emailAccount,
languageId, liquidObject,
toEmail, toName,
- reference: Reference.Customer, objectId: customer?.Id);
+ reference: Reference.Customer, objectId: customer.Id);
}
#endregion
diff --git a/src/Business/Grand.Business.Storage/Services/AmazonPictureService.cs b/src/Business/Grand.Business.Storage/Services/AmazonPictureService.cs
index 64b7ba631..4c53dcd7d 100644
--- a/src/Business/Grand.Business.Storage/Services/AmazonPictureService.cs
+++ b/src/Business/Grand.Business.Storage/Services/AmazonPictureService.cs
@@ -109,7 +109,7 @@ public class AmazonPictureService : PictureService
/// </summary>
/// <param name="actualResponse">Actual Response</param>
/// <param name="expectedHttpStatusCode">Expected Status Code</param>
- private void EnsureValidResponse(AmazonWebServiceResponse actualResponse, HttpStatusCode expectedHttpStatusCode)
+ private static void EnsureValidResponse(AmazonWebServiceResponse actualResponse, HttpStatusCode expectedHttpStatusCode)
{
if (actualResponse.HttpStatusCode != expectedHttpStatusCode)
throw new Exception("Http Status Codes Aren't Consistent");
diff --git a/src/Business/Grand.Business.Storage/Services/PictureService.cs b/src/Business/Grand.Business.Storage/Services/PictureService.cs
index 210207adf..57253c867 100644
--- a/src/Business/Grand.Business.Storage/Services/PictureService.cs
+++ b/src/Business/Grand.Business.Storage/Services/PictureService.cs
@@ -73,7 +73,7 @@ public class PictureService : IPictureService
/// </summary>
/// <param name="mimeType">Mime type</param>
/// <returns>File extension</returns>
- private string GetFileExtensionFromMimeType(string mimeType)
+ private static string GetFileExtensionFromMimeType(string mimeType)
{
if (mimeType == null)
return null;
@@ -804,7 +804,7 @@ public class PictureService : IPictureService
}
- private SKEncodedImageFormat EncodedImageFormat(string mimetype)
+ private static SKEncodedImageFormat EncodedImageFormat(string mimetype)
{
const SKEncodedImageFormat defaultFormat = SKEncodedImageFormat.Jpeg;
if (string.IsNullOrEmpty(mimetype))
diff --git a/src/Core/Grand.Data/LiteDb/LiteDBContext.cs b/src/Core/Grand.Data/LiteDb/LiteDBContext.cs
index 7635e91b5..25f82e23d 100644
--- a/src/Core/Grand.Data/LiteDb/LiteDBContext.cs
+++ b/src/Core/Grand.Data/LiteDb/LiteDBContext.cs
@@ -40,7 +40,7 @@ public class LiteDBContext : IDatabaseContext
ArgumentNullException.ThrowIfNullOrEmpty(indexName);
try
{
- foreach (var (selector, value, fieldName) in orderBuilder?.Fields)
+ foreach (var (selector, value, fieldName) in orderBuilder.Fields)
{
var col = _database.GetCollection<T>();
if (selector != null)
diff --git a/src/Core/Grand.Data/LiteDb/LiteDBRepository.cs b/src/Core/Grand.Data/LiteDb/LiteDBRepository.cs
index 665338c9a..79d5c4b55 100644
--- a/src/Core/Grand.Data/LiteDb/LiteDBRepository.cs
+++ b/src/Core/Grand.Data/LiteDb/LiteDBRepository.cs
@@ -362,7 +362,7 @@ public class LiteDBRepository<T> : IRepository<T> where T : BaseEntity
var bsonValue = BsonMapper.Global.Serialize(value);
var oldbsonValue = BsonMapper.Global.Serialize(elemFieldMatch);
var list = entity[fieldName].AsArray.ToList();
- if (list != null && list.Any())
+ if (list.Any())
{
list.Add(bsonValue);
list.Remove(oldbsonValue);
@@ -416,7 +416,7 @@ public class LiteDBRepository<T> : IRepository<T> where T : BaseEntity
var bsonValue = BsonMapper.Global.Serialize(elemMatch);
var list = entity[fieldName].AsArray.ToList();
var documents = list.Where(x => x[elementfieldName] == new BsonValue(elemMatch)).ToList();
- if (documents != null && documents.Any())
+ if (documents.Any())
{
foreach (var document in documents) list.Remove(document);
entity[fieldName] = new BsonArray(list);
@@ -492,7 +492,7 @@ public class LiteDBRepository<T> : IRepository<T> where T : BaseEntity
if (entity != null && entity[fieldName].IsArray)
{
var list = entity[fieldName].AsArray.ToList();
- if (list != null && list.Any())
+ if (list.Any())
{
list.Remove(new BsonValue(element));
entity[fieldName] = new BsonArray(list);
@@ -575,13 +575,13 @@ public class LiteDBRepository<T> : IRepository<T> where T : BaseEntity
#region Helpers
- private string GetName(LambdaExpression lambdaexpression)
+ private static string GetName(LambdaExpression lambdaexpression)
{
var expression = (MemberExpression)lambdaexpression.Body;
return expression.Member.Name;
}
- private string GetName<TSource, TField>(Expression<Func<TSource, TField>> Field)
+ private static string GetName<TSource, TField>(Expression<Func<TSource, TField>> Field)
{
if (Equals(Field, null)) throw new NullReferenceException("Field is required");
diff --git a/src/Core/Grand.Data/LiteDb/LiteDBStoreFilesContext.cs b/src/Core/Grand.Data/LiteDb/LiteDBStoreFilesContext.cs
index b5d52ecd5..7771c2dc7 100644
--- a/src/Core/Grand.Data/LiteDb/LiteDBStoreFilesContext.cs
+++ b/src/Core/Grand.Data/LiteDb/LiteDBStoreFilesContext.cs
@@ -1,6 +1,5 @@
using Grand.Domain;
using LiteDB;
-using System.Xml.Linq;
namespace Grand.Data.LiteDb;
@@ -23,8 +22,8 @@ public class LiteDBStoreFilesContext : IStoreFilesContext
using (var stream = file.OpenRead())
using (MemoryStream mstream = new())
{
- stream.CopyTo(mstream);
- return await Task.FromResult(mstream.ToArray());
+ await stream.CopyToAsync(mstream);
+ return mstream.ToArray();
}
}
diff --git a/src/Core/Grand.Data/Mongo/MongoRepository.cs b/src/Core/Grand.Data/Mongo/MongoRepository.cs
index 8e30468b6..12a35ffa5 100644
--- a/src/Core/Grand.Data/Mongo/MongoRepository.cs
+++ b/src/Core/Grand.Data/Mongo/MongoRepository.cs
@@ -121,7 +121,7 @@ public class MongoRepository<T> : IRepository<T> where T : BaseEntity
public virtual T Update(T entity)
{
entity.UpdatedOnUtc = _auditInfoProvider.GetCurrentDateTime();
- entity.UpdatedBy = _auditInfoProvider?.GetCurrentUser();
+ entity.UpdatedBy = _auditInfoProvider.GetCurrentUser();
Collection.ReplaceOne(x => x.Id == entity.Id, entity, new ReplaceOptions { IsUpsert = false });
return entity;
}
diff --git a/src/Modules/Grand.Module.Api/Attributes/EnableQueryAttribute.cs b/src/Modules/Grand.Module.Api/Attributes/EnableQueryAttribute.cs
index b77a19ca6..f2d108cc5 100644
--- a/src/Modules/Grand.Module.Api/Attributes/EnableQueryAttribute.cs
+++ b/src/Modules/Grand.Module.Api/Attributes/EnableQueryAttribute.cs
@@ -21,7 +21,7 @@ public class EnableQueryAttribute : ActionFilterAttribute
}
}
- private IQueryable ApplyQueryOptions(IQueryable queryable, IQueryCollection query, HttpResponse response)
+ private static IQueryable ApplyQueryOptions(IQueryable queryable, IQueryCollection query, HttpResponse response)
{
if (query.TryGetValue("$filter", out var filter))
queryable = queryable.Where(filter.ToString());
diff --git a/src/Modules/Grand.Module.Api/Infrastructure/OpenApiStartup.cs b/src/Modules/Grand.Module.Api/Infrastructure/OpenApiStartup.cs
index f235ed519..e7606dfed 100644
--- a/src/Modules/Grand.Module.Api/Infrastructure/OpenApiStartup.cs
+++ b/src/Modules/Grand.Module.Api/Infrastructure/OpenApiStartup.cs
@@ -65,7 +65,7 @@ public class OpenApiStartup : IStartupApplication
public int Priority => 505;
public bool BeforeConfigure => false;
- private void ConfigureBackendApi(IServiceCollection services)
+ private static void ConfigureBackendApi(IServiceCollection services)
{
services.AddOpenApi(ApiConstants.ApiGroupNameV1, options =>
{
@@ -78,7 +78,7 @@ public class OpenApiStartup : IStartupApplication
});
}
- private void ConfigureFrontendApi(IServiceCollection services)
+ private static void ConfigureFrontendApi(IServiceCollection services)
{
services.AddOpenApi(ApiConstants.ApiGroupNameV2, options =>
{
diff --git a/src/Modules/Grand.Module.Installer/Services/InstallDataBrands.cs b/src/Modules/Grand.Module.Installer/Services/InstallDataBrands.cs
index ee2c67cba..506a045fe 100644
--- a/src/Modules/Grand.Module.Installer/Services/InstallDataBrands.cs
+++ b/src/Modules/Grand.Module.Installer/Services/InstallDataBrands.cs
@@ -27,7 +27,7 @@ public partial class InstallationService
DisplayOrder = 1
};
brandXiaomi.PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "brand_xiaomi.jpg"), "image/pjpeg",
+ await File.ReadAllBytesAsync(sampleImagesPath + "brand_xiaomi.jpg"), "image/pjpeg",
"Xiaomi", "", "", false, Reference.Brand, brandXiaomi.Id)).Id;
await _brandRepository.InsertAsync(brandXiaomi);
allbrands.Add(brandXiaomi);
@@ -43,7 +43,7 @@ public partial class InstallationService
DisplayOrder = 5
};
brandDell.PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "brand_dell.jpg"), "image/pjpeg",
+ await File.ReadAllBytesAsync(sampleImagesPath + "brand_dell.jpg"), "image/pjpeg",
("Dell"), "", "", false, Reference.Brand, brandDell.Id)).Id;
await _brandRepository.InsertAsync(brandDell);
@@ -60,7 +60,7 @@ public partial class InstallationService
DisplayOrder = 5
};
brandAdidas.PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "brand_adidas.jpg"), "image/pjpeg",
+ await File.ReadAllBytesAsync(sampleImagesPath + "brand_adidas.jpg"), "image/pjpeg",
("Adidas"), "", "", false, Reference.Brand, brandAdidas.Id)).Id;
await _brandRepository.InsertAsync(brandAdidas);
allbrands.Add(brandAdidas);
diff --git a/src/Modules/Grand.Module.Installer/Services/InstallDataCategories.cs b/src/Modules/Grand.Module.Installer/Services/InstallDataCategories.cs
index a4c93fb6a..fed2a82f9 100644
--- a/src/Modules/Grand.Module.Installer/Services/InstallDataCategories.cs
+++ b/src/Modules/Grand.Module.Installer/Services/InstallDataCategories.cs
@@ -35,7 +35,7 @@ public partial class InstallationService
DisplayOrder = 100
};
categoryComputers.PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "category_computers.jpeg"), "image/jpeg",
+ await File.ReadAllBytesAsync(sampleImagesPath + "category_computers.jpeg"), "image/jpeg",
"Computers", reference: Reference.Category,
objectId: categoryComputers.Id)).Id;
allCategories.Add(categoryComputers);
@@ -52,7 +52,7 @@ public partial class InstallationService
DisplayOrder = categoryComputers.DisplayOrder + 1
};
categoryTablets.PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "category_tablets.jpg"), "image/jpeg",
+ await File.ReadAllBytesAsync(sampleImagesPath + "category_tablets.jpg"), "image/jpeg",
"Tablets", reference: Reference.Category,
objectId: categoryTablets.Id))
.Id;
@@ -70,7 +70,7 @@ public partial class InstallationService
DisplayOrder = categoryComputers.DisplayOrder + 2
};
categoryNotebooks.PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "category_notebooks.jpg"), "image/jpeg",
+ await File.ReadAllBytesAsync(sampleImagesPath + "category_notebooks.jpg"), "image/jpeg",
"Notebooks", reference: Reference.Category,
objectId: categoryNotebooks.Id)).Id;
allCategories.Add(categoryNotebooks);
@@ -87,7 +87,7 @@ public partial class InstallationService
DisplayOrder = categoryComputers.DisplayOrder + 3
};
categorySmartwatches.PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "category_smartwatches.jpg"), "image/jpeg",
+ await File.ReadAllBytesAsync(sampleImagesPath + "category_smartwatches.jpg"), "image/jpeg",
"Smartwatches", reference: Reference.Category,
objectId: categorySmartwatches.Id)).Id;
allCategories.Add(categorySmartwatches);
@@ -105,7 +105,7 @@ public partial class InstallationService
DisplayOrder = 200
};
categoryElectronics.PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "category_electronics.jpeg"), "image/jpeg",
+ await File.ReadAllBytesAsync(sampleImagesPath + "category_electronics.jpeg"), "image/jpeg",
"Electronics", reference: Reference.Category,
objectId: categoryElectronics.Id)).Id;
allCategories.Add(categoryElectronics);
@@ -122,7 +122,7 @@ public partial class InstallationService
DisplayOrder = categoryElectronics.DisplayOrder + 1
};
categoryDisplay.PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "category_display.jpeg"), "image/jpeg",
+ await File.ReadAllBytesAsync(sampleImagesPath + "category_display.jpeg"), "image/jpeg",
"Display", reference: Reference.Category,
objectId: categoryDisplay.Id))
.Id;
@@ -140,7 +140,7 @@ public partial class InstallationService
DisplayOrder = categoryElectronics.DisplayOrder + 2
};
categorySmartphones.PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "category_smartphones.jpeg"), "image/jpeg",
+ await File.ReadAllBytesAsync(sampleImagesPath + "category_smartphones.jpeg"), "image/jpeg",
"Smartphones", reference: Reference.Category,
objectId: categorySmartphones.Id)).Id;
allCategories.Add(categorySmartphones);
@@ -158,7 +158,7 @@ public partial class InstallationService
DisplayOrder = categoryElectronics.DisplayOrder + 3
};
categoryOthers.PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "category_accessories.jpg"), "image/jpeg",
+ await File.ReadAllBytesAsync(sampleImagesPath + "category_accessories.jpg"), "image/jpeg",
"SmAccessoriesartphones", reference: Reference.Category,
objectId: categoryOthers.Id)).Id;
@@ -177,7 +177,7 @@ public partial class InstallationService
DisplayOrder = 300
};
categorySport.PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "category_sport.jpeg"), "image/jpeg",
+ await File.ReadAllBytesAsync(sampleImagesPath + "category_sport.jpeg"), "image/jpeg",
("Sport"), reference: Reference.Category, objectId: categorySport.Id)).Id;
allCategories.Add(categorySport);
@@ -193,7 +193,7 @@ public partial class InstallationService
DisplayOrder = categorySport.DisplayOrder + 1
};
categoryShoes.PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "category_shoes.jpeg"), "image/jpeg",
+ await File.ReadAllBytesAsync(sampleImagesPath + "category_shoes.jpeg"), "image/jpeg",
"Shoes", reference: Reference.Category, objectId: categoryShoes.Id)).Id;
allCategories.Add(categoryShoes);
@@ -209,7 +209,7 @@ public partial class InstallationService
DisplayOrder = categorySport.DisplayOrder + 2
};
categoryApparel.PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "category_sport.jpeg"), "image/jpeg",
+ await File.ReadAllBytesAsync(sampleImagesPath + "category_sport.jpeg"), "image/jpeg",
"Apparel", reference: Reference.Category,
objectId: categoryApparel.Id))
.Id;
@@ -228,7 +228,7 @@ public partial class InstallationService
DisplayOrder = categorySport.DisplayOrder + 3
};
categoryBalls.PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "category_balls.jpeg"), "image/jpeg",
+ await File.ReadAllBytesAsync(sampleImagesPath + "category_balls.jpeg"), "image/jpeg",
("Balls"), reference: Reference.Category, objectId: categoryBalls.Id)).Id;
allCategories.Add(categoryBalls);
@@ -245,7 +245,7 @@ public partial class InstallationService
DisplayOrder = 400
};
categoryDigitalDownloads.PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "category_digital_downloads.jpeg"), "image/jpeg",
+ await File.ReadAllBytesAsync(sampleImagesPath + "category_digital_downloads.jpeg"), "image/jpeg",
("Digital downloads"), reference: Reference.Category,
objectId: categoryDigitalDownloads.Id)).Id;
allCategories.Add(categoryDigitalDownloads);
@@ -267,7 +267,7 @@ public partial class InstallationService
FlagStyle = "bg-success"
};
categoryLego.PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "category_lego.jpeg"), "image/jpeg",
+ await File.ReadAllBytesAsync(sampleImagesPath + "category_lego.jpeg"), "image/jpeg",
(categoryLego.Name), reference: Reference.Category,
objectId: categoryLego.Id)).Id;
allCategories.Add(categoryLego);
@@ -284,7 +284,7 @@ public partial class InstallationService
DisplayOrder = 600
};
categoryGiftVouchers.PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "category_gift_cards.jpeg"), "image/jpeg",
+ await File.ReadAllBytesAsync(sampleImagesPath + "category_gift_cards.jpeg"), "image/jpeg",
(categoryGiftVouchers.Name), reference: Reference.Category,
objectId: categoryGiftVouchers.Id)).Id;
allCategories.Add(categoryGiftVouchers);
diff --git a/src/Modules/Grand.Module.Installer/Services/InstallDataProducts.cs b/src/Modules/Grand.Module.Installer/Services/InstallDataProducts.cs
index 573c80b7a..fac437266 100644
--- a/src/Modules/Grand.Module.Installer/Services/InstallDataProducts.cs
+++ b/src/Modules/Grand.Module.Installer/Services/InstallDataProducts.cs
@@ -190,10 +190,10 @@ public partial class InstallationService
};
allProducts.Add(productBuildComputer);
- var picture1 = await _pictureRepository.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_desktop_1.png"),
+ var picture1 = await _pictureRepository.InsertPicture(await File.ReadAllBytesAsync(sampleImagesPath + "product_desktop_1.png"),
"image/png", SeoExtensions.GenerateSlug(productBuildComputer.Name, true, false, false), reference: Reference.Product,
objectId: productBuildComputer.Id);
- var picture2 = await _pictureRepository.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_desktop_2.png"),
+ var picture2 = await _pictureRepository.InsertPicture(await File.ReadAllBytesAsync(sampleImagesPath + "product_desktop_2.png"),
"image/png", SeoExtensions.GenerateSlug(productBuildComputer.Name, true, false, false), reference: Reference.Product,
objectId: productBuildComputer.Id);
@@ -250,7 +250,7 @@ public partial class InstallationService
allProducts.Add(productSonyPS5Pad);
productSonyPS5Pad.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_sony_ps5_pad_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_sony_ps5_pad_1.png"), "image/png",
SeoExtensions.GenerateSlug(productSonyPS5Pad.Name), reference: Reference.Product,
objectId: productSonyPS5Pad.Id)).Id,
DisplayOrder = 1,
@@ -258,7 +258,7 @@ public partial class InstallationService
});
productSonyPS5Pad.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_sony_ps5_pad_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_sony_ps5_pad_2.png"), "image/png",
SeoExtensions.GenerateSlug(productSonyPS5Pad.Name), reference: Reference.Product,
objectId: productSonyPS5Pad.Id)).Id,
DisplayOrder = 1
@@ -302,7 +302,7 @@ public partial class InstallationService
allProducts.Add(productLenovoIdeaPadDual);
productLenovoIdeaPadDual.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_lenovo_ideapad_dual_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_lenovo_ideapad_dual_1.png"), "image/png",
SeoExtensions.GenerateSlug(productLenovoIdeaPadDual.Name), reference: Reference.Product,
objectId: productLenovoIdeaPadDual.Id)).Id,
DisplayOrder = 1,
@@ -310,7 +310,7 @@ public partial class InstallationService
});
productLenovoIdeaPadDual.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_lenovo_ideapad_dual_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_lenovo_ideapad_dual_2.png"), "image/png",
SeoExtensions.GenerateSlug(productLenovoIdeaPadDual.Name), reference: Reference.Product,
objectId: productLenovoIdeaPadDual.Id)).Id,
DisplayOrder = 2
@@ -394,7 +394,7 @@ public partial class InstallationService
allProducts.Add(productMiNotebook);
productMiNotebook.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_mi_notebook_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_mi_notebook_1.png"), "image/png",
SeoExtensions.GenerateSlug(productMiNotebook.Name), reference: Reference.Product,
objectId: productMiNotebook.Id)).Id,
DisplayOrder = 1,
@@ -402,7 +402,7 @@ public partial class InstallationService
});
productMiNotebook.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_mi_notebook_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_mi_notebook_2.png"), "image/png",
SeoExtensions.GenerateSlug(productMiNotebook.Name), reference: Reference.Product,
objectId: productMiNotebook.Id)).Id,
DisplayOrder = 2
@@ -489,7 +489,7 @@ public partial class InstallationService
allProducts.Add(productLenovoLegionY740);
productLenovoLegionY740.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_lenovo_legion_y740_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_lenovo_legion_y740_1.png"), "image/png",
SeoExtensions.GenerateSlug(productLenovoLegionY740.Name), reference: Reference.Product,
objectId: productLenovoLegionY740.Id)).Id,
DisplayOrder = 1,
@@ -497,7 +497,7 @@ public partial class InstallationService
});
productLenovoLegionY740.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_lenovo_legion_y740_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_lenovo_legion_y740_2.png"), "image/png",
SeoExtensions.GenerateSlug(productLenovoLegionY740.Name), reference: Reference.Product,
objectId: productLenovoLegionY740.Id)).Id,
DisplayOrder = 1
@@ -584,7 +584,7 @@ public partial class InstallationService
allProducts.Add(productPs5Camera);
productPs5Camera.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_ps5_camera_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_ps5_camera_1.png"), "image/png",
SeoExtensions.GenerateSlug(productPs5Camera.Name), reference: Reference.Product,
objectId: productPs5Camera.Id)).Id,
DisplayOrder = 1,
@@ -592,7 +592,7 @@ public partial class InstallationService
});
productPs5Camera.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_ps5_camera_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_ps5_camera_2.png"), "image/png",
SeoExtensions.GenerateSlug(productPs5Camera.Name), reference: Reference.Product,
objectId: productPs5Camera.Id)).Id,
DisplayOrder = 2
@@ -678,7 +678,7 @@ public partial class InstallationService
allProducts.Add(productAcerNitro);
productAcerNitro.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_acer_nitro_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_acer_nitro_1.png"), "image/png",
SeoExtensions.GenerateSlug(productAcerNitro.Name), reference: Reference.Product,
objectId: productAcerNitro.Id)).Id,
DisplayOrder = 1,
@@ -686,7 +686,7 @@ public partial class InstallationService
});
productAcerNitro.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_acer_nitro_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_acer_nitro_2.png"), "image/png",
SeoExtensions.GenerateSlug(productAcerNitro.Name), reference: Reference.Product,
objectId: productAcerNitro.Id)).Id,
DisplayOrder = 2
@@ -774,7 +774,7 @@ public partial class InstallationService
allProducts.Add(productDellG5);
productDellG5.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_dell_g5_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_dell_g5_1.png"), "image/png",
SeoExtensions.GenerateSlug(productDellG5.Name), reference: Reference.Product,
objectId: productDellG5.Id)).Id,
DisplayOrder = 1,
@@ -782,7 +782,7 @@ public partial class InstallationService
});
productDellG5.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_dell_g5_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_dell_g5_2.png"), "image/png",
SeoExtensions.GenerateSlug(productDellG5.Name), reference: Reference.Product,
objectId: productDellG5.Id)).Id,
DisplayOrder = 1
@@ -850,7 +850,7 @@ public partial class InstallationService
allProducts.Add(productDellXPS);
productDellXPS.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_dell_xps_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_dell_xps_1.png"), "image/png",
SeoExtensions.GenerateSlug(productDellXPS.Name), reference: Reference.Product,
objectId: productDellXPS.Id)).Id,
DisplayOrder = 1,
@@ -858,7 +858,7 @@ public partial class InstallationService
});
productDellXPS.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_dell_xps_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_dell_xps_2.png"), "image/png",
SeoExtensions.GenerateSlug(productDellXPS.Name), reference: Reference.Product,
objectId: productDellXPS.Id)).Id,
DisplayOrder = 2
@@ -906,7 +906,7 @@ public partial class InstallationService
allProducts.Add(productLenovoYogaDuet);
productLenovoYogaDuet.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_lenovo_yoga_duet_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_lenovo_yoga_duet_1.png"), "image/png",
SeoExtensions.GenerateSlug(productLenovoYogaDuet.Name), reference: Reference.Product,
objectId: productLenovoYogaDuet.Id)).Id,
DisplayOrder = 1,
@@ -914,7 +914,7 @@ public partial class InstallationService
});
productLenovoYogaDuet.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_lenovo_yoga_duet_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_lenovo_yoga_duet_2.png"), "image/png",
SeoExtensions.GenerateSlug(productLenovoYogaDuet.Name), reference: Reference.Product,
objectId: productLenovoYogaDuet.Id)).Id,
DisplayOrder = 1
@@ -958,7 +958,7 @@ public partial class InstallationService
allProducts.Add(productLenovoSmartTab);
productLenovoSmartTab.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_lenovo_smart_tab_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_lenovo_smart_tab_1.png"), "image/png",
SeoExtensions.GenerateSlug(productLenovoSmartTab.Name), reference: Reference.Product,
objectId: productLenovoSmartTab.Id)).Id,
DisplayOrder = 1,
@@ -966,7 +966,7 @@ public partial class InstallationService
});
productLenovoSmartTab.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_lenovo_smart_tab_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_lenovo_smart_tab_2.png"), "image/png",
SeoExtensions.GenerateSlug(productLenovoSmartTab.Name), reference: Reference.Product,
objectId: productLenovoSmartTab.Id)).Id,
DisplayOrder = 1
@@ -1010,7 +1010,7 @@ public partial class InstallationService
allProducts.Add(productAsusMixedReality);
productAsusMixedReality.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_asus_mixed_reality_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_asus_mixed_reality_1.png"), "image/png",
SeoExtensions.GenerateSlug(productAsusMixedReality.Name), reference: Reference.Product,
objectId: productAsusMixedReality.Id)).Id,
DisplayOrder = 1,
@@ -1018,7 +1018,7 @@ public partial class InstallationService
});
productAsusMixedReality.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_asus_mixed_reality_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_asus_mixed_reality_2.png"), "image/png",
SeoExtensions.GenerateSlug(productAsusMixedReality.Name), reference: Reference.Product,
objectId: productAsusMixedReality.Id)).Id,
DisplayOrder = 1
@@ -1066,7 +1066,7 @@ public partial class InstallationService
allProducts.Add(productAcerProjector);
productAcerProjector.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_acer_projector_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_acer_projector_1.png"), "image/png",
SeoExtensions.GenerateSlug(productAcerProjector.Name), reference: Reference.Product,
objectId: productAcerProjector.Id)).Id,
DisplayOrder = 1,
@@ -1074,7 +1074,7 @@ public partial class InstallationService
});
productAcerProjector.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_acer_projector_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_acer_projector_2.png"), "image/png",
SeoExtensions.GenerateSlug(productAcerProjector.Name), reference: Reference.Product,
objectId: productAcerProjector.Id)).Id,
DisplayOrder = 1
@@ -1119,7 +1119,7 @@ public partial class InstallationService
allProducts.Add(productAcerMonitor);
productAcerMonitor.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_acer_monitor_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_acer_monitor_1.png"), "image/png",
SeoExtensions.GenerateSlug(productAcerMonitor.Name), reference: Reference.Product,
objectId: productAcerMonitor.Id)).Id,
DisplayOrder = 1,
@@ -1127,7 +1127,7 @@ public partial class InstallationService
});
productAcerMonitor.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_acer_monitor_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_acer_monitor_2.png"), "image/png",
SeoExtensions.GenerateSlug(productAcerMonitor.Name), reference: Reference.Product,
objectId: productAcerMonitor.Id)).Id,
DisplayOrder = 2
@@ -1179,7 +1179,7 @@ public partial class InstallationService
allProducts.Add(productRedmiK30);
productRedmiK30.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_Redmi_K30.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_Redmi_K30.png"), "image/png",
SeoExtensions.GenerateSlug(productRedmiK30.Name), reference: Reference.Product,
objectId: productRedmiK30.Id)).Id,
DisplayOrder = 1,
@@ -1226,7 +1226,7 @@ public partial class InstallationService
allProducts.Add(productRedmiNote9);
productRedmiNote9.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_Redmi_Note_9_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_Redmi_Note_9_1.png"), "image/png",
SeoExtensions.GenerateSlug(productRedmiNote9.Name), reference: Reference.Product,
objectId: productRedmiNote9.Id)).Id,
DisplayOrder = 1,
@@ -1234,7 +1234,7 @@ public partial class InstallationService
});
productRedmiNote9.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_Redmi_Note_9_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_Redmi_Note_9_2.png"), "image/png",
SeoExtensions.GenerateSlug(productRedmiNote9.Name), reference: Reference.Product,
objectId: productRedmiNote9.Id)).Id,
DisplayOrder = 2
@@ -1280,7 +1280,7 @@ public partial class InstallationService
allProducts.Add(productPocoF2Pro);
productPocoF2Pro.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_POCO_F2_Pro.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_POCO_F2_Pro.png"), "image/png",
SeoExtensions.GenerateSlug(productPocoF2Pro.Name), reference: Reference.Product,
objectId: productPocoF2Pro.Id)).Id,
DisplayOrder = 1,
@@ -1348,7 +1348,7 @@ public partial class InstallationService
allProducts.Add(productMiSmartBand);
productMiSmartBand.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_Mi_Smart_Band_3i_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_Mi_Smart_Band_3i_1.png"), "image/png",
SeoExtensions.GenerateSlug(productMiSmartBand.Name), reference: Reference.Product,
objectId: productMiSmartBand.Id)).Id,
DisplayOrder = 1,
@@ -1356,7 +1356,7 @@ public partial class InstallationService
});
productMiSmartBand.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_Mi_Smart_Band_3i_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_Mi_Smart_Band_3i_2.png"), "image/png",
SeoExtensions.GenerateSlug(productMiSmartBand.Name), reference: Reference.Product,
objectId: productMiSmartBand.Id)).Id,
DisplayOrder = 2
@@ -1400,14 +1400,14 @@ public partial class InstallationService
};
allProducts.Add(productPs4);
productPs4.ProductPictures.Add(new ProductPicture {
- PictureId = (await _pictureRepository.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_ps4_1.png"),
+ PictureId = (await _pictureRepository.InsertPicture(await File.ReadAllBytesAsync(sampleImagesPath + "product_ps4_1.png"),
"image/png", SeoExtensions.GenerateSlug(productPs4.Name), reference: Reference.Product,
objectId: productPs4.Id)).Id,
DisplayOrder = 1,
IsDefault = true
});
productPs4.ProductPictures.Add(new ProductPicture {
- PictureId = (await _pictureRepository.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_ps4_2.png"),
+ PictureId = (await _pictureRepository.InsertPicture(await File.ReadAllBytesAsync(sampleImagesPath + "product_ps4_2.png"),
"image/png", SeoExtensions.GenerateSlug(productPs4.Name), reference: Reference.Product,
objectId: productPs4.Id)).Id,
DisplayOrder = 2
@@ -1453,7 +1453,7 @@ public partial class InstallationService
allProducts.Add(productMiBeard);
productMiBeard.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_mi_beard_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_mi_beard_1.png"), "image/png",
SeoExtensions.GenerateSlug(productMiBeard.Name), reference: Reference.Product,
objectId: productMiBeard.Id)).Id,
DisplayOrder = 1,
@@ -1461,7 +1461,7 @@ public partial class InstallationService
});
productMiBeard.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_mi_beard_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_mi_beard_2.png"), "image/png",
SeoExtensions.GenerateSlug(productMiBeard.Name), reference: Reference.Product,
objectId: productMiBeard.Id)).Id,
DisplayOrder = 1
@@ -1556,7 +1556,7 @@ public partial class InstallationService
allProducts.Add(productAdidasPredator);
productAdidasPredator.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_predator_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_predator_1.png"), "image/png",
SeoExtensions.GenerateSlug(productAdidasPredator.Name), reference: Reference.Product,
objectId: productAdidasPredator.Id)).Id,
DisplayOrder = 1,
@@ -1657,7 +1657,7 @@ public partial class InstallationService
};
allProducts.Add(productAdidasNitrocharge);
productAdidasNitrocharge.ProductPictures.Add(new ProductPicture {
- PictureId = (await _pictureRepository.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_adidas.png"),
+ PictureId = (await _pictureRepository.InsertPicture(await File.ReadAllBytesAsync(sampleImagesPath + "product_adidas.png"),
"image/png", SeoExtensions.GenerateSlug(productAdidasNitrocharge.Name),
reference: Reference.Product, objectId: productAdidasNitrocharge.Id)).Id,
DisplayOrder = 1,
@@ -1665,21 +1665,21 @@ public partial class InstallationService
});
productAdidasNitrocharge.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_adidas_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_adidas_2.png"), "image/png",
SeoExtensions.GenerateSlug(productAdidasNitrocharge.Name), reference: Reference.Product,
objectId: productAdidasNitrocharge.Id)).Id,
DisplayOrder = 2
});
productAdidasNitrocharge.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_adidas_3.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_adidas_3.png"), "image/png",
SeoExtensions.GenerateSlug(productAdidasNitrocharge.Name), reference: Reference.Product,
objectId: productAdidasNitrocharge.Id)).Id,
DisplayOrder = 3
});
productAdidasNitrocharge.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_adidas_4.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_adidas_4.png"), "image/png",
SeoExtensions.GenerateSlug(productAdidasNitrocharge.Name), reference: Reference.Product,
objectId: productAdidasNitrocharge.Id)).Id,
DisplayOrder = 4
@@ -1740,7 +1740,7 @@ public partial class InstallationService
allProducts.Add(productAdidasTurfs);
productAdidasTurfs.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_adidasturfs.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_adidasturfs.png"), "image/png",
SeoExtensions.GenerateSlug(productAdidasTurfs.Name), reference: Reference.Product,
objectId: productAdidasTurfs.Id)).Id,
DisplayOrder = 1,
@@ -1789,14 +1789,14 @@ public partial class InstallationService
allProducts.Add(productDerbyKit);
productDerbyKit.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_derby_awayshirt_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_derby_awayshirt_1.png"), "image/png",
SeoExtensions.GenerateSlug(productDerbyKit.Name), reference: Reference.Product,
objectId: productDerbyKit.Id)).Id,
DisplayOrder = 1
});
productDerbyKit.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_derby_shirt_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_derby_shirt_1.png"), "image/png",
SeoExtensions.GenerateSlug(productDerbyKit.Name), reference: Reference.Product,
objectId: productDerbyKit.Id)).Id,
DisplayOrder = 2
@@ -1837,7 +1837,7 @@ public partial class InstallationService
allProducts.Add(productDerbyKit_associated_1);
productDerbyKit_associated_1.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_derby_awayshirt_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_derby_awayshirt_1.png"), "image/png",
("Derby County Away Shirt"), reference: Reference.Product,
objectId: productDerbyKit_associated_1.Id)).Id,
DisplayOrder = 1,
@@ -1878,7 +1878,7 @@ public partial class InstallationService
allProducts.Add(productDerbyKit_associated_2);
productDerbyKit_associated_2.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_derby_shirt_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_derby_shirt_1.png"), "image/png",
SeoExtensions.GenerateSlug("Derby County Shirt - Home"), reference: Reference.Product,
objectId: productDerbyKit_associated_2.Id)).Id,
DisplayOrder = 1
@@ -1961,7 +1961,7 @@ public partial class InstallationService
};
allProducts.Add(productNikeKids);
productNikeKids.ProductPictures.Add(new ProductPicture {
- PictureId = (await _pictureRepository.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_kidskit.png"),
+ PictureId = (await _pictureRepository.InsertPicture(await File.ReadAllBytesAsync(sampleImagesPath + "product_kidskit.png"),
"image/png", SeoExtensions.GenerateSlug(productNikeKids.Name), reference: Reference.Product,
objectId: productNikeKids.Id)).Id,
DisplayOrder = 1,
@@ -2018,14 +2018,14 @@ public partial class InstallationService
};
allProducts.Add(productPsgKit);
productPsgKit.ProductPictures.Add(new ProductPicture {
- PictureId = (await _pictureRepository.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_psg_1.png"),
+ PictureId = (await _pictureRepository.InsertPicture(await File.ReadAllBytesAsync(sampleImagesPath + "product_psg_1.png"),
"image/png", SeoExtensions.GenerateSlug(productPsgKit.Name), reference: Reference.Product,
objectId: productPsgKit.Id)).Id,
DisplayOrder = 1,
IsDefault = true
});
productPsgKit.ProductPictures.Add(new ProductPicture {
- PictureId = (await _pictureRepository.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_psg_2.png"),
+ PictureId = (await _pictureRepository.InsertPicture(await File.ReadAllBytesAsync(sampleImagesPath + "product_psg_2.png"),
"image/png", SeoExtensions.GenerateSlug(productPsgKit.Name), reference: Reference.Product,
objectId: productPsgKit.Id)).Id,
DisplayOrder = 1
@@ -2077,7 +2077,7 @@ public partial class InstallationService
allProducts.Add(productDerbyShirt);
productDerbyShirt.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_derby_shirt_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_derby_shirt_1.png"), "image/png",
SeoExtensions.GenerateSlug(productDerbyShirt.Name), reference: Reference.Product,
objectId: productDerbyShirt.Id)).Id,
DisplayOrder = 1,
@@ -2121,7 +2121,7 @@ public partial class InstallationService
allProducts.Add(productDerbyShorts);
productDerbyShorts.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_derby_shorts_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_derby_shorts_1.png"), "image/png",
SeoExtensions.GenerateSlug(productDerbyShorts.Name), reference: Reference.Product,
objectId: productDerbyShorts.Id)).Id,
DisplayOrder = 1,
@@ -2165,7 +2165,7 @@ public partial class InstallationService
allProducts.Add(productDerbyKitHome);
productDerbyKitHome.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_derby_shirt_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_derby_shirt_1.png"), "image/png",
SeoExtensions.GenerateSlug(productDerbyKitHome.Name), reference: Reference.Product,
objectId: productDerbyKitHome.Id)).Id,
DisplayOrder = 1,
@@ -2226,7 +2226,7 @@ public partial class InstallationService
productChicagoBulls.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_chicago_jersey_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_chicago_jersey_1.png"), "image/png",
SeoExtensions.GenerateSlug(productChicagoBulls.Name), reference: Reference.Product,
objectId: productChicagoBulls.Id)).Id,
DisplayOrder = 1,
@@ -2234,7 +2234,7 @@ public partial class InstallationService
});
productChicagoBulls.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_chicago_jersey_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_chicago_jersey_2.png"), "image/png",
SeoExtensions.GenerateSlug(productChicagoBulls.Name), reference: Reference.Product,
objectId: productChicagoBulls.Id)).Id,
DisplayOrder = 2
@@ -2311,7 +2311,7 @@ public partial class InstallationService
allProducts.Add(productVivoactive);
productVivoactive.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_vivoactive.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_vivoactive.png"), "image/png",
SeoExtensions.GenerateSlug(productVivoactive.Name), reference: Reference.Product,
objectId: productVivoactive.Id)).Id,
DisplayOrder = 1,
@@ -2357,7 +2357,7 @@ public partial class InstallationService
allProducts.Add(productGarminFenix);
productGarminFenix.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_garmin_fenix_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_garmin_fenix_1.png"), "image/png",
SeoExtensions.GenerateSlug(productGarminFenix.Name), reference: Reference.Product,
objectId: productGarminFenix.Id)).Id,
DisplayOrder = 1,
@@ -2365,7 +2365,7 @@ public partial class InstallationService
});
productGarminFenix.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_garmin_fenix_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_garmin_fenix_2.png"), "image/png",
SeoExtensions.GenerateSlug(productGarminFenix.Name), reference: Reference.Product,
objectId: productGarminFenix.Id)).Id,
DisplayOrder = 1
@@ -2410,7 +2410,7 @@ public partial class InstallationService
allProducts.Add(productForerunner);
productForerunner.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_forerunner.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_forerunner.png"), "image/png",
SeoExtensions.GenerateSlug(productForerunner.Name), reference: Reference.Product,
objectId: productForerunner.Id)).Id,
DisplayOrder = 1,
@@ -2482,7 +2482,7 @@ public partial class InstallationService
allProducts.Add(productCyberpunk);
productCyberpunk.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_cyberpunk_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_cyberpunk_1.png"), "image/png",
SeoExtensions.GenerateSlug(productCyberpunk.Name), reference: Reference.Product,
objectId: productCyberpunk.Id)).Id,
DisplayOrder = 1
@@ -2548,7 +2548,7 @@ public partial class InstallationService
allProducts.Add(productGTA);
productGTA.ProductPictures.Add(new ProductPicture {
- PictureId = (await _pictureRepository.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_gta_1.png"),
+ PictureId = (await _pictureRepository.InsertPicture(await File.ReadAllBytesAsync(sampleImagesPath + "product_gta_1.png"),
"image/png", SeoExtensions.GenerateSlug(productGTA.Name), reference: Reference.Product,
objectId: productGTA.Id)).Id,
DisplayOrder = 1,
@@ -2604,7 +2604,7 @@ public partial class InstallationService
};
productCod.ProductPictures.Add(new ProductPicture {
- PictureId = (await _pictureRepository.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_cod_1.png"),
+ PictureId = (await _pictureRepository.InsertPicture(await File.ReadAllBytesAsync(sampleImagesPath + "product_cod_1.png"),
"image/png", SeoExtensions.GenerateSlug(productCod.Name, true, false, false), reference: Reference.Product,
objectId: productCod.Id)).Id,
DisplayOrder = 1
@@ -2656,7 +2656,7 @@ public partial class InstallationService
allProducts.Add(productLegoFalcon);
productLegoFalcon.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_lego_falcon_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_lego_falcon_1.png"), "image/png",
SeoExtensions.GenerateSlug(productLegoFalcon.Name), reference: Reference.Product,
objectId: productLegoFalcon.Id)).Id,
DisplayOrder = 1,
@@ -2664,7 +2664,7 @@ public partial class InstallationService
});
productLegoFalcon.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_lego_falcon_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_lego_falcon_2.png"), "image/png",
SeoExtensions.GenerateSlug(productLegoFalcon.Name), reference: Reference.Product,
objectId: productLegoFalcon.Id)).Id,
DisplayOrder = 1
@@ -2710,7 +2710,7 @@ public partial class InstallationService
allProducts.Add(productLegoHogwarts);
productLegoHogwarts.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_lego_hogwarts_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_lego_hogwarts_1.png"), "image/png",
SeoExtensions.GenerateSlug(productLegoHogwarts.Name), reference: Reference.Product,
objectId: productLegoHogwarts.Id)).Id,
DisplayOrder = 1,
@@ -2718,7 +2718,7 @@ public partial class InstallationService
});
productLegoHogwarts.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_lego_hogwarts_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_lego_hogwarts_2.png"), "image/png",
SeoExtensions.GenerateSlug(productLegoHogwarts.Name), reference: Reference.Product,
objectId: productLegoHogwarts.Id)).Id,
DisplayOrder = 1
@@ -2763,7 +2763,7 @@ public partial class InstallationService
allProducts.Add(productLegoCity);
productLegoCity.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_LegoCity_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_LegoCity_1.png"), "image/png",
SeoExtensions.GenerateSlug(productLegoCity.Name), reference: Reference.Product,
objectId: productLegoCity.Id)).Id,
DisplayOrder = 1,
@@ -2771,7 +2771,7 @@ public partial class InstallationService
});
productLegoCity.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_LegoCity_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_LegoCity_2.png"), "image/png",
SeoExtensions.GenerateSlug(productLegoCity.Name), reference: Reference.Product,
objectId: productLegoCity.Id)).Id,
DisplayOrder = 2
@@ -2820,7 +2820,7 @@ public partial class InstallationService
allProducts.Add(productAdidasBall);
productAdidasBall.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_adidasball.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_adidasball.png"), "image/png",
SeoExtensions.GenerateSlug(productAdidasBall.Name), reference: Reference.Product,
objectId: productAdidasBall.Id)).Id,
DisplayOrder = 1,
@@ -2866,7 +2866,7 @@ public partial class InstallationService
};
allProducts.Add(productMikasa);
productMikasa.ProductPictures.Add(new ProductPicture {
- PictureId = (await _pictureRepository.InsertPicture(File.ReadAllBytes(sampleImagesPath + "product_mikasa.png"),
+ PictureId = (await _pictureRepository.InsertPicture(await File.ReadAllBytesAsync(sampleImagesPath + "product_mikasa.png"),
"image/png", SeoExtensions.GenerateSlug(productMikasa.Name), reference: Reference.Product,
objectId: productMikasa.Id)).Id,
DisplayOrder = 1,
@@ -2912,7 +2912,7 @@ public partial class InstallationService
allProducts.Add(productSpalding);
productSpalding.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_spalding.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_spalding.png"), "image/png",
SeoExtensions.GenerateSlug(productSpalding.Name), reference: Reference.Product,
objectId: productSpalding.Id)).Id,
DisplayOrder = 1,
@@ -2955,7 +2955,7 @@ public partial class InstallationService
allProducts.Add(product25GiftVoucher);
product25GiftVoucher.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_25giftcart.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_25giftcart.png"), "image/png",
SeoExtensions.GenerateSlug(product25GiftVoucher.Name), reference: Reference.Product,
objectId: product25GiftVoucher.Id)).Id,
DisplayOrder = 1,
@@ -3002,7 +3002,7 @@ public partial class InstallationService
allProducts.Add(product50GiftVoucher);
product50GiftVoucher.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_50giftcart.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_50giftcart.png"), "image/png",
SeoExtensions.GenerateSlug(product50GiftVoucher.Name), reference: Reference.Product,
objectId: product50GiftVoucher.Id)).Id,
DisplayOrder = 1,
@@ -3047,7 +3047,7 @@ public partial class InstallationService
allProducts.Add(product100GiftVoucher);
product100GiftVoucher.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_100giftcart.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_100giftcart.png"), "image/png",
SeoExtensions.GenerateSlug(product100GiftVoucher.Name), reference: Reference.Product,
objectId: product100GiftVoucher.Id)).Id,
DisplayOrder = 1,
@@ -3093,7 +3093,7 @@ public partial class InstallationService
allProducts.Add(productPlaystationBundlePack);
productPlaystationBundlePack.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_sony_ps5_console_1.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_sony_ps5_console_1.png"), "image/png",
SeoExtensions.GenerateSlug(productPlaystationBundlePack.Name), reference: Reference.Product,
objectId: productPlaystationBundlePack.Id)).Id,
DisplayOrder = 1,
@@ -3101,7 +3101,7 @@ public partial class InstallationService
});
productPlaystationBundlePack.ProductPictures.Add(new ProductPicture {
PictureId = (await _pictureRepository.InsertPicture(
- File.ReadAllBytes(sampleImagesPath + "product_sony_ps5_console_2.png"), "image/png",
+ await File.ReadAllBytesAsync(sampleImagesPath + "product_sony_ps5_console_2.png"), "image/png",
SeoExtensions.GenerateSlug(productPlaystationBundlePack.Name), reference: Reference.Product,
objectId: productPlaystationBundlePack.Id)).Id,
DisplayOrder = 2
diff --git a/src/Modules/Grand.Module.Installer/Services/InstallDataSettings.cs b/src/Modules/Grand.Module.Installer/Services/InstallDataSettings.cs
index 71949d040..72363b574 100644
--- a/src/Modules/Grand.Module.Installer/Services/InstallDataSettings.cs
+++ b/src/Modules/Grand.Module.Installer/Services/InstallDataSettings.cs
@@ -29,7 +29,7 @@ public partial class InstallationService
{
var path = Path.Combine(_hostingEnvironment.WebRootPath, "logo.png");
- var storePictureId = (await _pictureRepository.InsertPicture(File.ReadAllBytes(path), "image/png", "Logo")).Id;
+ var storePictureId = (await _pictureRepository.InsertPicture(await File.ReadAllBytesAsync(path), "image/png", "Logo")).Id;
await _settingRepository.SaveSetting(new MenuItemSettings {
DisplayHomePageMenu = !installSampleData,
diff --git a/src/Modules/Grand.Module.Installer/Services/InstallationService.cs b/src/Modules/Grand.Module.Installer/Services/InstallationService.cs
index 018df5244..4c8ec00b3 100644
--- a/src/Modules/Grand.Module.Installer/Services/InstallationService.cs
+++ b/src/Modules/Grand.Module.Installer/Services/InstallationService.cs
@@ -449,7 +449,7 @@ public partial class InstallationService : IInstallationService
await _customerRepository.UpdateAsync(customer);
}
- private byte[] EncryptTextToMemory(string data, byte[] key, byte[] iv)
+ private static byte[] EncryptTextToMemory(string data, byte[] key, byte[] iv)
{
using var ms = new MemoryStream();
using (var cs = new CryptoStream(ms, TripleDES.Create().CreateEncryptor(key, iv), CryptoStreamMode.Write))
diff --git a/src/Modules/Grand.Module.Installer/Startup/StartupApplication.cs b/src/Modules/Grand.Module.Installer/Startup/StartupApplication.cs
index 94a44092a..927d015b0 100644
--- a/src/Modules/Grand.Module.Installer/Startup/StartupApplication.cs
+++ b/src/Modules/Grand.Module.Installer/Startup/StartupApplication.cs
@@ -22,7 +22,7 @@ public class StartupApplication : IStartupApplication
public int Priority => 100;
public bool BeforeConfigure => false;
- private void RegisterInstallService(IServiceCollection serviceCollection)
+ private static void RegisterInstallService(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<IInstallationLocalizedService, InstallationLocalizedService>();
serviceCollection.AddScoped<IInstallationService, InstallationService>();
diff --git a/src/Modules/Grand.Module.ScheduledTasks/Commands/Handlers/Common/GetSitemapXMLCommandHandler.cs b/src/Modules/Grand.Module.ScheduledTasks/Commands/Handlers/Common/GetSitemapXMLCommandHandler.cs
index b950a5ffd..63ee79bd4 100644
--- a/src/Modules/Grand.Module.ScheduledTasks/Commands/Handlers/Common/GetSitemapXMLCommandHandler.cs
+++ b/src/Modules/Grand.Module.ScheduledTasks/Commands/Handlers/Common/GetSitemapXMLCommandHandler.cs
@@ -77,7 +77,7 @@ public class GetSitemapXmlCommandHandler : IRequestHandler<GetSitemapXmlCommand,
return await Generate(request.Language, request.Store);
}
- private string RemoveBom(string p)
+ private static string RemoveBom(string p)
{
var bomMarkUtf8 = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble());
if (p.StartsWith(bomMarkUtf8))
diff --git a/src/Modules/Grand.Module.ScheduledTasks/Startup/StartupApplication.cs b/src/Modules/Grand.Module.ScheduledTasks/Startup/StartupApplication.cs
index d0741d68d..6f620d782 100644
--- a/src/Modules/Grand.Module.ScheduledTasks/Startup/StartupApplication.cs
+++ b/src/Modules/Grand.Module.ScheduledTasks/Startup/StartupApplication.cs
@@ -22,7 +22,7 @@ public class StartupApplication : IStartupApplication
public int Priority => 100;
public bool BeforeConfigure => false;
- private void RegisterTask(IServiceCollection serviceCollection)
+ private static void RegisterTask(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<IScheduleTaskService, ScheduleTaskService>();
diff --git a/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/CustomerGroupsController.cs b/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/CustomerGroupsController.cs
index 01d655271..375e4362a 100644
--- a/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/CustomerGroupsController.cs
+++ b/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/CustomerGroupsController.cs
@@ -54,7 +54,7 @@ public class CustomerGroupsController : BaseAdminPluginController
foreach (var cr in await _groupService.GetAllCustomerGroups(showHidden: true))
model.AvailableCustomerGroups.Add(new SelectListItem {
Text = cr.Name, Value = cr.Id,
- Selected = discountRequirement != null && cr.Id == discountRequirement?.Metadata
+ Selected = discountRequirement != null && cr.Id == discountRequirement.Metadata
});
//add a prefix
diff --git a/src/Plugins/Widgets.GoogleAnalytics/Components/WidgetsGoogleAnalyticsViewComponent.cs b/src/Plugins/Widgets.GoogleAnalytics/Components/WidgetsGoogleAnalyticsViewComponent.cs
index 6cbbf69f8..b2f1c953c 100644
--- a/src/Plugins/Widgets.GoogleAnalytics/Components/WidgetsGoogleAnalyticsViewComponent.cs
+++ b/src/Plugins/Widgets.GoogleAnalytics/Components/WidgetsGoogleAnalyticsViewComponent.cs
@@ -183,7 +183,7 @@ public class WidgetsGoogleAnalyticsViewComponent : ViewComponent
return analyticsTrackingScript;
}
- private string FixIllegalJavaScriptChars(string text)
+ private static string FixIllegalJavaScriptChars(string text)
{
if (string.IsNullOrEmpty(text))
return text;
diff --git a/src/Plugins/Widgets.Slider/Infrastructure/Mapper/SliderMapperConfiguration.cs b/src/Plugins/Widgets.Slider/Infrastructure/Mapper/SliderMapperConfiguration.cs
index 39fe2b93d..26e914544 100644
--- a/src/Plugins/Widgets.Slider/Infrastructure/Mapper/SliderMapperConfiguration.cs
+++ b/src/Plugins/Widgets.Slider/Infrastructure/Mapper/SliderMapperConfiguration.cs
@@ -31,7 +31,7 @@ public class SliderMapperConfiguration : Profile, IAutoMapperProfile
public int Order => 0;
- private string SetObjectEntry(SlideModel model)
+ private static string SetObjectEntry(SlideModel model)
{
return model.SliderTypeId switch {
(int)SliderType.HomePage => "",
@@ -42,17 +42,17 @@ public class SliderMapperConfiguration : Profile, IAutoMapperProfile
};
}
- private string GetCategoryId(PictureSlider pictureSlider)
+ private static string GetCategoryId(PictureSlider pictureSlider)
{
return pictureSlider.SliderTypeId == SliderType.Category ? pictureSlider.ObjectEntry : "";
}
- private string GetCollectionId(PictureSlider pictureSlider)
+ private static string GetCollectionId(PictureSlider pictureSlider)
{
return pictureSlider.SliderTypeId == SliderType.Collection ? pictureSlider.ObjectEntry : "";
}
- private string GetBrandId(PictureSlider pictureSlider)
+ private static string GetBrandId(PictureSlider pictureSlider)
{
return pictureSlider.SliderTypeId == SliderType.Brand ? pictureSlider.ObjectEntry : "";
}
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shared/_AdminLayout.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shared/_AdminLayout.cshtml
index bf0cb9a25..0d8ec7805 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shared/_AdminLayout.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Shared/_AdminLayout.cshtml
@@ -176,7 +176,7 @@
@if (await groupService.IsAdmin(currentCustomer))
{
<li>
- <a href="@Url.Action("Edit", "Customer", new { id = currentCustomer.Id, area = Constants.AreaAdmin })">
+ <a href="@Url.Action("Edit", "Customer", new { currentCustomer.Id, area = Constants.AreaAdmin })">
<i class="icon-user"></i> @Loc["Admin.Header.Profile"]
</a>
</li>
diff --git a/src/Web/Grand.Web.Admin/Controllers/HomeController.cs b/src/Web/Grand.Web.Admin/Controllers/HomeController.cs
index 221544cfe..bf03ee122 100644
--- a/src/Web/Grand.Web.Admin/Controllers/HomeController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/HomeController.cs
@@ -206,7 +206,7 @@ public class HomeController : BaseAdminController
return View();
}
- _logger.LogInformation("Access denied to user #{CurrentCustomerEmail} \'{CurrentCustomerEmail}\'", currentCustomer.Email, currentCustomer.Email);
+ _logger.LogInformation("Access denied to user #{CurrentCustomerEmail}", currentCustomer.Email);
return View();
}
diff --git a/src/Web/Grand.Web.Admin/Controllers/OrderController.cs b/src/Web/Grand.Web.Admin/Controllers/OrderController.cs
index 2e09adaea..22ea5ecf1 100644
--- a/src/Web/Grand.Web.Admin/Controllers/OrderController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/OrderController.cs
@@ -266,7 +266,7 @@ public class OrderController(
//add a note
await orderService.InsertOrderNote(new OrderNote {
- Note = $"Order status has been edited. New status: {status?.Name}",
+ Note = $"Order status has been edited. New status: {status.Name}",
DisplayToCustomer = false,
OrderId = order.Id
});
diff --git a/src/Web/Grand.Web.Admin/Controllers/PluginController.cs b/src/Web/Grand.Web.Admin/Controllers/PluginController.cs
index 70cf1dedf..de794fbaf 100644
--- a/src/Web/Grand.Web.Admin/Controllers/PluginController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/PluginController.cs
@@ -73,7 +73,7 @@ public class PluginController(
}
- protected byte[] ToByteArray(Stream stream)
+ protected static byte[] ToByteArray(Stream stream)
{
using (stream)
{
diff --git a/src/Web/Grand.Web.Admin/Controllers/SettingController.cs b/src/Web/Grand.Web.Admin/Controllers/SettingController.cs
index 3d2045acb..f53a256e6 100644
--- a/src/Web/Grand.Web.Admin/Controllers/SettingController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/SettingController.cs
@@ -5,7 +5,6 @@ using Grand.Business.Core.Interfaces.Common.Configuration;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Storage;
-using Grand.Domain.Permissions;
using Grand.Domain.Admin;
using Grand.Domain.Blogs;
using Grand.Domain.Catalog;
@@ -18,6 +17,7 @@ using Grand.Domain.Localization;
using Grand.Domain.Media;
using Grand.Domain.News;
using Grand.Domain.Orders;
+using Grand.Domain.Permissions;
using Grand.Domain.PushNotifications;
using Grand.Domain.Security;
using Grand.Domain.Seo;
@@ -29,7 +29,6 @@ using Grand.Web.Admin.Extensions.Mapping;
using Grand.Web.Admin.Extensions.Mapping.Settings;
using Grand.Web.Admin.Models.Settings;
using Grand.Web.Common.DataSource;
-using Grand.Web.Common.Extensions;
using Grand.Web.Common.Filters;
using Grand.Web.Common.Localization;
using Grand.Web.Common.Security.Authorization;
@@ -47,14 +46,10 @@ namespace Grand.Web.Admin.Controllers;
[PermissionAuthorize(PermissionSystemName.Settings)]
public class SettingController(
ISettingService settingService,
- ICurrencyService currencyService,
IPictureService pictureService,
ITranslationService translationService,
- IDateTimeService dateTimeService,
- IMediator mediator,
IMerchandiseReturnService merchandiseReturnService,
ILanguageService languageService,
- IOrderStatusService orderStatusService,
ICacheBase cacheBase,
IEnumTranslationService enumTranslationService)
: BaseAdminController
@@ -222,7 +217,7 @@ public class SettingController(
#endregion
- public async Task<IActionResult> Sales()
+ public async Task<IActionResult> Sales([FromServices] IOrderStatusService orderStatusService, [FromServices] ICurrencyService currencyService)
{
//load settings for a chosen store scope
var storeScope = await GetActiveStore();
@@ -286,8 +281,8 @@ public class SettingController(
{
//If we got this far, something failed, redisplay form
foreach (var modelState in ModelState.Values)
- foreach (var error in modelState.Errors)
- Error(error.ErrorMessage);
+ foreach (var error in modelState.Errors)
+ Error(error.ErrorMessage);
}
//selected tab
@@ -595,7 +590,7 @@ public class SettingController(
return RedirectToAction("Customer");
}
- public async Task<IActionResult> GeneralCommon([FromServices] IEnumerable<IThemeView> themes)
+ public async Task<IActionResult> GeneralCommon([FromServices] IEnumerable<IThemeView> themes, [FromServices] IDateTimeService dateTimeService)
{
var model = new GeneralCommonSettingsModel();
var storeScope = await GetActiveStore();
@@ -757,27 +752,27 @@ public class SettingController(
await ClearCache();
//save to file
- SavePushNotificationsToFile(model, configuration, webHostEnvironment);
+ SavePushNotificationsToFile(model);
Success(translationService.GetResource("Admin.Configuration.Updated"));
return await PushNotifications();
- }
- private void SavePushNotificationsToFile(PushNotificationsSettingsModel model, IConfiguration configuration, IWebHostEnvironment webHostEnvironment)
- {
- var fullPath = GetSafeFilePath(configuration, webHostEnvironment, "firebase-messaging-sw.js");
-
- if (System.IO.File.Exists(fullPath))
+ void SavePushNotificationsToFile(PushNotificationsSettingsModel model)
{
- var lines = System.IO.File.ReadAllLines(fullPath);
- lines = UpdateFileLines(lines, model);
- System.IO.File.WriteAllLines(fullPath, lines);
+ var fullPath = GetSafeFilePath(configuration, webHostEnvironment, "firebase-messaging-sw.js");
+
+ if (System.IO.File.Exists(fullPath))
+ {
+ var lines = System.IO.File.ReadAllLines(fullPath);
+ lines = UpdateFileLines(lines, model);
+ System.IO.File.WriteAllLines(fullPath, lines);
+ }
+ else
+ throw new ArgumentNullException($"{fullPath} not exist");
}
- else
- throw new ArgumentNullException($"{fullPath} not exist");
}
- private string GetSafeFilePath(IConfiguration configuration, IWebHostEnvironment webHostEnvironment, string filename)
+ private static string GetSafeFilePath(IConfiguration configuration, IWebHostEnvironment webHostEnvironment, string filename)
{
var directoryParam = configuration[CommonPath.DirectoryParam] ?? "";
@@ -795,7 +790,7 @@ public class SettingController(
return fullPath;
}
- private string[] UpdateFileLines(string[] lines, PushNotificationsSettingsModel model)
+ private static string[] UpdateFileLines(string[] lines, PushNotificationsSettingsModel model)
{
for (var i = 0; i < lines.Length; i++)
{
@@ -809,7 +804,7 @@ public class SettingController(
}
return lines;
}
-
+
public async Task<IActionResult> AdminSearch()
{
var settings = await settingService.LoadSetting<AdminSearchSettings>();
@@ -833,7 +828,7 @@ public class SettingController(
#region System settings
- public async Task<IActionResult> SystemSetting()
+ public async Task<IActionResult> SystemSetting([FromServices] IMediator mediator)
{
var settings = await settingService.LoadSetting<SystemSettings>();
@@ -870,7 +865,7 @@ public class SettingController(
}
[HttpPost]
- public async Task<IActionResult> SystemSetting(SystemSettingsModel model)
+ public async Task<IActionResult> SystemSetting([FromServices] IMediator mediator, SystemSettingsModel model)
{
//system
var settings = await settingService.LoadSetting<SystemSettings>();
@@ -906,7 +901,7 @@ public class SettingController(
Success(translationService.GetResource("Admin.Configuration.Updated"));
- return await SystemSetting();
+ return RedirectToAction("SystemSetting");
}
[HttpPost]
diff --git a/src/Web/Grand.Web.Admin/Controllers/ShippingController.cs b/src/Web/Grand.Web.Admin/Controllers/ShippingController.cs
index ba8b5c360..59074c840 100644
--- a/src/Web/Grand.Web.Admin/Controllers/ShippingController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/ShippingController.cs
@@ -338,7 +338,7 @@ public class ShippingController : BaseAdminController
if (states?.Count > 0)
foreach (var s in states)
model.ShippingOriginAddress.AvailableStates.Add(new SelectListItem
- { Text = s.Name, Value = s.Id, Selected = s.Id == originAddress?.StateProvinceId });
+ { Text = s.Name, Value = s.Id, Selected = s.Id == originAddress.StateProvinceId });
model.ShippingOriginAddress.CountryEnabled = true;
model.ShippingOriginAddress.StateProvinceEnabled = true;
diff --git a/src/Web/Grand.Web.Admin/Extensions/Mapping/AddressMappingExtensions.cs b/src/Web/Grand.Web.Admin/Extensions/Mapping/AddressMappingExtensions.cs
index dcf7df366..113194e4b 100644
--- a/src/Web/Grand.Web.Admin/Extensions/Mapping/AddressMappingExtensions.cs
+++ b/src/Web/Grand.Web.Admin/Extensions/Mapping/AddressMappingExtensions.cs
@@ -13,10 +13,10 @@ public static class AddressMappingExtensions
{
var address = entity.MapTo<Address, AddressModel>();
var country = await countryService.GetCountryById(address.CountryId);
- if (country != null && !string.IsNullOrEmpty(address.CountryId)) address.CountryName = country?.Name;
+ if (country != null && !string.IsNullOrEmpty(address.CountryId)) address.CountryName = country.Name;
if (country != null && !string.IsNullOrEmpty(address.StateProvinceId))
address.StateProvinceName =
- country?.StateProvinces.FirstOrDefault(x => x.Id == address.StateProvinceId)?.Name;
+ country.StateProvinces.FirstOrDefault(x => x.Id == address.StateProvinceId)?.Name;
return address;
}
diff --git a/src/Web/Grand.Web.Admin/Services/MerchandiseReturnViewModelService.cs b/src/Web/Grand.Web.Admin/Services/MerchandiseReturnViewModelService.cs
index e525490b2..f32d7c5f1 100644
--- a/src/Web/Grand.Web.Admin/Services/MerchandiseReturnViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/MerchandiseReturnViewModelService.cs
@@ -214,6 +214,7 @@ public class MerchandiseReturnViewModelService(
foreach (var item in merchandiseReturn.MerchandiseReturnItems)
{
var orderItem = order.OrderItems.FirstOrDefault(x => x.Id == item.OrderItemId);
+ ArgumentNullException.ThrowIfNull(orderItem);
items.Add(new MerchandiseReturnModel.MerchandiseReturnItemModel {
ProductId = orderItem.ProductId,
ProductName = (await productService.GetProductByIdIncludeArch(orderItem.ProductId)).Name,
diff --git a/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs b/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs
index e807975d8..af779b3bf 100644
--- a/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs
@@ -1241,7 +1241,7 @@ public class OrderViewModelService : IOrderViewModelService
}
}
- private IList<string> ParseOrderTagsToList(string orderTags)
+ private static IList<string> ParseOrderTagsToList(string orderTags)
{
var result = new List<string>();
if (!string.IsNullOrWhiteSpace(orderTags))
diff --git a/src/Web/Grand.Web.Admin/Services/PictureViewModelService.cs b/src/Web/Grand.Web.Admin/Services/PictureViewModelService.cs
index c5dfe3c8b..2a45e1a6b 100644
--- a/src/Web/Grand.Web.Admin/Services/PictureViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/PictureViewModelService.cs
@@ -28,10 +28,10 @@ public class PictureViewModelService : IPictureViewModelService
Id = picture.Id,
ObjectId = objectId,
PictureUrl = await _pictureService.GetPictureUrl(picture),
- AltAttribute = picture?.AltAttribute,
- TitleAttribute = picture?.TitleAttribute,
- Style = picture?.Style,
- ExtraField = picture?.ExtraField
+ AltAttribute = picture.AltAttribute,
+ TitleAttribute = picture.TitleAttribute,
+ Style = picture.Style,
+ ExtraField = picture.ExtraField
};
foreach (var language in await _languageService.GetAllLanguages(true))
diff --git a/src/Web/Grand.Web.Common/Infrastructure/ApplicationBuilderExtensions.cs b/src/Web/Grand.Web.Common/Infrastructure/ApplicationBuilderExtensions.cs
index 1db50d61e..19208911c 100644
--- a/src/Web/Grand.Web.Common/Infrastructure/ApplicationBuilderExtensions.cs
+++ b/src/Web/Grand.Web.Common/Infrastructure/ApplicationBuilderExtensions.cs
@@ -59,22 +59,17 @@ public static class ApplicationBuilderExtensions
return;
}
- try
+ if (DataSettingsManager.DatabaseIsInstalled())
{
- //check whether database is installed
- if (DataSettingsManager.DatabaseIsInstalled())
- {
- var logger = context.RequestServices.GetRequiredService<ILoggerFactory>()
- .CreateLogger("UseExceptionHandler");
- //log error
- logger.LogError(exception, exception.Message);
- }
- }
- finally
- {
- //rethrow the exception to show the error page
- throw exception;
+ var logger = context.RequestServices.GetRequiredService<ILoggerFactory>()
+ .CreateLogger("UseExceptionHandler");
+ // Log the error
+ logger.LogError(exception, exception.Message);
}
+
+ // Set the response status code and message without throwing
+ context.Response.StatusCode = StatusCodes.Status500InternalServerError;
+ await context.Response.WriteAsync("An unexpected error occurred.");
});
});
}
diff --git a/src/Web/Grand.Web.Common/Infrastructure/BackgroundServiceTask.cs b/src/Web/Grand.Web.Common/Infrastructure/BackgroundServiceTask.cs
index 49044b08c..dcc0e885e 100644
--- a/src/Web/Grand.Web.Common/Infrastructure/BackgroundServiceTask.cs
+++ b/src/Web/Grand.Web.Common/Infrastructure/BackgroundServiceTask.cs
@@ -104,7 +104,7 @@ public class BackgroundServiceTask : BackgroundService
}
}
- private async Task WorkContext(IServiceProvider serviceProvider, ScheduleTask scheduleTask)
+ private static async Task WorkContext(IServiceProvider serviceProvider, ScheduleTask scheduleTask)
{
var contextAccessor = serviceProvider.GetRequiredService<IContextAccessor>();
diff --git a/src/Web/Grand.Web.Common/Middleware/InstallUrlMiddleware.cs b/src/Web/Grand.Web.Common/Middleware/InstallUrlMiddleware.cs
index 5854a4c83..26e684591 100644
--- a/src/Web/Grand.Web.Common/Middleware/InstallUrlMiddleware.cs
+++ b/src/Web/Grand.Web.Common/Middleware/InstallUrlMiddleware.cs
@@ -83,7 +83,7 @@ public class InstallUrlMiddleware
}, int.MaxValue);
}
- private bool IsInstallUrl(HttpRequest request)
+ private static bool IsInstallUrl(HttpRequest request)
{
return request.GetEncodedPathAndQuery().StartsWith(InstallUrl, StringComparison.OrdinalIgnoreCase);
}
diff --git a/src/Web/Grand.Web.Common/Startup/StartupApplication.cs b/src/Web/Grand.Web.Common/Startup/StartupApplication.cs
index 1b31ddc8c..349534514 100644
--- a/src/Web/Grand.Web.Common/Startup/StartupApplication.cs
+++ b/src/Web/Grand.Web.Common/Startup/StartupApplication.cs
@@ -54,7 +54,7 @@ public class StartupApplication : IStartupApplication
public int Priority => 0;
public bool BeforeConfigure => false;
- private void RegisterCache(IServiceCollection serviceCollection, IConfiguration configuration)
+ private static void RegisterCache(IServiceCollection serviceCollection, IConfiguration configuration)
{
var config = new RedisConfig();
configuration.GetSection("Redis").Bind(config);
@@ -71,7 +71,7 @@ public class StartupApplication : IStartupApplication
}
}
- private void RegisterContextService(IServiceCollection serviceCollection)
+ private static void RegisterContextService(IServiceCollection serviceCollection)
{
//work context
serviceCollection.AddSingleton<IContextAccessor, ContextAccessor>();
@@ -98,7 +98,7 @@ public class StartupApplication : IStartupApplication
}
- private void RegisterFramework(IServiceCollection serviceCollection)
+ private static void RegisterFramework(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<IPageHeadBuilder, PageHeadBuilder>();
diff --git a/src/Web/Grand.Web.Common/Startup/UrlRewriteStartup.cs b/src/Web/Grand.Web.Common/Startup/UrlRewriteStartup.cs
index 211406f74..9bb355062 100644
--- a/src/Web/Grand.Web.Common/Startup/UrlRewriteStartup.cs
+++ b/src/Web/Grand.Web.Common/Startup/UrlRewriteStartup.cs
@@ -42,7 +42,7 @@ public class UrlRewriteStartup : IStartupApplication
application.UseRewriter(urlRewriteOptions);
}
}
- private void ConfigureUrlRewriteOptions(RewriteOptions options, UrlRewriteConfig config)
+ private static void ConfigureUrlRewriteOptions(RewriteOptions options, UrlRewriteConfig config)
{
if (config.UseUrlRewrite && File.Exists(UrlRewriteFilePath))
{
@@ -51,7 +51,7 @@ public class UrlRewriteStartup : IStartupApplication
}
}
- private void ConfigureHttpsOptions(RewriteOptions options, UrlRewriteConfig config)
+ private static void ConfigureHttpsOptions(RewriteOptions options, UrlRewriteConfig config)
{
if (config.UrlRewriteHttpsOptions)
{
diff --git a/src/Web/Grand.Web.Common/TagHelpers/Admin/AdminInputTagHelper.cs b/src/Web/Grand.Web.Common/TagHelpers/Admin/AdminInputTagHelper.cs
index fd1e57d50..f134e467c 100644
--- a/src/Web/Grand.Web.Common/TagHelpers/Admin/AdminInputTagHelper.cs
+++ b/src/Web/Grand.Web.Common/TagHelpers/Admin/AdminInputTagHelper.cs
@@ -156,7 +156,7 @@ public class AdminInputTagHelper : TagHelper
}
- private object GetPrivateFieldValue(object target, string fieldName)
+ private static object GetPrivateFieldValue(object target, string fieldName)
{
ArgumentNullException.ThrowIfNull(target);
ArgumentNullException.ThrowIfNullOrEmpty(fieldName);
diff --git a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/DefaultHtmlGenerator.cs b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/DefaultHtmlGenerator.cs
index 8f333d907..f04892c4a 100644
--- a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/DefaultHtmlGenerator.cs
+++ b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/DefaultHtmlGenerator.cs
@@ -1330,7 +1330,7 @@ public class DefaultHtmlGenerator : IHtmlGenerator
return listItemBuilder;
}
- private IHtmlContent GenerateOption(SelectListItem item, ICollection<string> currentValues)
+ private static IHtmlContent GenerateOption(SelectListItem item, ICollection<string> currentValues)
{
var selected = item.Selected;
if (currentValues != null)
diff --git a/src/Web/Grand.Web.Common/View/DefaultAreaViewFactory.cs b/src/Web/Grand.Web.Common/View/DefaultAreaViewFactory.cs
index 01879771b..9fc081fee 100644
--- a/src/Web/Grand.Web.Common/View/DefaultAreaViewFactory.cs
+++ b/src/Web/Grand.Web.Common/View/DefaultAreaViewFactory.cs
@@ -31,7 +31,7 @@ public class DefaultAreaViewFactory : IAreaViewFactory
: GetDefaultViewLocations();
}
- private IEnumerable<string> GetDefaultViewLocations()
+ private static IEnumerable<string> GetDefaultViewLocations()
{
return new List<string> {
"/Views/{1}/{0}.cshtml",
diff --git a/src/Web/Grand.Web.Common/View/ViewLocationExpander.cs b/src/Web/Grand.Web.Common/View/ViewLocationExpander.cs
index 581dc2fe1..3fcada461 100644
--- a/src/Web/Grand.Web.Common/View/ViewLocationExpander.cs
+++ b/src/Web/Grand.Web.Common/View/ViewLocationExpander.cs
@@ -15,7 +15,7 @@ public class ViewLocationExpander : IViewLocationExpander
var themeContext = themeContextFactory.GetThemeContext(context.AreaName ?? "");
var themeName = themeContext?.GetCurrentTheme();
if (!string.IsNullOrEmpty(themeName))
- context.Values[ThemeKey] = themeContext?.GetCurrentTheme();
+ context.Values[ThemeKey] = themeContext.GetCurrentTheme();
}
public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context,
diff --git a/src/Web/Grand.Web.Vendor/Extensions/AddressMappingExtensions.cs b/src/Web/Grand.Web.Vendor/Extensions/AddressMappingExtensions.cs
index 94d13fa35..535b7d11e 100644
--- a/src/Web/Grand.Web.Vendor/Extensions/AddressMappingExtensions.cs
+++ b/src/Web/Grand.Web.Vendor/Extensions/AddressMappingExtensions.cs
@@ -13,11 +13,11 @@ public static class AddressMappingExtensions
{
var address = entity.MapTo<Address, AddressModel>();
var country = await countryService.GetCountryById(address.CountryId);
- if (country != null && !string.IsNullOrEmpty(address.CountryId)) address.CountryName = country?.Name;
+ if (country != null && !string.IsNullOrEmpty(address.CountryId)) address.CountryName = country.Name;
if (country != null && !string.IsNullOrEmpty(address.StateProvinceId))
address.StateProvinceName =
- country?.StateProvinces.FirstOrDefault(x => x.Id == address.StateProvinceId)?.Name;
+ country.StateProvinces.FirstOrDefault(x => x.Id == address.StateProvinceId)?.Name;
return address;
}
diff --git a/src/Web/Grand.Web.Vendor/Services/MerchandiseReturnViewModelService.cs b/src/Web/Grand.Web.Vendor/Services/MerchandiseReturnViewModelService.cs
index 5869284ac..325aa1f33 100644
--- a/src/Web/Grand.Web.Vendor/Services/MerchandiseReturnViewModelService.cs
+++ b/src/Web/Grand.Web.Vendor/Services/MerchandiseReturnViewModelService.cs
@@ -194,10 +194,11 @@ public class MerchandiseReturnViewModelService : IMerchandiseReturnViewModelServ
foreach (var item in merchandiseReturn.MerchandiseReturnItems)
{
var orderItem = order.OrderItems.FirstOrDefault(x => x.Id == item.OrderItemId);
+ ArgumentNullException.ThrowIfNull(orderItem);
items.Add(new MerchandiseReturnModel.MerchandiseReturnItemModel {
- ProductId = orderItem?.ProductId,
- ProductName = (await _productService.GetProductByIdIncludeArch(orderItem?.ProductId)).Name,
- ProductSku = orderItem?.Sku,
+ ProductId = orderItem.ProductId,
+ ProductName = (await _productService.GetProductByIdIncludeArch(orderItem.ProductId)).Name,
+ ProductSku = orderItem.Sku,
Quantity = item.Quantity,
UnitPrice = _priceFormatter.FormatPrice(orderItem!.UnitPriceInclTax),
ReasonForReturn = item.ReasonForReturn,
diff --git a/src/Web/Grand.Web/Controllers/CheckoutController.cs b/src/Web/Grand.Web/Controllers/CheckoutController.cs
index 0d6281647..b819a324b 100644
--- a/src/Web/Grand.Web/Controllers/CheckoutController.cs
+++ b/src/Web/Grand.Web/Controllers/CheckoutController.cs
@@ -842,7 +842,7 @@ public class CheckoutController : BasePublicController
return warnings;
}
- private IList<string> SerializeModelState(ModelStateDictionary modelState)
+ private static IList<string> SerializeModelState(ModelStateDictionary modelState)
{
var errors = new List<string>();
var valuerrors = modelState.Where(entry => entry.Value.Errors.Any());
diff --git a/src/Web/Grand.Web/Controllers/CommonController.cs b/src/Web/Grand.Web/Controllers/CommonController.cs
index 0345a083d..325f23f3e 100644
--- a/src/Web/Grand.Web/Controllers/CommonController.cs
+++ b/src/Web/Grand.Web/Controllers/CommonController.cs
@@ -56,7 +56,7 @@ public class CommonController : BasePublicController
#region Utilities
- private string RemoveLanguageSeoCode(string url, PathString pathBase)
+ private static string RemoveLanguageSeoCode(string url, PathString pathBase)
{
if (string.IsNullOrEmpty(url))
return url;
diff --git a/src/Web/Grand.Web/Features/Handlers/Common/GetAddressModelHandler.cs b/src/Web/Grand.Web/Features/Handlers/Common/GetAddressModelHandler.cs
index 73ae4c831..d0615c2dc 100644
--- a/src/Web/Grand.Web/Features/Handlers/Common/GetAddressModelHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Common/GetAddressModelHandler.cs
@@ -135,14 +135,14 @@ public class GetAddressModelHandler : IRequestHandler<GetAddressModel, AddressMo
{
var states = await _countryService
.GetStateProvincesByCountryId(
- !string.IsNullOrEmpty(model.CountryId) ? model.CountryId : store.DefaultCountryId, language.Id);
+ !string.IsNullOrEmpty(model.CountryId) ? model.CountryId : store.DefaultCountryId, language?.Id);
model.AvailableStates.Add(new SelectListItem
{ Text = _translationService.GetResource("Address.SelectState"), Value = "" });
foreach (var s in states)
model.AvailableStates.Add(new SelectListItem {
- Text = s.GetTranslation(x => x.Name, language.Id),
+ Text = s.GetTranslation(x => x.Name, language?.Id),
Value = s.Id,
Selected = s.Id == model.StateProvinceId
});
diff --git a/src/Web/Grand.Web/Features/Handlers/Customers/GetInfoHandler.cs b/src/Web/Grand.Web/Features/Handlers/Customers/GetInfoHandler.cs
index 5fecc406f..e90e23652 100644
--- a/src/Web/Grand.Web/Features/Handlers/Customers/GetInfoHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Customers/GetInfoHandler.cs
@@ -86,7 +86,7 @@ public class GetInfoHandler : IRequestHandler<GetInfo, CustomerInfoModel>
return model;
}
- private void PrepareNotExludeModel(CustomerInfoModel model, GetInfo request)
+ private static void PrepareNotExludeModel(CustomerInfoModel model, GetInfo request)
{
model.VatNumber = request.Customer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.VatNumber);
model.FirstName = request.Customer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.FirstName);
diff --git a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsAttributeChangeHandler.cs b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsAttributeChangeHandler.cs
index 52402b1c2..f6aaabf71 100644
--- a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsAttributeChangeHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsAttributeChangeHandler.cs
@@ -175,7 +175,7 @@ public class GetProductDetailsAttributeChangeHandler : IRequestHandler<GetProduc
return model;
}
- private List<string> PrepareNotAvailableAttributeMapping(GetProductDetailsAttributeChange request,
+ private static List<string> PrepareNotAvailableAttributeMapping(GetProductDetailsAttributeChange request,
IList<CustomAttribute> customAttributes)
{
var model = new List<string>();
diff --git a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs
index 64579c7e9..821d54453 100644
--- a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs
@@ -410,7 +410,7 @@ public class GetProductDetailsPageHandler : IRequestHandler<GetProductDetailsPag
WarehouseId = warehouse.Id,
Name = warehouse.Name,
Code = warehouse.Code,
- Selected = updateCartItem != null && updateCartItem?.WarehouseId == warehouse.Id
+ Selected = updateCartItem != null && updateCartItem.WarehouseId == warehouse.Id
});
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Products/GetProductReviewsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Products/GetProductReviewsHandler.cs
index f42d71baa..d2ebebf42 100644
--- a/src/Web/Grand.Web/Features/Handlers/Products/GetProductReviewsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Products/GetProductReviewsHandler.cs
@@ -56,7 +56,7 @@ public class GetProductReviewsHandler : IRequestHandler<GetProductReviews, Produ
var customer = await _customerService.GetCustomerById(pr.CustomerId);
model.Items.Add(new ProductReviewModel {
Id = pr.Id,
- CustomerId = pr?.CustomerId,
+ CustomerId = pr.CustomerId,
CustomerName = customer?.FormatUserName(_customerSettings.CustomerNameFormat),
Title = pr.Title,
ReviewText = pr.ReviewText,
diff --git a/src/Web/Grand.Web/Models/Blogs/BlogPostTagListModel.cs b/src/Web/Grand.Web/Models/Blogs/BlogPostTagListModel.cs
index dba6d8fdb..7bd62cd02 100644
--- a/src/Web/Grand.Web/Models/Blogs/BlogPostTagListModel.cs
+++ b/src/Web/Grand.Web/Models/Blogs/BlogPostTagListModel.cs
@@ -14,7 +14,7 @@ public class BlogPostTagListModel : BaseModel
return GetFontSize(blogPostTag.BlogPostCount, mean, stdDev);
}
- protected int GetFontSize(double weight, double mean, double stdDev)
+ protected static int GetFontSize(double weight, double mean, double stdDev)
{
var factor = weight - mean;
@@ -29,7 +29,7 @@ public class BlogPostTagListModel : BaseModel
75;
}
- protected double Mean(IEnumerable<double> values)
+ protected static double Mean(IEnumerable<double> values)
{
double sum = 0;
var count = 0;
@@ -43,7 +43,7 @@ public class BlogPostTagListModel : BaseModel
return sum / count;
}
- protected double StdDev(IEnumerable<double> values, out double mean)
+ protected static double StdDev(IEnumerable<double> values, out double mean)
{
mean = Mean(values);
double sumOfDiffSquares = 0;
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/Selector_Currency.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/Selector_Currency.cshtml
index 9303ba8b3..a77e4ca36 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/Selector_Currency.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/Selector_Currency.cshtml
@@ -32,7 +32,7 @@
Value = Url.RouteUrl("ChangeCurrency", new { currencyCode = x.CurrencyCode, returnUrl }),
Selected = x.Id.Equals(contextAccessor.WorkContext.WorkingCurrency.Id)
});
- <b-dropdown class="mr-2" text="@currencies.FirstOrDefault(x => x.Selected).Text">
+ <b-dropdown class="mr-2" text="@currencies.FirstOrDefault(x => x.Selected)?.Text">
@foreach (var item in currencies)
{
var className = item.Selected ? "active" : "";