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.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Minor improvements (#467)
Krzysztof Pajakb1a94ce36d9e
diff --git a/src/API/Grand.Api/ApiExplorer/MetadataApiDescriptionProvider.cs b/src/API/Grand.Api/ApiExplorer/MetadataApiDescriptionProvider.csindex 334a1ccd0..ffadf7e8b 100644--- a/src/API/Grand.Api/ApiExplorer/MetadataApiDescriptionProvider.cs+++ b/src/API/Grand.Api/ApiExplorer/MetadataApiDescriptionProvider.cs@@ -58,10 +58,7 @@ public class MetadataApiDescriptionProvider : IApiDescriptionProvider/// <inheritdoc />public void OnProvidersExecuting(ApiDescriptionProviderContext context){- if (context == null)- {- throw new ArgumentNullException(nameof(context));- }+ ArgumentNullException.ThrowIfNull(context);foreach (var action in context.Actions.OfType<ControllerActionDescriptor>()){diff --git a/src/API/Grand.Api/Filters/AuthorizeApiAdminAttribute.cs b/src/API/Grand.Api/Filters/AuthorizeApiAdminAttribute.csindex ea69068b2..c5f044c0b 100644--- a/src/API/Grand.Api/Filters/AuthorizeApiAdminAttribute.cs+++ b/src/API/Grand.Api/Filters/AuthorizeApiAdminAttribute.cs@@ -61,9 +61,7 @@ namespace Grand.Api.Filters/// <param name="filterContext">Authorization filter context</param>public async Task OnAuthorizationAsync(AuthorizationFilterContext filterContext){-- if (filterContext == null)- throw new ArgumentNullException(nameof(filterContext));+ ArgumentNullException.ThrowIfNull(filterContext);//check whether this filter has been overridden for the actionvar actionFilter = filterContext.ActionDescriptor.FilterDescriptorsdiff --git a/src/Business/Grand.Business.Authentication/Services/CookieAuthenticationService.cs b/src/Business/Grand.Business.Authentication/Services/CookieAuthenticationService.csindex 276dafd6d..699547801 100644--- a/src/Business/Grand.Business.Authentication/Services/CookieAuthenticationService.cs+++ b/src/Business/Grand.Business.Authentication/Services/CookieAuthenticationService.cs@@ -74,8 +74,7 @@ namespace Grand.Business.Authentication.Services/// <param name="isPersistent">Whether the authentication session is persisted across multiple requests</param>public virtual async Task SignIn(Customer customer, bool isPersistent){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);//create claims for customer's username and emailvar claims = new List<Claim>();diff --git a/src/Business/Grand.Business.Authentication/Services/ExternalAuthenticationService.cs b/src/Business/Grand.Business.Authentication/Services/ExternalAuthenticationService.csindex b10e12227..ebc385dc7 100644--- a/src/Business/Grand.Business.Authentication/Services/ExternalAuthenticationService.cs+++ b/src/Business/Grand.Business.Authentication/Services/ExternalAuthenticationService.cs@@ -252,8 +252,7 @@ namespace Grand.Business.Authentication.Services/// <returns>Result of an authentication</returns>public virtual async Task<IActionResult> Authenticate(ExternalAuthParam parameters, string returnUrl = null){- if (parameters == null)- throw new ArgumentNullException(nameof(parameters));+ ArgumentNullException.ThrowIfNull(parameters);if (!AuthenticationProviderIsAvailable(parameters.ProviderSystemName))return Error(new[] { "External authentication method cannot be loaded" });@@ -279,8 +278,7 @@ namespace Grand.Business.Authentication.Services/// <param name="parameters">External authentication parameters</param>public virtual async Task AssociateCustomer(Customer customer, ExternalAuthParam parameters){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);var externalAuthenticationRecord = new ExternalAuthentication {CustomerId = customer.Id,@@ -301,8 +299,7 @@ namespace Grand.Business.Authentication.Services/// <returns>Customer</returns>public virtual async Task<Customer> GetCustomer(ExternalAuthParam parameters){- if (parameters == null)- throw new ArgumentNullException(nameof(parameters));+ ArgumentNullException.ThrowIfNull(parameters);var associationRecord = (from q in _externalAuthenticationRecordRepository.Tablewhere q.ExternalIdentifier.ToLowerInvariant() == parameters.Identifier@@ -317,8 +314,8 @@ namespace Grand.Business.Authentication.Servicespublic virtual async Task<IList<ExternalAuthentication>> GetExternalIdentifiers(Customer customer){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);+var query = from p in _externalAuthenticationRecordRepository.Tablewhere p.CustomerId == customer.Idselect p;@@ -331,8 +328,7 @@ namespace Grand.Business.Authentication.Services/// <param name="externalAuthentication">External authentication</param>public virtual async Task DeleteExternalAuthentication(ExternalAuthentication externalAuthentication){- if (externalAuthentication == null)- throw new ArgumentNullException(nameof(externalAuthentication));+ ArgumentNullException.ThrowIfNull(externalAuthentication);await _externalAuthenticationRecordRepository.DeleteAsync(externalAuthentication);}diff --git a/src/Business/Grand.Business.Catalog/Services/Brands/BrandLayoutService.cs b/src/Business/Grand.Business.Catalog/Services/Brands/BrandLayoutService.csindex d97750220..407fce196 100644--- a/src/Business/Grand.Business.Catalog/Services/Brands/BrandLayoutService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Brands/BrandLayoutService.cs@@ -74,8 +74,7 @@ namespace Grand.Business.Catalog.Services.Brands/// <param name="brandLayout">Brand layout</param>public virtual async Task InsertBrandLayout(BrandLayout brandLayout){- if (brandLayout == null)- throw new ArgumentNullException(nameof(brandLayout));+ ArgumentNullException.ThrowIfNull(brandLayout);await _brandLayoutRepository.InsertAsync(brandLayout);@@ -92,8 +91,7 @@ namespace Grand.Business.Catalog.Services.Brands/// <param name="brandLayout">Brand layout</param>public virtual async Task UpdateBrandLayout(BrandLayout brandLayout){- if (brandLayout == null)- throw new ArgumentNullException(nameof(brandLayout));+ ArgumentNullException.ThrowIfNull(brandLayout);await _brandLayoutRepository.UpdateAsync(brandLayout);@@ -110,8 +108,7 @@ namespace Grand.Business.Catalog.Services.Brands/// <param name="brandLayout">Brand layout</param>public virtual async Task DeleteBrandLayout(BrandLayout brandLayout){- if (brandLayout == null)- throw new ArgumentNullException(nameof(brandLayout));+ ArgumentNullException.ThrowIfNull(brandLayout);await _brandLayoutRepository.DeleteAsync(brandLayout);diff --git a/src/Business/Grand.Business.Catalog/Services/Brands/BrandService.cs b/src/Business/Grand.Business.Catalog/Services/Brands/BrandService.csindex c3d03ec19..2b77811fb 100644--- a/src/Business/Grand.Business.Catalog/Services/Brands/BrandService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Brands/BrandService.cs@@ -110,8 +110,7 @@ namespace Grand.Business.Catalog.Services.Brands/// <param name="brand">Brand</param>public virtual async Task InsertBrand(Brand brand){- if (brand == null)- throw new ArgumentNullException(nameof(brand));+ ArgumentNullException.ThrowIfNull(brand);await _brandRepository.InsertAsync(brand);@@ -128,8 +127,7 @@ namespace Grand.Business.Catalog.Services.Brands/// <param name="brand">Brand</param>public virtual async Task UpdateBrand(Brand brand){- if (brand == null)- throw new ArgumentNullException(nameof(brand));+ ArgumentNullException.ThrowIfNull(brand);await _brandRepository.UpdateAsync(brand);@@ -145,8 +143,7 @@ namespace Grand.Business.Catalog.Services.Brands/// <param name="brand">Brand</param>public virtual async Task DeleteBrand(Brand brand){- if (brand == null)- throw new ArgumentNullException(nameof(brand));+ ArgumentNullException.ThrowIfNull(brand);await _cacheBase.RemoveByPrefix(CacheKey.BRANDS_PATTERN_KEY);diff --git a/src/Business/Grand.Business.Catalog/Services/Categories/CategoryLayoutService.cs b/src/Business/Grand.Business.Catalog/Services/Categories/CategoryLayoutService.csindex 1f42f5daf..e84707fbc 100644--- a/src/Business/Grand.Business.Catalog/Services/Categories/CategoryLayoutService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Categories/CategoryLayoutService.cs@@ -74,8 +74,7 @@ namespace Grand.Business.Catalog.Services.Categories/// <param name="categoryLayout">Category layout</param>public virtual async Task InsertCategoryLayout(CategoryLayout categoryLayout){- if (categoryLayout == null)- throw new ArgumentNullException(nameof(categoryLayout));+ ArgumentNullException.ThrowIfNull(categoryLayout);await _categoryLayoutRepository.InsertAsync(categoryLayout);@@ -92,8 +91,7 @@ namespace Grand.Business.Catalog.Services.Categories/// <param name="categoryLayout">Category layout</param>public virtual async Task UpdateCategoryLayout(CategoryLayout categoryLayout){- if (categoryLayout == null)- throw new ArgumentNullException(nameof(categoryLayout));+ ArgumentNullException.ThrowIfNull(categoryLayout);await _categoryLayoutRepository.UpdateAsync(categoryLayout);@@ -110,8 +108,7 @@ namespace Grand.Business.Catalog.Services.Categories/// <param name="categoryLayout">Category layout</param>public virtual async Task DeleteCategoryLayout(CategoryLayout categoryLayout){- if (categoryLayout == null)- throw new ArgumentNullException(nameof(categoryLayout));+ ArgumentNullException.ThrowIfNull(categoryLayout);await _categoryLayoutRepository.DeleteAsync(categoryLayout);diff --git a/src/Business/Grand.Business.Catalog/Services/Categories/CategoryService.cs b/src/Business/Grand.Business.Catalog/Services/Categories/CategoryService.csindex 4c3d98531..aeb1f53c5 100644--- a/src/Business/Grand.Business.Catalog/Services/Categories/CategoryService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Categories/CategoryService.cs@@ -397,8 +397,7 @@ namespace Grand.Business.Catalog.Services.Categories/// <param name="category">Category</param>public virtual async Task InsertCategory(Category category){- if (category == null)- throw new ArgumentNullException(nameof(category));+ ArgumentNullException.ThrowIfNull(category);await _categoryRepository.InsertAsync(category);@@ -416,8 +415,7 @@ namespace Grand.Business.Catalog.Services.Categories/// <param name="category">Category</param>public virtual async Task UpdateCategory(Category category){- if (category == null)- throw new ArgumentNullException(nameof(category));+ ArgumentNullException.ThrowIfNull(category);if (string.IsNullOrEmpty(category.ParentCategoryId))category.ParentCategoryId = "";@@ -448,8 +446,7 @@ namespace Grand.Business.Catalog.Services.Categories/// <param name="category">Category</param>public virtual async Task DeleteCategory(Category category){- if (category == null)- throw new ArgumentNullException(nameof(category));+ ArgumentNullException.ThrowIfNull(category);//reset a "Parent category" property of all child subcategoriesvar subcategories = await GetAllCategoriesByParentCategoryId(category.Id, true);diff --git a/src/Business/Grand.Business.Catalog/Services/Categories/ProductCategoryService.cs b/src/Business/Grand.Business.Catalog/Services/Categories/ProductCategoryService.csindex 03be306bb..e4c90c998 100644--- a/src/Business/Grand.Business.Catalog/Services/Categories/ProductCategoryService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Categories/ProductCategoryService.cs@@ -103,8 +103,7 @@ namespace Grand.Business.Catalog.Services.Categories/// <param name="productId">Product ident</param>public virtual async Task InsertProductCategory(ProductCategory productCategory, string productId){- if (productCategory == null)- throw new ArgumentNullException(nameof(productCategory));+ ArgumentNullException.ThrowIfNull(productCategory);await _productRepository.AddToSet(productId, x => x.ProductCategories, productCategory);@@ -123,8 +122,7 @@ namespace Grand.Business.Catalog.Services.Categories/// <param name="productId">Product ident</param>public virtual async Task UpdateProductCategory(ProductCategory productCategory, string productId){- if (productCategory == null)- throw new ArgumentNullException(nameof(productCategory));+ ArgumentNullException.ThrowIfNull(productCategory);await _productRepository.UpdateToSet(productId, x => x.ProductCategories, z => z.Id, productCategory.Id, productCategory);@@ -142,8 +140,7 @@ namespace Grand.Business.Catalog.Services.Categories/// <param name="productId">Product ident</param>public virtual async Task DeleteProductCategory(ProductCategory productCategory, string productId){- if (productCategory == null)- throw new ArgumentNullException(nameof(productCategory));+ ArgumentNullException.ThrowIfNull(productCategory);await _productRepository.PullFilter(productId, x => x.ProductCategories, z => z.Id, productCategory.Id);diff --git a/src/Business/Grand.Business.Catalog/Services/Collections/CollectionLayoutService.cs b/src/Business/Grand.Business.Catalog/Services/Collections/CollectionLayoutService.csindex e980c1397..5a35286a7 100644--- a/src/Business/Grand.Business.Catalog/Services/Collections/CollectionLayoutService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Collections/CollectionLayoutService.cs@@ -74,8 +74,7 @@ namespace Grand.Business.Catalog.Services.Collections/// <param name="collectionLayout">Collection layout</param>public virtual async Task InsertCollectionLayout(CollectionLayout collectionLayout){- if (collectionLayout == null)- throw new ArgumentNullException(nameof(collectionLayout));+ ArgumentNullException.ThrowIfNull(collectionLayout);await _collectionLayoutRepository.InsertAsync(collectionLayout);@@ -92,8 +91,7 @@ namespace Grand.Business.Catalog.Services.Collections/// <param name="collectionLayout">Collection layout</param>public virtual async Task UpdateCollectionLayout(CollectionLayout collectionLayout){- if (collectionLayout == null)- throw new ArgumentNullException(nameof(collectionLayout));+ ArgumentNullException.ThrowIfNull(collectionLayout);await _collectionLayoutRepository.UpdateAsync(collectionLayout);@@ -110,8 +108,7 @@ namespace Grand.Business.Catalog.Services.Collections/// <param name="collectionLayout">Collection layout</param>public virtual async Task DeleteCollectionLayout(CollectionLayout collectionLayout){- if (collectionLayout == null)- throw new ArgumentNullException(nameof(collectionLayout));+ ArgumentNullException.ThrowIfNull(collectionLayout);await _collectionLayoutRepository.DeleteAsync(collectionLayout);diff --git a/src/Business/Grand.Business.Catalog/Services/Collections/CollectionService.cs b/src/Business/Grand.Business.Catalog/Services/Collections/CollectionService.csindex 0f7b9a333..542c5707a 100644--- a/src/Business/Grand.Business.Catalog/Services/Collections/CollectionService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Collections/CollectionService.cs@@ -136,8 +136,7 @@ namespace Grand.Business.Catalog.Services.Collections/// <param name="collection">Collection</param>public virtual async Task InsertCollection(Collection collection){- if (collection == null)- throw new ArgumentNullException(nameof(collection));+ ArgumentNullException.ThrowIfNull(collection);await _collectionRepository.InsertAsync(collection);@@ -155,8 +154,7 @@ namespace Grand.Business.Catalog.Services.Collections/// <param name="collection">Collection</param>public virtual async Task UpdateCollection(Collection collection){- if (collection == null)- throw new ArgumentNullException(nameof(collection));+ ArgumentNullException.ThrowIfNull(collection);await _collectionRepository.UpdateAsync(collection);@@ -173,8 +171,7 @@ namespace Grand.Business.Catalog.Services.Collections/// <param name="collection">Collection</param>public virtual async Task DeleteCollection(Collection collection){- if (collection == null)- throw new ArgumentNullException(nameof(collection));+ ArgumentNullException.ThrowIfNull(collection);await _cacheBase.RemoveByPrefix(CacheKey.COLLECTIONS_PATTERN_KEY);diff --git a/src/Business/Grand.Business.Catalog/Services/Collections/ProductCollectionService.cs b/src/Business/Grand.Business.Catalog/Services/Collections/ProductCollectionService.csindex f9b1e0be9..e81c8fcdf 100644--- a/src/Business/Grand.Business.Catalog/Services/Collections/ProductCollectionService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Collections/ProductCollectionService.cs@@ -104,8 +104,7 @@ namespace Grand.Business.Catalog.Services.Collections/// <param name="productId">Product ident</param>public virtual async Task InsertProductCollection(ProductCollection productCollection, string productId){- if (productCollection == null)- throw new ArgumentNullException(nameof(productCollection));+ ArgumentNullException.ThrowIfNull(productCollection);await _productRepository.AddToSet(productId, x => x.ProductCollections, productCollection);@@ -124,8 +123,7 @@ namespace Grand.Business.Catalog.Services.Collections/// <param name="productId">Product id</param>public virtual async Task UpdateProductCollection(ProductCollection productCollection, string productId){- if (productCollection == null)- throw new ArgumentNullException(nameof(productCollection));+ ArgumentNullException.ThrowIfNull(productCollection);await _productRepository.UpdateToSet(productId, x => x.ProductCollections, z => z.Id, productCollection.Id, productCollection);@@ -144,8 +142,7 @@ namespace Grand.Business.Catalog.Services.Collections/// <param name="productId">Product id</param>public virtual async Task DeleteProductCollection(ProductCollection productCollection, string productId){- if (productCollection == null)- throw new ArgumentNullException(nameof(productCollection));+ ArgumentNullException.ThrowIfNull(productCollection);await _productRepository.PullFilter(productId, x => x.ProductCollections, z => z.Id, productCollection.Id);diff --git a/src/Business/Grand.Business.Catalog/Services/Directory/MeasureService.cs b/src/Business/Grand.Business.Catalog/Services/Directory/MeasureService.csindex 55ac020b5..702a0cdf8 100644--- a/src/Business/Grand.Business.Catalog/Services/Directory/MeasureService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Directory/MeasureService.cs@@ -104,8 +104,7 @@ namespace Grand.Business.Catalog.Services.Directory/// <param name="measure">Measure dimension</param>public virtual async Task InsertMeasureDimension(MeasureDimension measure){- if (measure == null)- throw new ArgumentNullException(nameof(measure));+ ArgumentNullException.ThrowIfNull(measure);await _measureDimensionRepository.InsertAsync(measure);@@ -121,8 +120,7 @@ namespace Grand.Business.Catalog.Services.Directory/// <param name="measure">Measure dimension</param>public virtual async Task UpdateMeasureDimension(MeasureDimension measure){- if (measure == null)- throw new ArgumentNullException(nameof(measure));+ ArgumentNullException.ThrowIfNull(measure);await _measureDimensionRepository.UpdateAsync(measure);@@ -138,8 +136,7 @@ namespace Grand.Business.Catalog.Services.Directory/// <param name="measureDimension">Measure dimension</param>public virtual async Task DeleteMeasureDimension(MeasureDimension measureDimension){- if (measureDimension == null)- throw new ArgumentNullException(nameof(measureDimension));+ ArgumentNullException.ThrowIfNull(measureDimension);await _measureDimensionRepository.DeleteAsync(measureDimension);@@ -160,11 +157,8 @@ namespace Grand.Business.Catalog.Services.Directorypublic virtual async Task<double> ConvertDimension(double value,MeasureDimension sourceMeasureDimension, MeasureDimension targetMeasureDimension, bool round = true){- if (sourceMeasureDimension == null)- throw new ArgumentNullException(nameof(sourceMeasureDimension));-- if (targetMeasureDimension == null)- throw new ArgumentNullException(nameof(targetMeasureDimension));+ ArgumentNullException.ThrowIfNull(sourceMeasureDimension);+ ArgumentNullException.ThrowIfNull(targetMeasureDimension);var result = value;if (result != 0 && sourceMeasureDimension.Id != targetMeasureDimension.Id)@@ -186,8 +180,7 @@ namespace Grand.Business.Catalog.Services.Directorypublic virtual async Task<double> ConvertToPrimaryMeasureDimension(double value,MeasureDimension sourceMeasureDimension){- if (sourceMeasureDimension == null)- throw new ArgumentNullException(nameof(sourceMeasureDimension));+ ArgumentNullException.ThrowIfNull(sourceMeasureDimension);var result = value;var baseDimensionIn = await GetMeasureDimensionById(_measureSettings.BaseDimensionId);@@ -208,8 +201,7 @@ namespace Grand.Business.Catalog.Services.Directorypublic virtual async Task<double> ConvertFromPrimaryMeasureDimension(double value,MeasureDimension targetMeasureDimension){- if (targetMeasureDimension == null)- throw new ArgumentNullException(nameof(targetMeasureDimension));+ ArgumentNullException.ThrowIfNull(targetMeasureDimension);var result = value;var baseDimensionIn = await GetMeasureDimensionById(_measureSettings.BaseDimensionId);@@ -272,8 +264,7 @@ namespace Grand.Business.Catalog.Services.Directory/// <param name="measure">Measure weight</param>public virtual async Task InsertMeasureWeight(MeasureWeight measure){- if (measure == null)- throw new ArgumentNullException(nameof(measure));+ ArgumentNullException.ThrowIfNull(measure);await _measureWeightRepository.InsertAsync(measure);@@ -289,8 +280,7 @@ namespace Grand.Business.Catalog.Services.Directory/// <param name="measure">Measure weight</param>public virtual async Task UpdateMeasureWeight(MeasureWeight measure){- if (measure == null)- throw new ArgumentNullException(nameof(measure));+ ArgumentNullException.ThrowIfNull(measure);await _measureWeightRepository.UpdateAsync(measure);@@ -306,8 +296,7 @@ namespace Grand.Business.Catalog.Services.Directory/// <param name="measureWeight">Measure weight</param>public virtual async Task DeleteMeasureWeight(MeasureWeight measureWeight){- if (measureWeight == null)- throw new ArgumentNullException(nameof(measureWeight));+ ArgumentNullException.ThrowIfNull(measureWeight);await _measureWeightRepository.DeleteAsync(measureWeight);@@ -328,11 +317,8 @@ namespace Grand.Business.Catalog.Services.Directorypublic virtual async Task<double> ConvertWeight(double value,MeasureWeight sourceMeasureWeight, MeasureWeight targetMeasureWeight, bool round = true){- if (sourceMeasureWeight == null)- throw new ArgumentNullException(nameof(sourceMeasureWeight));-- if (targetMeasureWeight == null)- throw new ArgumentNullException(nameof(targetMeasureWeight));+ ArgumentNullException.ThrowIfNull(sourceMeasureWeight);+ ArgumentNullException.ThrowIfNull(targetMeasureWeight);var result = value;if (result != 0 && sourceMeasureWeight.Id != targetMeasureWeight.Id)@@ -353,8 +339,7 @@ namespace Grand.Business.Catalog.Services.Directory/// <returns>Converted value</returns>public virtual async Task<double> ConvertToPrimaryMeasureWeight(double value, MeasureWeight sourceMeasureWeight){- if (sourceMeasureWeight == null)- throw new ArgumentNullException(nameof(sourceMeasureWeight));+ ArgumentNullException.ThrowIfNull(sourceMeasureWeight);var result = value;var baseWeightIn = await GetMeasureWeightById(_measureSettings.BaseWeightId);@@ -375,8 +360,7 @@ namespace Grand.Business.Catalog.Services.Directorypublic virtual async Task<double> ConvertFromPrimaryMeasureWeight(double value,MeasureWeight targetMeasureWeight){- if (targetMeasureWeight == null)- throw new ArgumentNullException(nameof(targetMeasureWeight));+ ArgumentNullException.ThrowIfNull(targetMeasureWeight);var result = value;var baseWeightIn = await GetMeasureWeightById(_measureSettings.BaseWeightId);@@ -427,8 +411,7 @@ namespace Grand.Business.Catalog.Services.Directory/// <param name="measure">Measure unit</param>public virtual async Task InsertMeasureUnit(MeasureUnit measure){- if (measure == null)- throw new ArgumentNullException(nameof(measure));+ ArgumentNullException.ThrowIfNull(measure);await _measureUnitRepository.InsertAsync(measure);@@ -444,8 +427,7 @@ namespace Grand.Business.Catalog.Services.Directory/// <param name="measure">Measure unit</param>public virtual async Task UpdateMeasureUnit(MeasureUnit measure){- if (measure == null)- throw new ArgumentNullException(nameof(measure));+ ArgumentNullException.ThrowIfNull(measure);await _measureUnitRepository.UpdateAsync(measure);@@ -461,8 +443,7 @@ namespace Grand.Business.Catalog.Services.Directory/// <param name="measureUnit">Measure unit</param>public virtual async Task DeleteMeasureUnit(MeasureUnit measureUnit){- if (measureUnit == null)- throw new ArgumentNullException(nameof(measureUnit));+ ArgumentNullException.ThrowIfNull(measureUnit);//deleteawait _measureUnitRepository.DeleteAsync(measureUnit);diff --git a/src/Business/Grand.Business.Catalog/Services/Directory/SearchTermService.cs b/src/Business/Grand.Business.Catalog/Services/Directory/SearchTermService.csindex 1d10e8d60..bab95e591 100644--- a/src/Business/Grand.Business.Catalog/Services/Directory/SearchTermService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Directory/SearchTermService.cs@@ -39,8 +39,7 @@ namespace Grand.Business.Catalog.Services.Directory/// <param name="searchTerm">Search term</param>public virtual async Task DeleteSearchTerm(SearchTerm searchTerm){- if (searchTerm == null)- throw new ArgumentNullException(nameof(searchTerm));+ ArgumentNullException.ThrowIfNull(searchTerm);await _searchTermRepository.DeleteAsync(searchTerm);@@ -104,8 +103,7 @@ namespace Grand.Business.Catalog.Services.Directory/// <param name="searchTerm">Search term</param>public virtual async Task InsertSearchTerm(SearchTerm searchTerm){- if (searchTerm == null)- throw new ArgumentNullException(nameof(searchTerm));+ ArgumentNullException.ThrowIfNull(searchTerm);await _searchTermRepository.InsertAsync(searchTerm);@@ -119,8 +117,7 @@ namespace Grand.Business.Catalog.Services.Directory/// <param name="searchTerm">Search term</param>public virtual async Task UpdateSearchTerm(SearchTerm searchTerm){- if (searchTerm == null)- throw new ArgumentNullException(nameof(searchTerm));+ ArgumentNullException.ThrowIfNull(searchTerm);await _searchTermRepository.UpdateAsync(searchTerm);diff --git a/src/Business/Grand.Business.Catalog/Services/Discounts/DiscountService.cs b/src/Business/Grand.Business.Catalog/Services/Discounts/DiscountService.csindex 57da598f5..2598d4d06 100644--- a/src/Business/Grand.Business.Catalog/Services/Discounts/DiscountService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Discounts/DiscountService.cs@@ -105,7 +105,7 @@ namespace Grand.Business.Catalog.Services.Discounts}if (!string.IsNullOrEmpty(couponCode)){- var coupon = _discountCouponRepository.Table.FirstOrDefault(x => x.CouponCode == couponCode);+ var coupon = await _discountCouponRepository.GetOneAsync(x => x.CouponCode == couponCode);if (coupon != null)query = query.Where(d => d.Id == coupon.DiscountId);}@@ -135,9 +135,8 @@ namespace Grand.Business.Catalog.Services.Discounts/// <param name="discount">Discount</param>public virtual async Task InsertDiscount(Discount discount){- if (discount == null)- throw new ArgumentNullException(nameof(discount));-+ ArgumentNullException.ThrowIfNull(discount);+await _discountRepository.InsertAsync(discount);await _cacheBase.RemoveByPrefix(CacheKey.DISCOUNTS_PATTERN_KEY);@@ -152,8 +151,7 @@ namespace Grand.Business.Catalog.Services.Discounts/// <param name="discount">Discount</param>public virtual async Task UpdateDiscount(Discount discount){- if (discount == null)- throw new ArgumentNullException(nameof(discount));+ ArgumentNullException.ThrowIfNull(discount);await _discountRepository.UpdateAsync(discount);@@ -169,8 +167,7 @@ namespace Grand.Business.Catalog.Services.Discounts/// <param name="discount">Discount</param>public virtual async Task DeleteDiscount(Discount discount){- if (discount == null)- throw new ArgumentNullException(nameof(discount));+ ArgumentNullException.ThrowIfNull(discount);var usageHistory = await GetAllDiscountUsageHistory(discount.Id);if (usageHistory.Count > 0)@@ -224,9 +221,7 @@ namespace Grand.Business.Catalog.Services.Discountsif (string.IsNullOrWhiteSpace(couponCode))return null;- var query = _discountCouponRepository.Table.Where(x => x.CouponCode == couponCode).ToList();-- var coupon = query.FirstOrDefault();+ var coupon = await _discountCouponRepository.GetOneAsync(x => x.CouponCode == couponCode);if (coupon == null)return null;@@ -293,8 +288,7 @@ namespace Grand.Business.Catalog.Services.Discounts/// <returns></returns>public virtual async Task<DiscountCoupon> GetDiscountCodeByCode(string couponCode){- var query = await Task.FromResult(_discountCouponRepository.Table.Where(x => x.CouponCode == couponCode).ToList());- return query.FirstOrDefault();+ return await _discountCouponRepository.GetOneAsync(x => x.CouponCode == couponCode);}@@ -367,8 +361,7 @@ namespace Grand.Business.Catalog.Services.Discounts/// <returns>Discount validation result</returns>public virtual async Task<DiscountValidationResult> ValidateDiscount(Discount discount, Customer customer, Currency currency){- if (discount == null)- throw new ArgumentNullException(nameof(discount));+ ArgumentNullException.ThrowIfNull(discount);string[] couponCodesToValidate = null;if (customer != null)@@ -403,11 +396,8 @@ namespace Grand.Business.Catalog.Services.Discounts/// <returns>Discount validation result</returns>public virtual async Task<DiscountValidationResult> ValidateDiscount(Discount discount, Customer customer, Currency currency, string[] couponCodesToValidate){- if (discount == null)- throw new ArgumentNullException(nameof(discount));-- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(discount);+ ArgumentNullException.ThrowIfNull(customer);var result = new DiscountValidationResult();@@ -585,8 +575,7 @@ namespace Grand.Business.Catalog.Services.Discounts/// <param name="discountUsageHistory">Discount usage history item</param>public virtual async Task InsertDiscountUsageHistory(DiscountUsageHistory discountUsageHistory){- if (discountUsageHistory == null)- throw new ArgumentNullException(nameof(discountUsageHistory));+ ArgumentNullException.ThrowIfNull(discountUsageHistory);await _discountUsageHistoryRepository.InsertAsync(discountUsageHistory);@@ -605,8 +594,7 @@ namespace Grand.Business.Catalog.Services.Discounts/// <param name="discountUsageHistory">Discount usage history item</param>public virtual async Task UpdateDiscountUsageHistory(DiscountUsageHistory discountUsageHistory){- if (discountUsageHistory == null)- throw new ArgumentNullException(nameof(discountUsageHistory));+ ArgumentNullException.ThrowIfNull(discountUsageHistory);await _discountUsageHistoryRepository.UpdateAsync(discountUsageHistory);@@ -622,8 +610,7 @@ namespace Grand.Business.Catalog.Services.Discounts/// <param name="discountUsageHistory">Discount usage history record</param>public virtual async Task DeleteDiscountUsageHistory(DiscountUsageHistory discountUsageHistory){- if (discountUsageHistory == null)- throw new ArgumentNullException(nameof(discountUsageHistory));+ ArgumentNullException.ThrowIfNull(discountUsageHistory);await _discountUsageHistoryRepository.DeleteAsync(discountUsageHistory);@@ -643,8 +630,7 @@ namespace Grand.Business.Catalog.Services.Discounts/// <param name="product">Product</param>public virtual async Task<double> GetDiscountAmount(Discount discount, Customer customer, Currency currency, Product product, double amount){- if (discount == null)- throw new ArgumentNullException(nameof(discount));+ ArgumentNullException.ThrowIfNull(discount);//calculate discount amountdouble result;@@ -687,8 +673,7 @@ namespace Grand.Business.Catalog.Services.DiscountsIList<ApplyDiscount> discounts, Customer customer, Currency currency, Product product,double amount){- if (discounts == null)- throw new ArgumentNullException(nameof(discounts));+ ArgumentNullException.ThrowIfNull(discounts);var appliedDiscount = new List<ApplyDiscount>();double discountAmount = 0;diff --git a/src/Business/Grand.Business.Catalog/Services/Prices/PricingService.cs b/src/Business/Grand.Business.Catalog/Services/Prices/PricingService.csindex a2e3286a3..f01741132 100644--- a/src/Business/Grand.Business.Catalog/Services/Prices/PricingService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Prices/PricingService.cs@@ -323,9 +323,8 @@ namespace Grand.Business.Catalog.Services.Pricesprotected virtual async Task<(double discountAmount, List<ApplyDiscount> appliedDiscounts)> GetDiscountAmount(Product product,Customer customer, Currency currency, double productPriceWithoutDiscount){- if (product == null)- throw new ArgumentNullException(nameof(product));-+ ArgumentNullException.ThrowIfNull(product);+//we don't apply discounts to products with price entered by a customerif (product.EnteredPrice)return (0, null);@@ -393,8 +392,7 @@ namespace Grand.Business.Catalog.Services.PricesDateTime? rentalStartDate,DateTime? rentalEndDate){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);double discountAmount = 0;var appliedDiscounts = new List<ApplyDiscount>();@@ -482,8 +480,7 @@ namespace Grand.Business.Catalog.Services.Pricespublic virtual async Task<(double unitprice, double discountAmount, List<ApplyDiscount> appliedDiscounts)> GetUnitPrice(ShoppingCartItem shoppingCartItem,Product product, bool includeDiscounts = true){- if (shoppingCartItem == null)- throw new ArgumentNullException(nameof(shoppingCartItem));+ ArgumentNullException.ThrowIfNull(shoppingCartItem);return await GetUnitPrice(product,_workContext.CurrentCustomer,@@ -522,11 +519,8 @@ namespace Grand.Business.Catalog.Services.PricesDateTime? rentalEndDate,bool includeDiscounts){- if (product == null)- throw new ArgumentNullException(nameof(product));-- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(product);+ ArgumentNullException.ThrowIfNull(customer);double discountAmount = 0;var appliedDiscounts = new List<ApplyDiscount>();@@ -631,8 +625,7 @@ namespace Grand.Business.Catalog.Services.Pricespublic virtual async Task<(double subTotal, double discountAmount, List<ApplyDiscount> appliedDiscounts)> GetSubTotal(ShoppingCartItem shoppingCartItem, Product product,bool includeDiscounts = true){- if (shoppingCartItem == null)- throw new ArgumentNullException(nameof(shoppingCartItem));+ ArgumentNullException.ThrowIfNull(shoppingCartItem);double subTotal;//unit price@@ -687,8 +680,7 @@ namespace Grand.Business.Catalog.Services.Prices/// <returns>Product cost (one item)</returns>public virtual async Task<double> GetProductCost(Product product, IList<CustomAttribute> attributes){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);var cost = product.ProductCost;var attributeValues = product.ParseProductAttributeValues(attributes);@@ -722,8 +714,7 @@ namespace Grand.Business.Catalog.Services.Prices/// <returns>Price adjustment</returns>public virtual async Task<double> GetProductAttributeValuePriceAdjustment(ProductAttributeValue value){- if (value == null)- throw new ArgumentNullException(nameof(value));+ ArgumentNullException.ThrowIfNull(value);double adjustment = 0;switch (value.AttributeValueTypeId)diff --git a/src/Business/Grand.Business.Catalog/Services/Products/AuctionService.cs b/src/Business/Grand.Business.Catalog/Services/Products/AuctionService.csindex 92dafdcb2..8da39d21d 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/AuctionService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/AuctionService.cs@@ -63,8 +63,7 @@ namespace Grand.Business.Catalog.Services.Productspublic virtual async Task InsertBid(Bid bid){- if (bid == null)- throw new ArgumentNullException(nameof(bid));+ ArgumentNullException.ThrowIfNull(bid);await _bidRepository.InsertAsync(bid);await _mediator.EntityInserted(bid);@@ -72,16 +71,14 @@ namespace Grand.Business.Catalog.Services.Productspublic virtual async Task UpdateBid(Bid bid){- if (bid == null)- throw new ArgumentNullException(nameof(bid));+ ArgumentNullException.ThrowIfNull(bid);await _bidRepository.UpdateAsync(bid);await _mediator.EntityUpdated(bid);}public virtual async Task DeleteBid(Bid bid){- if (bid == null)- throw new ArgumentNullException(nameof(bid));+ ArgumentNullException.ThrowIfNull(bid);await _bidRepository.DeleteAsync(bid);await _mediator.EntityDeleted(bid);@@ -167,7 +164,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="orderId">OrderId</param>public virtual async Task CancelBidByOrder(string orderId){- var bid = _bidRepository.Table.FirstOrDefault(x => x.OrderId == orderId);+ var bid = await _bidRepository.GetOneAsync(x => x.OrderId == orderId);if (bid != null){await _bidRepository.DeleteAsync(bid);diff --git a/src/Business/Grand.Business.Catalog/Services/Products/CopyProductService.cs b/src/Business/Grand.Business.Catalog/Services/Products/CopyProductService.csindex 932f60d10..e4609c967 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/CopyProductService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/CopyProductService.cs@@ -48,8 +48,7 @@ namespace Grand.Business.Catalog.Services.Productspublic virtual async Task<Product> CopyProduct(Product product, string newName,bool isPublished = true, bool copyAssociatedProducts = true){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);if (string.IsNullOrEmpty(newName))newName = $"{product.Name} - CopyProduct";diff --git a/src/Business/Grand.Business.Catalog/Services/Products/CustomerGroupProductService.cs b/src/Business/Grand.Business.Catalog/Services/Products/CustomerGroupProductService.csindex 918c564d9..da1a4b018 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/CustomerGroupProductService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/CustomerGroupProductService.cs@@ -32,8 +32,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="customerGroupProduct">Customer group product</param>public virtual async Task DeleteCustomerGroupProduct(CustomerGroupProduct customerGroupProduct){- if (customerGroupProduct == null)- throw new ArgumentNullException(nameof(customerGroupProduct));+ ArgumentNullException.ThrowIfNull(customerGroupProduct);await _customerGroupProductRepository.DeleteAsync(customerGroupProduct);@@ -52,8 +51,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="customerGroupProduct">Customer group product</param>public virtual async Task InsertCustomerGroupProduct(CustomerGroupProduct customerGroupProduct){- if (customerGroupProduct == null)- throw new ArgumentNullException(nameof(customerGroupProduct));+ ArgumentNullException.ThrowIfNull(customerGroupProduct);await _customerGroupProductRepository.InsertAsync(customerGroupProduct);@@ -71,8 +69,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="customerGroupProduct">Customer group product</param>public virtual async Task UpdateCustomerGroupProduct(CustomerGroupProduct customerGroupProduct){- if (customerGroupProduct == null)- throw new ArgumentNullException(nameof(customerGroupProduct));+ ArgumentNullException.ThrowIfNull(customerGroupProduct);await _customerGroupProductRepository.UpdateAsync(customerGroupProduct);diff --git a/src/Business/Grand.Business.Catalog/Services/Products/InventoryManageService.cs b/src/Business/Grand.Business.Catalog/Services/Products/InventoryManageService.csindex 613090535..fd95232b9 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/InventoryManageService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/InventoryManageService.cs@@ -274,8 +274,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="warehouseId">Warehouse ident</param>public virtual async Task AdjustReserved(Product product, int quantityToChange, IList<CustomAttribute> attributes = null, string warehouseId = ""){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);if (quantityToChange == 0)return;@@ -447,8 +446,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="warehouseId"></param>protected virtual async Task ReserveInventory(Product product, int quantity, string warehouseId){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);if (quantity >= 0)throw new ArgumentException("Value must be negative.", nameof(quantity));@@ -491,11 +489,8 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="warehouseId">Warehouse ident</param>protected virtual async Task ReserveInventoryCombination(Product product, ProductAttributeCombination combination, int quantity, string warehouseId){- if (product == null)- throw new ArgumentNullException(nameof(product));-- if (combination == null)- throw new ArgumentNullException(nameof(combination));+ ArgumentNullException.ThrowIfNull(product);+ ArgumentNullException.ThrowIfNull(combination);if (quantity >= 0)throw new ArgumentException("Value must be negative.", nameof(quantity));@@ -549,8 +544,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="warehouseId">Warehouse ident</param>protected virtual async Task UnblockReservedInventory(Product product, int quantity, string warehouseId){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);if (quantity < 0)throw new ArgumentException("Value must be positive.", nameof(quantity));@@ -595,8 +589,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="warehouseId">Warehouse ident</param>protected virtual async Task UnblockReservedInventoryCombination(Product product, ProductAttributeCombination combination, int quantity, string warehouseId){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);if (quantity < 0)throw new ArgumentException("Value must be positive.", nameof(quantity));@@ -645,14 +638,9 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="shipmentItem">Shipment item</param>public virtual async Task BookReservedInventory(Product product, Shipment shipment, ShipmentItem shipmentItem){- if (product == null)- throw new ArgumentNullException(nameof(product));-- if (shipment == null)- throw new ArgumentNullException(nameof(shipment));-- if (shipmentItem == null)- throw new ArgumentNullException(nameof(shipmentItem));+ ArgumentNullException.ThrowIfNull(product);+ ArgumentNullException.ThrowIfNull(shipment);+ ArgumentNullException.ThrowIfNull(shipmentItem);//standard manage stockif (product.ManageInventoryMethodId == ManageInventoryMethod.ManageStock)@@ -697,12 +685,8 @@ namespace Grand.Business.Catalog.Services.Products/// <returns>Quantity reversed</returns>public virtual async Task ReverseBookedInventory(Shipment shipment, ShipmentItem shipmentItem){-- if (shipment == null)- throw new ArgumentNullException(nameof(shipment));-- if (shipmentItem == null)- throw new ArgumentNullException(nameof(shipmentItem));+ ArgumentNullException.ThrowIfNull(shipment);+ ArgumentNullException.ThrowIfNull(shipmentItem);var inventoryJournals = _inventoryJournalRepository.Table.Where(j => j.PositionId == shipmentItem.Id);@@ -726,8 +710,8 @@ namespace Grand.Business.Catalog.Services.Productspublic virtual async Task UpdateStockProduct(Product product, bool mediator = true){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);+if (product.ReservedQuantity < 0)product.ReservedQuantity = 0;diff --git a/src/Business/Grand.Business.Catalog/Services/Products/OutOfStockSubscriptionService.cs b/src/Business/Grand.Business.Catalog/Services/Products/OutOfStockSubscriptionService.csindex 9013f0106..05fbe65bd 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/OutOfStockSubscriptionService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/OutOfStockSubscriptionService.cs@@ -107,8 +107,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="subscription">Subscription</param>public virtual async Task InsertSubscription(OutOfStockSubscription subscription){- if (subscription == null)- throw new ArgumentNullException(nameof(subscription));+ ArgumentNullException.ThrowIfNull(subscription);await _outOfStockSubscriptionRepository.InsertAsync(subscription);@@ -122,8 +121,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="subscription">Subscription</param>public virtual async Task UpdateSubscription(OutOfStockSubscription subscription){- if (subscription == null)- throw new ArgumentNullException(nameof(subscription));+ ArgumentNullException.ThrowIfNull(subscription);await _outOfStockSubscriptionRepository.UpdateAsync(subscription);@@ -136,8 +134,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="subscription">Subscription</param>public virtual async Task DeleteSubscription(OutOfStockSubscription subscription){- if (subscription == null)- throw new ArgumentNullException(nameof(subscription));+ ArgumentNullException.ThrowIfNull(subscription);await _outOfStockSubscriptionRepository.DeleteAsync(subscription);@@ -153,8 +150,7 @@ namespace Grand.Business.Catalog.Services.Products/// <returns>Number of sent email</returns>public virtual async Task SendNotificationsToSubscribers(Product product, string warehouse){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);var subscriptions = await _mediator.Send(new SendNotificationsToSubscribersCommand {Product = product,@@ -174,8 +170,7 @@ namespace Grand.Business.Catalog.Services.Products/// <returns>Number of sent email</returns>public virtual async Task SendNotificationsToSubscribers(Product product, IList<CustomAttribute> attributes, string warehouse){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);var subscriptions = await _mediator.Send(new SendNotificationsToSubscribersCommand {Product = product,diff --git a/src/Business/Grand.Business.Catalog/Services/Products/ProductAttributeService.cs b/src/Business/Grand.Business.Catalog/Services/Products/ProductAttributeService.csindex df79d9489..087bebee6 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/ProductAttributeService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/ProductAttributeService.cs@@ -85,8 +85,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productAttribute">Product attribute</param>public virtual async Task InsertProductAttribute(ProductAttribute productAttribute){- if (productAttribute == null)- throw new ArgumentNullException(nameof(productAttribute));+ ArgumentNullException.ThrowIfNull(productAttribute);await _productAttributeRepository.InsertAsync(productAttribute);@@ -106,8 +105,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productAttribute">Product attribute</param>public virtual async Task UpdateProductAttribute(ProductAttribute productAttribute){- if (productAttribute == null)- throw new ArgumentNullException(nameof(productAttribute));+ ArgumentNullException.ThrowIfNull(productAttribute);await _productAttributeRepository.UpdateAsync(productAttribute);@@ -127,8 +125,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productAttribute">Product attribute</param>public virtual async Task DeleteProductAttribute(ProductAttribute productAttribute){- if (productAttribute == null)- throw new ArgumentNullException(nameof(productAttribute));+ ArgumentNullException.ThrowIfNull(productAttribute);//delete from all product collectionsawait _productRepository.PullFilter(string.Empty, x => x.ProductAttributeMappings, z => z.ProductAttributeId, productAttribute.Id);@@ -158,8 +155,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productId">Product ident</param>public virtual async Task DeleteProductAttributeMapping(ProductAttributeMapping productAttributeMapping, string productId){- if (productAttributeMapping == null)- throw new ArgumentNullException(nameof(productAttributeMapping));+ ArgumentNullException.ThrowIfNull(productAttributeMapping);await _productRepository.PullFilter(productId, x => x.ProductAttributeMappings, z => z.Id, productAttributeMapping.Id);@@ -177,8 +173,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productId">Product ident</param>public virtual async Task InsertProductAttributeMapping(ProductAttributeMapping productAttributeMapping, string productId){- if (productAttributeMapping == null)- throw new ArgumentNullException(nameof(productAttributeMapping));+ ArgumentNullException.ThrowIfNull(productAttributeMapping);await _productRepository.AddToSet(productId, x => x.ProductAttributeMappings, productAttributeMapping);@@ -197,8 +192,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="values">Update values</param>public virtual async Task UpdateProductAttributeMapping(ProductAttributeMapping productAttributeMapping, string productId, bool values = false){- if (productAttributeMapping == null)- throw new ArgumentNullException(nameof(productAttributeMapping));+ ArgumentNullException.ThrowIfNull(productAttributeMapping);await _productRepository.UpdateToSet(productId, x => x.ProductAttributeMappings, z => z.Id, productAttributeMapping.Id, productAttributeMapping);@@ -221,8 +215,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productAttributeMappingId">Product attr mapping ident</param>public virtual async Task DeleteProductAttributeValue(ProductAttributeValue productAttributeValue, string productId, string productAttributeMappingId){- if (productAttributeValue == null)- throw new ArgumentNullException(nameof(productAttributeValue));+ ArgumentNullException.ThrowIfNull(productAttributeValue);var p = await _productRepository.GetByIdAsync(productId);if (p != null)@@ -252,8 +245,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productAttributeMappingId">Product attr mapping ident</param>public virtual async Task InsertProductAttributeValue(ProductAttributeValue productAttributeValue, string productId, string productAttributeMappingId){- if (productAttributeValue == null)- throw new ArgumentNullException(nameof(productAttributeValue));+ ArgumentNullException.ThrowIfNull(productAttributeValue);var p = await _productRepository.GetByIdAsync(productId);if (p == null)@@ -281,8 +273,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productAttributeMappingId">Product attr mapping ident</param>public virtual async Task UpdateProductAttributeValue(ProductAttributeValue productAttributeValue, string productId, string productAttributeMappingId){- if (productAttributeValue == null)- throw new ArgumentNullException(nameof(productAttributeValue));+ ArgumentNullException.ThrowIfNull(productAttributeValue);var p = await _productRepository.GetByIdAsync(productId);var pavs = p?.ProductAttributeMappings.FirstOrDefault(x => x.Id == productAttributeMappingId);@@ -324,8 +315,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productId">Product ident</param>public virtual async Task DeleteProductAttributeCombination(ProductAttributeCombination combination, string productId){- if (combination == null)- throw new ArgumentNullException(nameof(combination));+ ArgumentNullException.ThrowIfNull(combination);await _productRepository.PullFilter(productId, x => x.ProductAttributeCombinations, z => z.Id, combination.Id);//cache@@ -342,8 +332,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productId">Product ident</param>public virtual async Task InsertProductAttributeCombination(ProductAttributeCombination combination, string productId){- if (combination == null)- throw new ArgumentNullException(nameof(combination));+ ArgumentNullException.ThrowIfNull(combination);await _productRepository.AddToSet(productId, x => x.ProductAttributeCombinations, combination);@@ -361,8 +350,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productId">Product ident</param>public virtual async Task UpdateProductAttributeCombination(ProductAttributeCombination combination, string productId){- if (combination == null)- throw new ArgumentNullException(nameof(combination));+ ArgumentNullException.ThrowIfNull(combination);await _productRepository.UpdateToSet(productId, x => x.ProductAttributeCombinations, z => z.Id, combination.Id, combination);diff --git a/src/Business/Grand.Business.Catalog/Services/Products/ProductCourseService.cs b/src/Business/Grand.Business.Catalog/Services/Products/ProductCourseService.csindex 979c0110e..9f8083797 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/ProductCourseService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/ProductCourseService.cs@@ -18,12 +18,12 @@ namespace Grand.Business.Catalog.Services.Productspublic virtual async Task<Course> GetCourseByProductId(string productId){- return await Task.FromResult(_courseRepository.Table.FirstOrDefault(p => p.ProductId == productId));+ return await _courseRepository.GetOneAsync(p => p.ProductId == productId);}public virtual async Task<Product> GetProductByCourseId(string courseId){- return await Task.FromResult(_productRepository.Table.FirstOrDefault(p => p.CourseId == courseId));+ return await _productRepository.GetOneAsync(p => p.CourseId == courseId);}public virtual async Task UpdateCourseOnProduct(string productId, string courseId)diff --git a/src/Business/Grand.Business.Catalog/Services/Products/ProductLayoutService.cs b/src/Business/Grand.Business.Catalog/Services/Products/ProductLayoutService.csindex b12737e44..9fb4cf98a 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/ProductLayoutService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/ProductLayoutService.cs@@ -75,8 +75,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productLayout">Product layout</param>public virtual async Task InsertProductLayout(ProductLayout productLayout){- if (productLayout == null)- throw new ArgumentNullException(nameof(productLayout));+ ArgumentNullException.ThrowIfNull(productLayout);await _productLayoutRepository.InsertAsync(productLayout);@@ -93,8 +92,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productLayout">Product layout</param>public virtual async Task UpdateProductLayout(ProductLayout productLayout){- if (productLayout == null)- throw new ArgumentNullException(nameof(productLayout));+ ArgumentNullException.ThrowIfNull(productLayout);await _productLayoutRepository.UpdateAsync(productLayout);@@ -111,8 +109,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productLayout">Product layout</param>public virtual async Task DeleteProductLayout(ProductLayout productLayout){- if (productLayout == null)- throw new ArgumentNullException(nameof(productLayout));+ ArgumentNullException.ThrowIfNull(productLayout);await _productLayoutRepository.DeleteAsync(productLayout);diff --git a/src/Business/Grand.Business.Catalog/Services/Products/ProductReservationService.cs b/src/Business/Grand.Business.Catalog/Services/Products/ProductReservationService.csindex e77b7f0af..8df95601f 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/ProductReservationService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/ProductReservationService.cs@@ -64,8 +64,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productReservation">Product reservation</param>public virtual async Task InsertProductReservation(ProductReservation productReservation){- if (productReservation == null)- throw new ArgumentNullException(nameof(productReservation));+ ArgumentNullException.ThrowIfNull(productReservation);await _productReservationRepository.InsertAsync(productReservation);@@ -79,8 +78,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productReservation">Product reservation</param>public virtual async Task UpdateProductReservation(ProductReservation productReservation){- if (productReservation == null)- throw new ArgumentNullException(nameof(productReservation));+ ArgumentNullException.ThrowIfNull(productReservation);await _productReservationRepository.UpdateAsync(productReservation);@@ -94,8 +92,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productReservation">Product reservation</param>public virtual async Task DeleteProductReservation(ProductReservation productReservation){- if (productReservation == null)- throw new ArgumentNullException(nameof(productReservation));+ ArgumentNullException.ThrowIfNull(productReservation);await _productReservationRepository.DeleteAsync(productReservation);@@ -119,8 +116,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="crh"></param>public virtual async Task InsertCustomerReservationsHelper(CustomerReservationsHelper crh){- if (crh == null)- throw new ArgumentNullException(nameof(crh));+ ArgumentNullException.ThrowIfNull(crh);await _customerReservationsHelperRepository.InsertAsync(crh);@@ -134,8 +130,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="crh"></param>public virtual async Task DeleteCustomerReservationsHelper(CustomerReservationsHelper crh){- if (crh == null)- throw new ArgumentNullException(nameof(crh));+ ArgumentNullException.ThrowIfNull(crh);await _customerReservationsHelperRepository.DeleteAsync(crh);diff --git a/src/Business/Grand.Business.Catalog/Services/Products/ProductReviewService.cs b/src/Business/Grand.Business.Catalog/Services/Products/ProductReviewService.csindex 334622cff..0f0db8be1 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/ProductReviewService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/ProductReviewService.cs@@ -76,8 +76,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productReview">Product review</param>public virtual async Task InsertProductReview(ProductReview productReview){- if (productReview == null)- throw new ArgumentNullException(nameof(productReview));+ ArgumentNullException.ThrowIfNull(productReview);await _productReviewRepository.InsertAsync(productReview);@@ -86,8 +85,7 @@ namespace Grand.Business.Catalog.Services.Products}public virtual async Task UpdateProductReview(ProductReview productReview){- if (productReview == null)- throw new ArgumentNullException(nameof(productReview));+ ArgumentNullException.ThrowIfNull(productReview);var update = UpdateBuilder<ProductReview>.Create().Set(x => x.Title, productReview.Title)@@ -111,8 +109,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productReview">Product review</param>public virtual async Task DeleteProductReview(ProductReview productReview){- if (productReview == null)- throw new ArgumentNullException(nameof(productReview));+ ArgumentNullException.ThrowIfNull(productReview);await _productReviewRepository.DeleteAsync(productReview);diff --git a/src/Business/Grand.Business.Catalog/Services/Products/ProductService.cs b/src/Business/Grand.Business.Catalog/Services/Products/ProductService.csindex 41af576bf..c56a5fce3 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/ProductService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/ProductService.cs@@ -157,8 +157,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="product">Product</param>public virtual async Task InsertProduct(Product product){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);//insertawait _productRepository.InsertAsync(product);@@ -176,8 +175,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="product">Product</param>public virtual async Task UpdateProduct(Product product){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);var oldProduct = await _productRepository.GetByIdAsync(product.Id);//update@@ -335,8 +333,7 @@ namespace Grand.Business.Catalog.Services.Productspublic virtual async Task UpdateProductField<T>(Product product,Expression<Func<Product, T>> expression, T value){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);//update fieldawait _productRepository.UpdateField(product.Id, expression, value);@@ -360,8 +357,7 @@ namespace Grand.Business.Catalog.Services.Productspublic virtual async Task IncrementProductField<T>(Product product,Expression<Func<Product, T>> expression, T value){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);//inc fieldawait _productRepository.IncField(product.Id, expression, value);@@ -373,8 +369,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="product">Product</param>public virtual async Task DeleteProduct(Product product){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);//deleted productawait _productRepository.DeleteAsync(product);@@ -630,13 +625,12 @@ namespace Grand.Business.Catalog.Services.Productsreturn null;sku = sku.Trim();- return await Task.FromResult(_productRepository.Table.FirstOrDefault(x => x.Sku == sku));+ return await _productRepository.GetOneAsync(x => x.Sku == sku);}public virtual async Task UpdateAssociatedProduct(Product product){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);var update = UpdateBuilder<Product>.Create().Set(x => x.DisplayOrder, product.DisplayOrder)@@ -664,8 +658,7 @@ namespace Grand.Business.Catalog.Services.Productspublic virtual async Task InsertRelatedProduct(RelatedProduct relatedProduct, string productId){- if (relatedProduct == null)- throw new ArgumentNullException(nameof(relatedProduct));+ ArgumentNullException.ThrowIfNull(relatedProduct);await _productRepository.AddToSet(productId, x => x.RelatedProducts, relatedProduct);@@ -682,8 +675,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productId">Product ident</param>public virtual async Task DeleteRelatedProduct(RelatedProduct relatedProduct, string productId){- if (relatedProduct == null)- throw new ArgumentNullException(nameof(relatedProduct));+ ArgumentNullException.ThrowIfNull(relatedProduct);await _productRepository.PullFilter(productId, x => x.RelatedProducts, z => z.Id, relatedProduct.Id);@@ -701,8 +693,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productId">Product ident</param>public virtual async Task UpdateRelatedProduct(RelatedProduct relatedProduct, string productId){- if (relatedProduct == null)- throw new ArgumentNullException(nameof(relatedProduct));+ ArgumentNullException.ThrowIfNull(relatedProduct);await _productRepository.UpdateToSet(productId, x => x.RelatedProducts, z => z.Id, relatedProduct.Id, relatedProduct);@@ -719,8 +710,7 @@ namespace Grand.Business.Catalog.Services.Productspublic virtual async Task InsertSimilarProduct(SimilarProduct similarProduct){- if (similarProduct == null)- throw new ArgumentNullException(nameof(similarProduct));+ ArgumentNullException.ThrowIfNull(similarProduct);await _productRepository.AddToSet(similarProduct.ProductId1, x => x.SimilarProducts, similarProduct);@@ -737,8 +727,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="similarProduct">Similar product</param>public virtual async Task UpdateSimilarProduct(SimilarProduct similarProduct){- if (similarProduct == null)- throw new ArgumentNullException(nameof(similarProduct));+ ArgumentNullException.ThrowIfNull(similarProduct);await _productRepository.UpdateToSet(similarProduct.ProductId1, x => x.SimilarProducts, z => z.Id, similarProduct.Id, similarProduct);@@ -754,8 +743,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="similarProduct">Similar product</param>public virtual async Task DeleteSimilarProduct(SimilarProduct similarProduct){- if (similarProduct == null)- throw new ArgumentNullException(nameof(similarProduct));+ ArgumentNullException.ThrowIfNull(similarProduct);await _productRepository.PullFilter(similarProduct.ProductId1, x => x.SimilarProducts, z => z.Id, similarProduct.Id);@@ -777,8 +765,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productBundleId">Product bundle ident</param>public virtual async Task InsertBundleProduct(BundleProduct bundleProduct, string productBundleId){- if (bundleProduct == null)- throw new ArgumentNullException(nameof(bundleProduct));+ ArgumentNullException.ThrowIfNull(bundleProduct);await _productRepository.AddToSet(productBundleId, x => x.BundleProducts, bundleProduct);@@ -797,8 +784,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productBundleId">Product bundle ident</param>public virtual async Task UpdateBundleProduct(BundleProduct bundleProduct, string productBundleId){- if (bundleProduct == null)- throw new ArgumentNullException(nameof(bundleProduct));+ ArgumentNullException.ThrowIfNull(bundleProduct);await _productRepository.UpdateToSet(productBundleId, x => x.BundleProducts, z => z.Id, bundleProduct.Id, bundleProduct);@@ -816,8 +802,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productBundleId">Product bundle ident</param>public virtual async Task DeleteBundleProduct(BundleProduct bundleProduct, string productBundleId){- if (bundleProduct == null)- throw new ArgumentNullException(nameof(bundleProduct));+ ArgumentNullException.ThrowIfNull(bundleProduct);await _productRepository.PullFilter(productBundleId, x => x.BundleProducts, z => z.Id, bundleProduct.Id);@@ -838,8 +823,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="crossSellProduct">Cross-sell product</param>public virtual async Task InsertCrossSellProduct(CrossSellProduct crossSellProduct){- if (crossSellProduct == null)- throw new ArgumentNullException(nameof(crossSellProduct));+ ArgumentNullException.ThrowIfNull(crossSellProduct);await _productRepository.AddToSet(crossSellProduct.ProductId1, x => x.CrossSellProduct, crossSellProduct.ProductId2);@@ -856,8 +840,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="crossSellProduct">Cross-sell identifier</param>public virtual async Task DeleteCrossSellProduct(CrossSellProduct crossSellProduct){- if (crossSellProduct == null)- throw new ArgumentNullException(nameof(crossSellProduct));+ ArgumentNullException.ThrowIfNull(crossSellProduct);await _productRepository.Pull(crossSellProduct.ProductId1, x => x.CrossSellProduct, crossSellProduct.ProductId2);@@ -930,11 +913,8 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="recommendedProductId">Recommended product</param>public virtual async Task InsertRecommendedProduct(string productId, string recommendedProductId){- if (productId == null)- throw new ArgumentNullException(nameof(productId));-- if (recommendedProductId == null)- throw new ArgumentNullException(nameof(recommendedProductId));+ ArgumentNullException.ThrowIfNull(productId);+ ArgumentNullException.ThrowIfNull(recommendedProductId);await _productRepository.AddToSet(productId, x => x.RecommendedProduct, recommendedProductId);@@ -950,11 +930,8 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="recommendedProductId">Recommended identifier</param>public virtual async Task DeleteRecommendedProduct(string productId, string recommendedProductId){- if (productId == null)- throw new ArgumentNullException(nameof(productId));-- if (recommendedProductId == null)- throw new ArgumentNullException(nameof(recommendedProductId));+ ArgumentNullException.ThrowIfNull(productId);+ ArgumentNullException.ThrowIfNull(recommendedProductId);await _productRepository.Pull(productId, x => x.RecommendedProduct, recommendedProductId);@@ -974,8 +951,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productId">Product ident</param>public virtual async Task InsertTierPrice(TierPrice tierPrice, string productId){- if (tierPrice == null)- throw new ArgumentNullException(nameof(tierPrice));+ ArgumentNullException.ThrowIfNull(tierPrice);await _productRepository.AddToSet(productId, x => x.TierPrices, tierPrice);@@ -993,8 +969,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productId">Product ident</param>public virtual async Task UpdateTierPrice(TierPrice tierPrice, string productId){- if (tierPrice == null)- throw new ArgumentNullException(nameof(tierPrice));+ ArgumentNullException.ThrowIfNull(tierPrice);await _productRepository.UpdateToSet(productId, x => x.TierPrices, z => z.Id, tierPrice.Id, tierPrice);@@ -1011,8 +986,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productId">Product ident</param>public virtual async Task DeleteTierPrice(TierPrice tierPrice, string productId){- if (tierPrice == null)- throw new ArgumentNullException(nameof(tierPrice));+ ArgumentNullException.ThrowIfNull(tierPrice);await _productRepository.PullFilter(productId, x => x.TierPrices, x => x.Id, tierPrice.Id);@@ -1033,8 +1007,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productPrice">Product price</param>public virtual async Task InsertProductPrice(ProductPrice productPrice){- if (productPrice == null)- throw new ArgumentNullException(nameof(productPrice));+ ArgumentNullException.ThrowIfNull(productPrice);await _productRepository.AddToSet(productPrice.ProductId, x => x.ProductPrices, productPrice);@@ -1051,8 +1024,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productPrice">Tier price</param>public virtual async Task UpdateProductPrice(ProductPrice productPrice){- if (productPrice == null)- throw new ArgumentNullException(nameof(productPrice));+ ArgumentNullException.ThrowIfNull(productPrice);await _productRepository.UpdateToSet(productPrice.ProductId, x => x.ProductPrices, z => z.Id, productPrice.Id, productPrice);@@ -1069,8 +1041,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productPrice">Product price</param>public virtual async Task DeleteProductPrice(ProductPrice productPrice){- if (productPrice == null)- throw new ArgumentNullException(nameof(productPrice));+ ArgumentNullException.ThrowIfNull(productPrice);await _productRepository.PullFilter(productPrice.ProductId, x => x.ProductPrices, x => x.Id, productPrice.Id);@@ -1091,8 +1062,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productId">Product ident</param>public virtual async Task InsertProductPicture(ProductPicture productPicture, string productId){- if (productPicture == null)- throw new ArgumentNullException(nameof(productPicture));+ ArgumentNullException.ThrowIfNull(productPicture);await _productRepository.AddToSet(productId, x => x.ProductPictures, productPicture);@@ -1110,8 +1080,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productId">Product ident</param>public virtual async Task UpdateProductPicture(ProductPicture productPicture, string productId){- if (productPicture == null)- throw new ArgumentNullException(nameof(productPicture));+ ArgumentNullException.ThrowIfNull(productPicture);await _productRepository.UpdateToSet(productId, x => x.ProductPictures, z => z.Id, productPicture.Id, productPicture);@@ -1128,8 +1097,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productId">Product ident</param>public virtual async Task DeleteProductPicture(ProductPicture productPicture, string productId){- if (productPicture == null)- throw new ArgumentNullException(nameof(productPicture));+ ArgumentNullException.ThrowIfNull(productPicture);await _productRepository.PullFilter(productId, x => x.ProductPictures, x => x.Id, productPicture.Id);@@ -1150,8 +1118,7 @@ namespace Grand.Business.Catalog.Services.Products/// <returns></returns>public virtual async Task InsertProductWarehouseInventory(ProductWarehouseInventory pwi, string productId){- if (pwi == null)- throw new ArgumentNullException(nameof(pwi));+ ArgumentNullException.ThrowIfNull(pwi);await _productRepository.AddToSet(productId, x => x.ProductWarehouseInventory, pwi);@@ -1169,8 +1136,7 @@ namespace Grand.Business.Catalog.Services.Products/// <returns></returns>public virtual async Task UpdateProductWarehouseInventory(ProductWarehouseInventory pwi, string productId){- if (pwi == null)- throw new ArgumentNullException(nameof(pwi));+ ArgumentNullException.ThrowIfNull(pwi);await _productRepository.UpdateToSet(productId, x => x.ProductWarehouseInventory, z => z.Id, pwi.Id, pwi);@@ -1186,8 +1152,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productId">Product ident</param>public virtual async Task DeleteProductWarehouseInventory(ProductWarehouseInventory pwi, string productId){- if (pwi == null)- throw new ArgumentNullException(nameof(pwi));+ ArgumentNullException.ThrowIfNull(pwi);await _productRepository.PullFilter(productId, x => x.ProductWarehouseInventory, x => x.Id, pwi.Id);diff --git a/src/Business/Grand.Business.Catalog/Services/Products/ProductTagService.cs b/src/Business/Grand.Business.Catalog/Services/Products/ProductTagService.csindex 7fb883fea..497071bc4 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/ProductTagService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/ProductTagService.cs@@ -94,11 +94,7 @@ namespace Grand.Business.Catalog.Services.Products/// <returns>Product tag</returns>public virtual Task<ProductTag> GetProductTagByName(string name){- var query = from pt in _productTagRepository.Table- where pt.Name == name- select pt;-- return Task.FromResult(query.FirstOrDefault());+ return _productTagRepository.GetOneAsync(x=>x.Name == name);}/// <summary>@@ -108,10 +104,7 @@ namespace Grand.Business.Catalog.Services.Products/// <returns>Product tag</returns>public virtual Task<ProductTag> GetProductTagBySeName(string sename){- var query = from pt in _productTagRepository.Table- where pt.SeName == sename- select pt;- return Task.FromResult(query.FirstOrDefault());+ return _productTagRepository.GetOneAsync(x=>x.SeName == sename);}/// <summary>@@ -120,8 +113,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productTag">Product tag</param>public virtual async Task InsertProductTag(ProductTag productTag){- if (productTag == null)- throw new ArgumentNullException(nameof(productTag));+ ArgumentNullException.ThrowIfNull(productTag);await _productTagRepository.InsertAsync(productTag);@@ -138,8 +130,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productTag">Product tag</param>public virtual async Task UpdateProductTag(ProductTag productTag){- if (productTag == null)- throw new ArgumentNullException(nameof(productTag));+ ArgumentNullException.ThrowIfNull(productTag);var previous = await GetProductTagById(productTag.Id);@@ -160,8 +151,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productTag">Product tag</param>public virtual async Task DeleteProductTag(ProductTag productTag){- if (productTag == null)- throw new ArgumentNullException(nameof(productTag));+ ArgumentNullException.ThrowIfNull(productTag);//update productawait _productRepository.Pull(string.Empty, x => x.ProductTags, productTag.Name);@@ -184,8 +174,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productId">Product ident</param>public virtual async Task AttachProductTag(ProductTag productTag, string productId){- if (productTag == null)- throw new ArgumentNullException(nameof(productTag));+ ArgumentNullException.ThrowIfNull(productTag);//assign to productawait _productRepository.AddToSet(productId, x => x.ProductTags, productTag.Name);@@ -208,9 +197,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productId">Product ident</param>public virtual async Task DetachProductTag(ProductTag productTag, string productId){- if (productTag == null)- throw new ArgumentNullException(nameof(productTag));-+ ArgumentNullException.ThrowIfNull(productTag);await _productRepository.Pull(productId, x => x.ProductTags, productTag.Name);diff --git a/src/Business/Grand.Business.Catalog/Services/Products/SpecificationAttributeService.cs b/src/Business/Grand.Business.Catalog/Services/Products/SpecificationAttributeService.csindex e598eb5a1..64d05dee5 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/SpecificationAttributeService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/SpecificationAttributeService.cs@@ -96,8 +96,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="specificationAttribute">The specification attribute</param>public virtual async Task InsertSpecificationAttribute(SpecificationAttribute specificationAttribute){- if (specificationAttribute == null)- throw new ArgumentNullException(nameof(specificationAttribute));+ ArgumentNullException.ThrowIfNull(specificationAttribute);await _specificationAttributeRepository.InsertAsync(specificationAttribute);@@ -114,8 +113,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="specificationAttribute">The specification attribute</param>public virtual async Task UpdateSpecificationAttribute(SpecificationAttribute specificationAttribute){- if (specificationAttribute == null)- throw new ArgumentNullException(nameof(specificationAttribute));+ ArgumentNullException.ThrowIfNull(specificationAttribute);await _specificationAttributeRepository.UpdateAsync(specificationAttribute);@@ -131,8 +129,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="specificationAttribute">The specification attribute</param>public virtual async Task DeleteSpecificationAttribute(SpecificationAttribute specificationAttribute){- if (specificationAttribute == null)- throw new ArgumentNullException(nameof(specificationAttribute));+ ArgumentNullException.ThrowIfNull(specificationAttribute);//delete from all product collectionsawait _productRepository.PullFilter(string.Empty, x => x.ProductSpecificationAttributes, z => z.SpecificationAttributeId, specificationAttribute.Id);@@ -177,8 +174,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="specificationAttributeOption">The specification attribute option</param>public virtual async Task DeleteSpecificationAttributeOption(SpecificationAttributeOption specificationAttributeOption){- if (specificationAttributeOption == null)- throw new ArgumentNullException(nameof(specificationAttributeOption));+ ArgumentNullException.ThrowIfNull(specificationAttributeOption);//delete from all product collectionsawait _productRepository.PullFilter(string.Empty, x => x.ProductSpecificationAttributes, z => z.SpecificationAttributeOptionId, specificationAttributeOption.Id);@@ -212,8 +208,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productId">Product ident</param>public virtual async Task InsertProductSpecificationAttribute(ProductSpecificationAttribute productSpecificationAttribute, string productId){- if (productSpecificationAttribute == null)- throw new ArgumentNullException(nameof(productSpecificationAttribute));+ ArgumentNullException.ThrowIfNull(productSpecificationAttribute);await _productRepository.AddToSet(productId, x => x.ProductSpecificationAttributes, productSpecificationAttribute);@@ -231,8 +226,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productId">Product ident</param>public virtual async Task UpdateProductSpecificationAttribute(ProductSpecificationAttribute productSpecificationAttribute, string productId){- if (productSpecificationAttribute == null)- throw new ArgumentNullException(nameof(productSpecificationAttribute));+ ArgumentNullException.ThrowIfNull(productSpecificationAttribute);await _productRepository.UpdateToSet(productId, x => x.ProductSpecificationAttributes, z => z.Id, productSpecificationAttribute.Id, productSpecificationAttribute);@@ -249,8 +243,7 @@ namespace Grand.Business.Catalog.Services.Products/// <param name="productId">Product ident</param>public virtual async Task DeleteProductSpecificationAttribute(ProductSpecificationAttribute productSpecificationAttribute, string productId){- if (productSpecificationAttribute == null)- throw new ArgumentNullException(nameof(productSpecificationAttribute));+ ArgumentNullException.ThrowIfNull(productSpecificationAttribute);await _productRepository.PullFilter(productId, x => x.ProductSpecificationAttributes, x => x.Id, productSpecificationAttribute.Id);diff --git a/src/Business/Grand.Business.Catalog/Services/Products/StockQuantityService.cs b/src/Business/Grand.Business.Catalog/Services/Products/StockQuantityService.csindex e4bb5d2b5..436b9f422 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/StockQuantityService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/StockQuantityService.cs@@ -11,8 +11,7 @@ namespace Grand.Business.Catalog.Services.Productspublic virtual int GetTotalStockQuantity(Product product, bool useReservedQuantity = true,string warehouseId = "", bool total = false){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);if (product.ManageInventoryMethodId != ManageInventoryMethod.ManageStock){@@ -51,11 +50,8 @@ namespace Grand.Business.Catalog.Services.Productspublic virtual int GetTotalStockQuantityForCombination(Product product, ProductAttributeCombination combination,bool useReservedQuantity = true, string warehouseId = ""){- if (product == null)- throw new ArgumentNullException(nameof(product));-- if (combination == null)- throw new ArgumentNullException(nameof(combination));+ ArgumentNullException.ThrowIfNull(product);+ ArgumentNullException.ThrowIfNull(combination);if (product.ManageInventoryMethodId != ManageInventoryMethod.ManageStockByAttributes){@@ -87,8 +83,7 @@ namespace Grand.Business.Catalog.Services.Productspublic virtual (string resource, object? arg0) FormatStockMessage(Product product, string warehouseId,IList<CustomAttribute> attributes){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);var stockMessage = string.Empty;diff --git a/src/Business/Grand.Business.Catalog/Services/Tax/TaxCategoryService.cs b/src/Business/Grand.Business.Catalog/Services/Tax/TaxCategoryService.csindex 80ce87b76..b2bfe1f33 100644--- a/src/Business/Grand.Business.Catalog/Services/Tax/TaxCategoryService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Tax/TaxCategoryService.cs@@ -75,8 +75,7 @@ namespace Grand.Business.Catalog.Services.Tax/// <param name="taxCategory">Tax category</param>public virtual async Task InsertTaxCategory(TaxCategory taxCategory){- if (taxCategory == null)- throw new ArgumentNullException(nameof(taxCategory));+ ArgumentNullException.ThrowIfNull(taxCategory);await _taxCategoryRepository.InsertAsync(taxCategory);@@ -92,8 +91,7 @@ namespace Grand.Business.Catalog.Services.Tax/// <param name="taxCategory">Tax category</param>public virtual async Task UpdateTaxCategory(TaxCategory taxCategory){- if (taxCategory == null)- throw new ArgumentNullException(nameof(taxCategory));+ ArgumentNullException.ThrowIfNull(taxCategory);await _taxCategoryRepository.UpdateAsync(taxCategory);@@ -108,8 +106,7 @@ namespace Grand.Business.Catalog.Services.Tax/// <param name="taxCategory">Tax category</param>public virtual async Task DeleteTaxCategory(TaxCategory taxCategory){- if (taxCategory == null)- throw new ArgumentNullException(nameof(taxCategory));+ ArgumentNullException.ThrowIfNull(taxCategory);await _taxCategoryRepository.DeleteAsync(taxCategory);diff --git a/src/Business/Grand.Business.Catalog/Services/Tax/TaxService.cs b/src/Business/Grand.Business.Catalog/Services/Tax/TaxService.csindex 740082568..71bc87a0a 100644--- a/src/Business/Grand.Business.Catalog/Services/Tax/TaxService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Tax/TaxService.cs@@ -71,8 +71,7 @@ namespace Grand.Business.Catalog.Services.Tax/// <returns>Result</returns>protected virtual async Task<bool> IsEuConsumer(Customer customer){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);Country country = null;@@ -116,8 +115,7 @@ namespace Grand.Business.Catalog.Services.Taxprotected virtual async Task<TaxRequest> CreateCalculateTaxRequest(Product product,string taxCategoryId, Customer customer, double price){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);var calculateTaxRequest = new TaxRequest {Customer = customer,@@ -598,11 +596,8 @@ namespace Grand.Business.Catalog.Services.Tax/// <returns>Price</returns>public virtual async Task<(double checkoutPrice, double taxRate)> GetCheckoutAttributePrice(CheckoutAttribute ca, CheckoutAttributeValue cav, bool includingTax, Customer customer){- if (ca == null)- throw new ArgumentNullException(nameof(ca));-- if (cav == null)- throw new ArgumentNullException(nameof(cav));+ ArgumentNullException.ThrowIfNull(ca);+ ArgumentNullException.ThrowIfNull(cav);var price = cav.PriceAdjustment;if (ca.IsTaxExempt)diff --git a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/ValidateMinShoppingCartSubtotalAmountCommandHandler.cs b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/ValidateMinShoppingCartSubtotalAmountCommandHandler.csindex 8c91187df..a47663a9a 100644--- a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/ValidateMinShoppingCartSubtotalAmountCommandHandler.cs+++ b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/ValidateMinShoppingCartSubtotalAmountCommandHandler.cs@@ -31,8 +31,7 @@ namespace Grand.Business.Checkout.Commands.Handlers.Ordersprotected virtual async Task<bool> ValidateMinOrderSubtotalAmount(IList<ShoppingCartItem> cart){- if (cart == null)- throw new ArgumentNullException(nameof(cart));+ ArgumentNullException.ThrowIfNull(cart);if (!cart.Any())return false;diff --git a/src/Business/Grand.Business.Checkout/Services/CheckoutAttributes/CheckoutAttributeParser.cs b/src/Business/Grand.Business.Checkout/Services/CheckoutAttributes/CheckoutAttributeParser.csindex f57e8ff3a..f382142cb 100644--- a/src/Business/Grand.Business.Checkout/Services/CheckoutAttributes/CheckoutAttributeParser.cs+++ b/src/Business/Grand.Business.Checkout/Services/CheckoutAttributes/CheckoutAttributeParser.cs@@ -130,8 +130,7 @@ namespace Grand.Business.Checkout.Services.CheckoutAttributes/// <returns>Result</returns>public virtual async Task<bool?> IsConditionMet(CheckoutAttribute attribute, IList<CustomAttribute> customAttributes){- if (attribute == null)- throw new ArgumentNullException(nameof(attribute));+ ArgumentNullException.ThrowIfNull(attribute);customAttributes ??= new List<CustomAttribute>();diff --git a/src/Business/Grand.Business.Checkout/Services/CheckoutAttributes/CheckoutAttributeService.cs b/src/Business/Grand.Business.Checkout/Services/CheckoutAttributes/CheckoutAttributeService.csindex b37ac213b..7339c96be 100644--- a/src/Business/Grand.Business.Checkout/Services/CheckoutAttributes/CheckoutAttributeService.cs+++ b/src/Business/Grand.Business.Checkout/Services/CheckoutAttributes/CheckoutAttributeService.cs@@ -109,8 +109,7 @@ namespace Grand.Business.Checkout.Services.CheckoutAttributes/// <param name="checkoutAttribute">Checkout attribute</param>public virtual async Task InsertCheckoutAttribute(CheckoutAttribute checkoutAttribute){- if (checkoutAttribute == null)- throw new ArgumentNullException(nameof(checkoutAttribute));+ ArgumentNullException.ThrowIfNull(checkoutAttribute);await _checkoutAttributeRepository.InsertAsync(checkoutAttribute);@@ -127,8 +126,7 @@ namespace Grand.Business.Checkout.Services.CheckoutAttributes/// <param name="checkoutAttribute">Checkout attribute</param>public virtual async Task UpdateCheckoutAttribute(CheckoutAttribute checkoutAttribute){- if (checkoutAttribute == null)- throw new ArgumentNullException(nameof(checkoutAttribute));+ ArgumentNullException.ThrowIfNull(checkoutAttribute);await _checkoutAttributeRepository.UpdateAsync(checkoutAttribute);@@ -144,8 +142,7 @@ namespace Grand.Business.Checkout.Services.CheckoutAttributes/// <param name="checkoutAttribute">Checkout attribute</param>public virtual async Task DeleteCheckoutAttribute(CheckoutAttribute checkoutAttribute){- if (checkoutAttribute == null)- throw new ArgumentNullException(nameof(checkoutAttribute));+ ArgumentNullException.ThrowIfNull(checkoutAttribute);await _checkoutAttributeRepository.DeleteAsync(checkoutAttribute);diff --git a/src/Business/Grand.Business.Checkout/Services/GiftVouchers/GiftVoucherService.cs b/src/Business/Grand.Business.Checkout/Services/GiftVouchers/GiftVoucherService.csindex cc361cd2d..168d1ddbf 100644--- a/src/Business/Grand.Business.Checkout/Services/GiftVouchers/GiftVoucherService.cs+++ b/src/Business/Grand.Business.Checkout/Services/GiftVouchers/GiftVoucherService.cs@@ -97,8 +97,7 @@ namespace Grand.Business.Checkout.Services.GiftVouchers/// <param name="giftVoucher">Gift voucher</param>public virtual async Task InsertGiftVoucher(GiftVoucher giftVoucher){- if (giftVoucher == null)- throw new ArgumentNullException(nameof(giftVoucher));+ ArgumentNullException.ThrowIfNull(giftVoucher);giftVoucher.Code = giftVoucher.Code.ToLowerInvariant();@@ -114,8 +113,7 @@ namespace Grand.Business.Checkout.Services.GiftVouchers/// <param name="giftVoucher">Gift voucher</param>public virtual async Task UpdateGiftVoucher(GiftVoucher giftVoucher){- if (giftVoucher == null)- throw new ArgumentNullException(nameof(giftVoucher));+ ArgumentNullException.ThrowIfNull(giftVoucher);giftVoucher.Code = giftVoucher.Code.ToLowerInvariant();@@ -130,8 +128,7 @@ namespace Grand.Business.Checkout.Services.GiftVouchers/// <param name="giftVoucher">Gift voucher</param>public virtual async Task DeleteGiftVoucher(GiftVoucher giftVoucher){- if (giftVoucher == null)- throw new ArgumentNullException(nameof(giftVoucher));+ ArgumentNullException.ThrowIfNull(giftVoucher);await _giftVoucherRepository.DeleteAsync(giftVoucher);diff --git a/src/Business/Grand.Business.Checkout/Services/Orders/MerchandiseReturnService.cs b/src/Business/Grand.Business.Checkout/Services/Orders/MerchandiseReturnService.csindex 018fe9726..c0d68d2a3 100644--- a/src/Business/Grand.Business.Checkout/Services/Orders/MerchandiseReturnService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Orders/MerchandiseReturnService.cs@@ -145,8 +145,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <param name="merchandiseReturn">Merchandise return </param>public virtual async Task InsertMerchandiseReturn(MerchandiseReturn merchandiseReturn){- if (merchandiseReturn == null)- throw new ArgumentNullException(nameof(merchandiseReturn));+ ArgumentNullException.ThrowIfNull(merchandiseReturn);lock (Locker){@@ -166,8 +165,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <param name="merchandiseReturn"></param>public virtual async Task UpdateMerchandiseReturn(MerchandiseReturn merchandiseReturn){- if (merchandiseReturn == null)- throw new ArgumentNullException(nameof(merchandiseReturn));+ ArgumentNullException.ThrowIfNull(merchandiseReturn);await _merchandiseReturnRepository.UpdateAsync(merchandiseReturn);@@ -180,8 +178,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <param name="merchandiseReturn">Merchandise return</param>public virtual async Task DeleteMerchandiseReturn(MerchandiseReturn merchandiseReturn){- if (merchandiseReturn == null)- throw new ArgumentNullException(nameof(merchandiseReturn));+ ArgumentNullException.ThrowIfNull(merchandiseReturn);await _merchandiseReturnRepository.DeleteAsync(merchandiseReturn);@@ -195,8 +192,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <param name="merchandiseReturnAction">Merchandise return action</param>public virtual async Task InsertMerchandiseReturnAction(MerchandiseReturnAction merchandiseReturnAction){- if (merchandiseReturnAction == null)- throw new ArgumentNullException(nameof(merchandiseReturnAction));+ ArgumentNullException.ThrowIfNull(merchandiseReturnAction);await _merchandiseReturnActionRepository.InsertAsync(merchandiseReturnAction);@@ -212,8 +208,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <param name="merchandiseReturnAction">Merchandise return action</param>public virtual async Task UpdateMerchandiseReturnAction(MerchandiseReturnAction merchandiseReturnAction){- if (merchandiseReturnAction == null)- throw new ArgumentNullException(nameof(merchandiseReturnAction));+ ArgumentNullException.ThrowIfNull(merchandiseReturnAction);await _merchandiseReturnActionRepository.UpdateAsync(merchandiseReturnAction);@@ -230,8 +225,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <param name="merchandiseReturnAction">Merchandise return action</param>public virtual async Task DeleteMerchandiseReturnAction(MerchandiseReturnAction merchandiseReturnAction){- if (merchandiseReturnAction == null)- throw new ArgumentNullException(nameof(merchandiseReturnAction));+ ArgumentNullException.ThrowIfNull(merchandiseReturnAction);await _merchandiseReturnActionRepository.DeleteAsync(merchandiseReturnAction);@@ -244,8 +238,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <param name="merchandiseReturnReason">Merchandise return reason</param>public virtual async Task DeleteMerchandiseReturnReason(MerchandiseReturnReason merchandiseReturnReason){- if (merchandiseReturnReason == null)- throw new ArgumentNullException(nameof(merchandiseReturnReason));+ ArgumentNullException.ThrowIfNull(merchandiseReturnReason);await _merchandiseReturnReasonRepository.DeleteAsync(merchandiseReturnReason);@@ -288,8 +281,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <param name="merchandiseReturnReason">Merchandise return reasons</param>public virtual async Task InsertMerchandiseReturnReason(MerchandiseReturnReason merchandiseReturnReason){- if (merchandiseReturnReason == null)- throw new ArgumentNullException(nameof(merchandiseReturnReason));+ ArgumentNullException.ThrowIfNull(merchandiseReturnReason);await _merchandiseReturnReasonRepository.InsertAsync(merchandiseReturnReason);@@ -306,8 +298,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <param name="merchandiseReturnReason">Merchandise return reasons</param>public virtual async Task UpdateMerchandiseReturnReason(MerchandiseReturnReason merchandiseReturnReason){- if (merchandiseReturnReason == null)- throw new ArgumentNullException(nameof(merchandiseReturnReason));+ ArgumentNullException.ThrowIfNull(merchandiseReturnReason);await _merchandiseReturnReasonRepository.UpdateAsync(merchandiseReturnReason);@@ -327,8 +318,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <param name="merchandiseReturnNote">The merchandise return note</param>public virtual async Task DeleteMerchandiseReturnNote(MerchandiseReturnNote merchandiseReturnNote){- if (merchandiseReturnNote == null)- throw new ArgumentNullException(nameof(merchandiseReturnNote));+ ArgumentNullException.ThrowIfNull(merchandiseReturnNote);await _merchandiseReturnNoteRepository.DeleteAsync(merchandiseReturnNote);@@ -342,8 +332,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <param name="merchandiseReturnNote">The merchandise return note</param>public virtual async Task InsertMerchandiseReturnNote(MerchandiseReturnNote merchandiseReturnNote){- if (merchandiseReturnNote == null)- throw new ArgumentNullException(nameof(merchandiseReturnNote));+ ArgumentNullException.ThrowIfNull(merchandiseReturnNote);await _merchandiseReturnNoteRepository.InsertAsync(merchandiseReturnNote);diff --git a/src/Business/Grand.Business.Checkout/Services/Orders/OrderCalculationService.cs b/src/Business/Grand.Business.Checkout/Services/Orders/OrderCalculationService.csindex c0a37ff7e..d408baa54 100644--- a/src/Business/Grand.Business.Checkout/Services/Orders/OrderCalculationService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Orders/OrderCalculationService.cs@@ -633,8 +633,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <returns>Tax total</returns>public virtual async Task<(double taxtotal, SortedDictionary<double, double> taxRates)> GetTaxTotal(IList<ShoppingCartItem> cart, bool usePaymentMethodAdditionalFee = true){- if (cart == null)- throw new ArgumentNullException(nameof(cart));+ ArgumentNullException.ThrowIfNull(cart);var taxRates = new SortedDictionary<double, double>();diff --git a/src/Business/Grand.Business.Checkout/Services/Orders/OrderService.cs b/src/Business/Grand.Business.Checkout/Services/Orders/OrderService.csindex fe9b065fa..4d972ea61 100644--- a/src/Business/Grand.Business.Checkout/Services/Orders/OrderService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Orders/OrderService.cs@@ -197,8 +197,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <param name="order">Order</param>public virtual async Task InsertOrder(Order order){- if (order == null)- throw new ArgumentNullException(nameof(order));+ ArgumentNullException.ThrowIfNull(order);var orderExists = _orderRepository.Table.OrderByDescending(x => x.OrderNumber).Select(x => x.OrderNumber).FirstOrDefault();order.OrderNumber = orderExists != 0 ? orderExists + 1 : 1;@@ -215,8 +214,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <param name="order">The order</param>public virtual async Task UpdateOrder(Order order){- if (order == null)- throw new ArgumentNullException(nameof(order));+ ArgumentNullException.ThrowIfNull(order);await _orderRepository.UpdateAsync(order);@@ -272,8 +270,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <param name="orderNote">The order note</param>public virtual async Task DeleteOrderNote(OrderNote orderNote){- if (orderNote == null)- throw new ArgumentNullException(nameof(orderNote));+ ArgumentNullException.ThrowIfNull(orderNote);await _orderNoteRepository.DeleteAsync(orderNote);@@ -287,8 +284,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <param name="orderNote">The order note</param>public virtual async Task InsertOrderNote(OrderNote orderNote){- if (orderNote == null)- throw new ArgumentNullException(nameof(orderNote));+ ArgumentNullException.ThrowIfNull(orderNote);await _orderNoteRepository.InsertAsync(orderNote);diff --git a/src/Business/Grand.Business.Checkout/Services/Orders/OrderStatusService.cs b/src/Business/Grand.Business.Checkout/Services/Orders/OrderStatusService.csindex e25de76b7..179bdc1b9 100644--- a/src/Business/Grand.Business.Checkout/Services/Orders/OrderStatusService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Orders/OrderStatusService.cs@@ -48,8 +48,7 @@ namespace Grand.Business.Checkout.Services.Orderspublic virtual async Task Insert(OrderStatus orderStatus){- if (orderStatus == null)- throw new ArgumentNullException(nameof(orderStatus));+ ArgumentNullException.ThrowIfNull(orderStatus);//insert order statusawait _orderStatusRepository.InsertAsync(orderStatus);@@ -63,8 +62,7 @@ namespace Grand.Business.Checkout.Services.Orderspublic virtual async Task Update(OrderStatus orderStatus){- if (orderStatus == null)- throw new ArgumentNullException(nameof(orderStatus));+ ArgumentNullException.ThrowIfNull(orderStatus);//update order statusawait _orderStatusRepository.UpdateAsync(orderStatus);@@ -77,8 +75,7 @@ namespace Grand.Business.Checkout.Services.Orders}public virtual async Task Delete(OrderStatus orderStatus){- if (orderStatus == null)- throw new ArgumentNullException(nameof(orderStatus));+ ArgumentNullException.ThrowIfNull(orderStatus);if (orderStatus.IsSystem)throw new Exception("You can't delete system status");diff --git a/src/Business/Grand.Business.Checkout/Services/Orders/OrderTagService.cs b/src/Business/Grand.Business.Checkout/Services/Orders/OrderTagService.csindex fb6999927..efa5d2051 100644--- a/src/Business/Grand.Business.Checkout/Services/Orders/OrderTagService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Orders/OrderTagService.cs@@ -87,11 +87,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <returns>Order's tag</returns>public virtual Task<OrderTag> GetOrderTagByName(string name){- var query = from pt in _orderTagRepository.Table- where pt.Name == name- select pt;-- return Task.FromResult(query.FirstOrDefault());+ return _orderTagRepository.GetOneAsync(x=>x.Name == name);}/// <summary>@@ -100,8 +96,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <param name="orderTag">Order's tag</param>public virtual async Task InsertOrderTag(OrderTag orderTag){- if (orderTag == null)- throw new ArgumentNullException(nameof(orderTag));+ ArgumentNullException.ThrowIfNull(orderTag);await _orderTagRepository.InsertAsync(orderTag);@@ -118,8 +113,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <param name="orderTag">Order tag</param>public virtual async Task UpdateOrderTag(OrderTag orderTag){- if (orderTag == null)- throw new ArgumentNullException(nameof(orderTag));+ ArgumentNullException.ThrowIfNull(orderTag);await _orderTagRepository.UpdateAsync(orderTag);@@ -135,8 +129,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <param name="orderTag">Order's tag</param>public virtual async Task DeleteOrderTag(OrderTag orderTag){- if (orderTag == null)- throw new ArgumentNullException(nameof(orderTag));+ ArgumentNullException.ThrowIfNull(orderTag);//update ordersawait _orderRepository.Pull(string.Empty, x => x.OrderTags, orderTag.Id);@@ -196,7 +189,6 @@ namespace Grand.Business.Checkout.Services.Orders/// Get number of orders/// </summary>/// <param name="orderTagId">Order's tag identifier</param>- /// <param name="storeId">Store identifier</param>/// <returns>Number of orders</returns>public virtual async Task<int> GetOrderCount(string orderTagId, string storeId){diff --git a/src/Business/Grand.Business.Checkout/Services/Orders/ShoppingCartService.cs b/src/Business/Grand.Business.Checkout/Services/Orders/ShoppingCartService.csindex 530bb5aec..9fe05f01e 100644--- a/src/Business/Grand.Business.Checkout/Services/Orders/ShoppingCartService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Orders/ShoppingCartService.cs@@ -106,8 +106,7 @@ namespace Grand.Business.Checkout.Services.OrdersDateTime? rentalStartDate = null,DateTime? rentalEndDate = null){- if (shoppingCart == null)- throw new ArgumentNullException(nameof(shoppingCart));+ ArgumentNullException.ThrowIfNull(shoppingCart);foreach (var sci in shoppingCart.Where(a => a.ShoppingCartTypeId == shoppingCartType)){@@ -193,8 +192,7 @@ namespace Grand.Business.Checkout.Services.Ordersstring reservationId = "", string parameter = "", string duration = "",ShoppingCartValidatorOptions validator = null){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);validator ??= new ShoppingCartValidatorOptions();@@ -318,8 +316,7 @@ namespace Grand.Business.Checkout.Services.OrdersDateTime? rentalStartDate = null, DateTime? rentalEndDate = null,int quantity = 1, bool resetCheckoutData = true, string reservationId = "", string sciId = ""){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);var warnings = new List<string>();@@ -373,8 +370,7 @@ namespace Grand.Business.Checkout.Services.Orderspublic virtual async Task DeleteShoppingCartItem(Customer customer, ShoppingCartItem shoppingCartItem, bool resetCheckoutData = true,bool ensureOnlyActiveCheckoutAttributes = false){- if (shoppingCartItem == null)- throw new ArgumentNullException(nameof(shoppingCartItem));+ ArgumentNullException.ThrowIfNull(shoppingCartItem);//reset checkout dataif (resetCheckoutData)@@ -399,10 +395,8 @@ namespace Grand.Business.Checkout.Services.Orders/// <param name="includeCouponCodes">A value indicating whether to coupon codes (discount and gift voucher) should be also re-applied</param>public virtual async Task MigrateShoppingCart(Customer fromCustomer, Customer toCustomer, bool includeCouponCodes){- if (fromCustomer == null)- throw new ArgumentNullException(nameof(fromCustomer));- if (toCustomer == null)- throw new ArgumentNullException(nameof(toCustomer));+ ArgumentNullException.ThrowIfNull(fromCustomer);+ ArgumentNullException.ThrowIfNull(toCustomer);if (fromCustomer.Id == toCustomer.Id)return; //the same customerdiff --git a/src/Business/Grand.Business.Checkout/Services/Orders/ShoppingCartValidator.cs b/src/Business/Grand.Business.Checkout/Services/Orders/ShoppingCartValidator.csindex b5a9401a2..88abf5753 100644--- a/src/Business/Grand.Business.Checkout/Services/Orders/ShoppingCartValidator.cs+++ b/src/Business/Grand.Business.Checkout/Services/Orders/ShoppingCartValidator.cs@@ -31,11 +31,8 @@ namespace Grand.Business.Checkout.Services.Orderspublic virtual async Task<IList<string>> GetStandardWarnings(Customer customer, Product product, ShoppingCartItem shoppingCartItem){- if (customer == null)- throw new ArgumentNullException(nameof(customer));-- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(customer);+ ArgumentNullException.ThrowIfNull(product);var warnings = new List<string>();@@ -48,8 +45,7 @@ namespace Grand.Business.Checkout.Services.Orderspublic virtual async Task<IList<string>> GetShoppingCartItemAttributeWarnings(Customer customer, Product product, ShoppingCartItem shoppingCartItem, bool ignoreNonCombinableAttributes = false){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);var warnings = new List<string>();@@ -64,8 +60,7 @@ namespace Grand.Business.Checkout.Services.Orderspublic virtual async Task<IList<string>> GetShoppingCartItemGiftVoucherWarnings(Customer customer,Product product, ShoppingCartItem shoppingCartItem){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);var warnings = new List<string>();@@ -165,8 +160,7 @@ namespace Grand.Business.Checkout.Services.Orderspublic virtual async Task<IList<string>> GetShoppingCartItemWarnings(Customer customer, ShoppingCartItem shoppingCartItem,Product product, ShoppingCartValidatorOptions options){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);var warnings = new List<string>();@@ -203,11 +197,8 @@ namespace Grand.Business.Checkout.Services.Orderspublic virtual async Task<IList<string>> GetRequiredProductWarnings(Customer customer,ShoppingCartItem shoppingCartItem, Product product, string storeId){- if (customer == null)- throw new ArgumentNullException(nameof(customer));-- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(customer);+ ArgumentNullException.ThrowIfNull(product);var warnings = new List<string>();diff --git a/src/Business/Grand.Business.Checkout/Services/Payments/PaymentService.cs b/src/Business/Grand.Business.Checkout/Services/Payments/PaymentService.csindex fb4aeda7f..53dfe5abf 100644--- a/src/Business/Grand.Business.Checkout/Services/Payments/PaymentService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Payments/PaymentService.cs@@ -111,8 +111,7 @@ namespace Grand.Business.Checkout.Services.Payments/// <returns>A list of country identifiers</returns>public virtual IList<string> GetRestrictedCountryIds(IPaymentProvider paymentMethod){- if (paymentMethod == null)- throw new ArgumentNullException(nameof(paymentMethod));+ ArgumentNullException.ThrowIfNull(paymentMethod);var settingKey = $"PaymentMethodRestictions.{paymentMethod.SystemName}";var restrictedCountryIds = _settingService.GetSettingByKey<PaymentRestrictedSettings>(settingKey);@@ -126,8 +125,7 @@ namespace Grand.Business.Checkout.Services.Payments/// <returns>A list of role identifiers</returns>public virtual IList<string> GetRestrictedShippingIds(IPaymentProvider paymentMethod){- if (paymentMethod == null)- throw new ArgumentNullException(nameof(paymentMethod));+ ArgumentNullException.ThrowIfNull(paymentMethod);var settingKey = $"PaymentMethodRestictionsShipping.{paymentMethod.SystemName}";var restrictedShippingIds = _settingService.GetSettingByKey<PaymentRestrictedSettings>(settingKey);@@ -140,8 +138,7 @@ namespace Grand.Business.Checkout.Services.Payments/// <param name="countryIds">A list of country identifiers</param>public virtual async Task SaveRestrictedCountryIds(IPaymentProvider paymentMethod, List<string> countryIds){- if (paymentMethod == null)- throw new ArgumentNullException(nameof(paymentMethod));+ ArgumentNullException.ThrowIfNull(paymentMethod);var settingKey = $"PaymentMethodRestictions.{paymentMethod.SystemName}";await _settingService.SetSetting(settingKey, new PaymentRestrictedSettings { Ids = countryIds });@@ -154,8 +151,7 @@ namespace Grand.Business.Checkout.Services.Payments/// <param name="groupIds">A list of group identifiers</param>public virtual async Task SaveRestrictedGroupIds(IPaymentProvider paymentMethod, List<string> groupIds){- if (paymentMethod == null)- throw new ArgumentNullException(nameof(paymentMethod));+ ArgumentNullException.ThrowIfNull(paymentMethod);var settingKey = $"PaymentMethodRestictionsGroup.{paymentMethod.SystemName}";await _settingService.SetSetting(settingKey, new PaymentRestrictedSettings { Ids = groupIds });@@ -168,8 +164,7 @@ namespace Grand.Business.Checkout.Services.Payments/// <param name="shippingIds">A list of country identifiers</param>public virtual async Task SaveRestrictedShippingIds(IPaymentProvider paymentMethod, List<string> shippingIds){- if (paymentMethod == null)- throw new ArgumentNullException(nameof(paymentMethod));+ ArgumentNullException.ThrowIfNull(paymentMethod);var settingKey = $"PaymentMethodRestictionsShipping.{paymentMethod.SystemName}";await _settingService.SetSetting(settingKey, new PaymentRestrictedSettings { Ids = shippingIds });@@ -182,8 +177,7 @@ namespace Grand.Business.Checkout.Services.Payments/// <returns>Process payment result</returns>public virtual async Task<ProcessPaymentResult> ProcessPayment(PaymentTransaction paymentTransaction){- if (paymentTransaction == null)- throw new ArgumentNullException(nameof(paymentTransaction));+ ArgumentNullException.ThrowIfNull(paymentTransaction);if (paymentTransaction.TransactionAmount == 0){@@ -206,8 +200,7 @@ namespace Grand.Business.Checkout.Services.Payments/// <param name="paymentTransaction">Payment transaction</param>public virtual async Task PostProcessPayment(PaymentTransaction paymentTransaction){- if (paymentTransaction == null)- throw new ArgumentNullException(nameof(paymentTransaction));+ ArgumentNullException.ThrowIfNull(paymentTransaction);if (paymentTransaction.TransactionStatus == TransactionStatus.Paid)return;@@ -224,8 +217,7 @@ namespace Grand.Business.Checkout.Services.Payments/// <param name="paymentTransaction">Payment Transaction</param>public virtual async Task PostRedirectPayment(PaymentTransaction paymentTransaction){- if (paymentTransaction == null)- throw new ArgumentNullException(nameof(paymentTransaction));+ ArgumentNullException.ThrowIfNull(paymentTransaction);//already paid or order.OrderTotal == 0if (paymentTransaction.TransactionStatus == TransactionStatus.Paid)@@ -243,8 +235,7 @@ namespace Grand.Business.Checkout.Services.Payments/// <param name="paymentTransaction">Payment transaction</param>public virtual async Task CancelPayment(PaymentTransaction paymentTransaction){- if (paymentTransaction == null)- throw new ArgumentNullException(nameof(paymentTransaction));+ ArgumentNullException.ThrowIfNull(paymentTransaction);var paymentMethod = LoadPaymentMethodBySystemName(paymentTransaction.PaymentMethodSystemName);if (paymentMethod == null)@@ -261,8 +252,7 @@ namespace Grand.Business.Checkout.Services.Payments/// <returns>Result</returns>public virtual async Task<bool> CanRePostRedirectPayment(PaymentTransaction paymentTransaction){- if (paymentTransaction == null)- throw new ArgumentNullException(nameof(paymentTransaction));+ ArgumentNullException.ThrowIfNull(paymentTransaction);if (!_paymentSettings.AllowRePostingPayments)return false;@@ -323,8 +313,7 @@ namespace Grand.Business.Checkout.Services.Payments/// <returns>Capture payment result</returns>public virtual async Task<CapturePaymentResult> Capture(PaymentTransaction paymentTransaction){- if (paymentTransaction == null)- throw new ArgumentNullException(nameof(paymentTransaction));+ ArgumentNullException.ThrowIfNull(paymentTransaction);var paymentMethod = LoadPaymentMethodBySystemName(paymentTransaction.PaymentMethodSystemName);if (paymentMethod == null)@@ -395,8 +384,7 @@ namespace Grand.Business.Checkout.Services.Payments/// <returns>Result</returns>public virtual async Task<VoidPaymentResult> Void(PaymentTransaction paymentTransaction){- if (paymentTransaction == null)- throw new ArgumentNullException(nameof(paymentTransaction));+ ArgumentNullException.ThrowIfNull(paymentTransaction);var paymentMethod = LoadPaymentMethodBySystemName(paymentTransaction.PaymentMethodSystemName);if (paymentMethod == null)diff --git a/src/Business/Grand.Business.Checkout/Services/Payments/PaymentTransactionService.cs b/src/Business/Grand.Business.Checkout/Services/Payments/PaymentTransactionService.csindex 6c1bfad37..98f9a488d 100644--- a/src/Business/Grand.Business.Checkout/Services/Payments/PaymentTransactionService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Payments/PaymentTransactionService.cs@@ -26,8 +26,7 @@ namespace Grand.Business.Checkout.Services.Payments/// <param name="paymentTransaction">payment transaction</param>public virtual async Task InsertPaymentTransaction(PaymentTransaction paymentTransaction){- if (paymentTransaction == null)- throw new ArgumentNullException(nameof(paymentTransaction));+ ArgumentNullException.ThrowIfNull(paymentTransaction);await _repositoryPaymentTransaction.InsertAsync(paymentTransaction);@@ -41,8 +40,7 @@ namespace Grand.Business.Checkout.Services.Payments/// <param name="paymentTransaction">payment transaction</param>public virtual async Task UpdatePaymentTransaction(PaymentTransaction paymentTransaction){- if (paymentTransaction == null)- throw new ArgumentNullException(nameof(paymentTransaction));+ ArgumentNullException.ThrowIfNull(paymentTransaction);await _repositoryPaymentTransaction.UpdateAsync(paymentTransaction);@@ -57,8 +55,7 @@ namespace Grand.Business.Checkout.Services.Payments/// <param name="paymentTransaction">payment transaction</param>public virtual async Task DeletePaymentTransaction(PaymentTransaction paymentTransaction){- if (paymentTransaction == null)- throw new ArgumentNullException(nameof(paymentTransaction));+ ArgumentNullException.ThrowIfNull(paymentTransaction);await _repositoryPaymentTransaction.DeleteAsync(paymentTransaction);diff --git a/src/Business/Grand.Business.Checkout/Services/Shipping/DeliveryDateService.cs b/src/Business/Grand.Business.Checkout/Services/Shipping/DeliveryDateService.csindex a5c5bba53..5935f3164 100644--- a/src/Business/Grand.Business.Checkout/Services/Shipping/DeliveryDateService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Shipping/DeliveryDateService.cs@@ -69,8 +69,7 @@ namespace Grand.Business.Checkout.Services.Shipping/// <param name="deliveryDate">Delivery date</param>public virtual async Task InsertDeliveryDate(DeliveryDate deliveryDate){- if (deliveryDate == null)- throw new ArgumentNullException(nameof(deliveryDate));+ ArgumentNullException.ThrowIfNull(deliveryDate);await _deliveryDateRepository.InsertAsync(deliveryDate);@@ -87,8 +86,7 @@ namespace Grand.Business.Checkout.Services.Shipping/// <param name="deliveryDate">Delivery date</param>public virtual async Task UpdateDeliveryDate(DeliveryDate deliveryDate){- if (deliveryDate == null)- throw new ArgumentNullException(nameof(deliveryDate));+ ArgumentNullException.ThrowIfNull(deliveryDate);await _deliveryDateRepository.UpdateAsync(deliveryDate);@@ -105,8 +103,7 @@ namespace Grand.Business.Checkout.Services.Shipping/// <param name="deliveryDate">The delivery date</param>public virtual async Task DeleteDeliveryDate(DeliveryDate deliveryDate){- if (deliveryDate == null)- throw new ArgumentNullException(nameof(deliveryDate));+ ArgumentNullException.ThrowIfNull(deliveryDate);await _deliveryDateRepository.DeleteAsync(deliveryDate);diff --git a/src/Business/Grand.Business.Checkout/Services/Shipping/PickupPointService.cs b/src/Business/Grand.Business.Checkout/Services/Shipping/PickupPointService.csindex d4bfb3f3e..8941b9088 100644--- a/src/Business/Grand.Business.Checkout/Services/Shipping/PickupPointService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Shipping/PickupPointService.cs@@ -79,8 +79,7 @@ namespace Grand.Business.Checkout.Services.Shipping/// <param name="pickupPoint">Pickup Point</param>public virtual async Task InsertPickupPoint(PickupPoint pickupPoint){- if (pickupPoint == null)- throw new ArgumentNullException(nameof(pickupPoint));+ ArgumentNullException.ThrowIfNull(pickupPoint);await _pickupPointsRepository.InsertAsync(pickupPoint);@@ -97,8 +96,7 @@ namespace Grand.Business.Checkout.Services.Shipping/// <param name="pickupPoint">Pickup Point</param>public virtual async Task UpdatePickupPoint(PickupPoint pickupPoint){- if (pickupPoint == null)- throw new ArgumentNullException(nameof(pickupPoint));+ ArgumentNullException.ThrowIfNull(pickupPoint);await _pickupPointsRepository.UpdateAsync(pickupPoint);@@ -115,8 +113,7 @@ namespace Grand.Business.Checkout.Services.Shipping/// <param name="pickupPoint">pickup point</param>public virtual async Task DeletePickupPoint(PickupPoint pickupPoint){- if (pickupPoint == null)- throw new ArgumentNullException(nameof(pickupPoint));+ ArgumentNullException.ThrowIfNull(pickupPoint);await _pickupPointsRepository.DeleteAsync(pickupPoint);diff --git a/src/Business/Grand.Business.Checkout/Services/Shipping/ShipmentService.cs b/src/Business/Grand.Business.Checkout/Services/Shipping/ShipmentService.csindex 6362af620..4c531c3e1 100644--- a/src/Business/Grand.Business.Checkout/Services/Shipping/ShipmentService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Shipping/ShipmentService.cs@@ -130,8 +130,7 @@ namespace Grand.Business.Checkout.Services.Shipping/// <param name="shipment">Shipment</param>public virtual async Task InsertShipment(Shipment shipment){- if (shipment == null)- throw new ArgumentNullException(nameof(shipment));+ ArgumentNullException.ThrowIfNull(shipment);var shipmentExists = _shipmentRepository.Table.FirstOrDefault();shipment.ShipmentNumber = shipmentExists != null ? _shipmentRepository.Table.Max(x => x.ShipmentNumber) + 1 : 1;await _shipmentRepository.InsertAsync(shipment);@@ -146,8 +145,7 @@ namespace Grand.Business.Checkout.Services.Shipping/// <param name="shipment">Shipment</param>public virtual async Task UpdateShipment(Shipment shipment){- if (shipment == null)- throw new ArgumentNullException(nameof(shipment));+ ArgumentNullException.ThrowIfNull(shipment);await _shipmentRepository.UpdateAsync(shipment);@@ -161,8 +159,7 @@ namespace Grand.Business.Checkout.Services.Shipping/// <param name="shipment">Shipment</param>public virtual async Task DeleteShipment(Shipment shipment){- if (shipment == null)- throw new ArgumentNullException(nameof(shipment));+ ArgumentNullException.ThrowIfNull(shipment);await _shipmentRepository.DeleteAsync(shipment);@@ -178,8 +175,7 @@ namespace Grand.Business.Checkout.Services.Shipping/// <param name="shipmentNote">The order note</param>public virtual async Task DeleteShipmentNote(ShipmentNote shipmentNote){- if (shipmentNote == null)- throw new ArgumentNullException(nameof(shipmentNote));+ ArgumentNullException.ThrowIfNull(shipmentNote);await _shipmentNoteRepository.DeleteAsync(shipmentNote);@@ -193,8 +189,7 @@ namespace Grand.Business.Checkout.Services.Shipping/// <param name="shipmentNote">The shipment note</param>public virtual async Task InsertShipmentNote(ShipmentNote shipmentNote){- if (shipmentNote == null)- throw new ArgumentNullException(nameof(shipmentNote));+ ArgumentNullException.ThrowIfNull(shipmentNote);await _shipmentNoteRepository.InsertAsync(shipmentNote);diff --git a/src/Business/Grand.Business.Checkout/Services/Shipping/ShippingMethodService.cs b/src/Business/Grand.Business.Checkout/Services/Shipping/ShippingMethodService.csindex 4bbbae133..52f92b965 100644--- a/src/Business/Grand.Business.Checkout/Services/Shipping/ShippingMethodService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Shipping/ShippingMethodService.cs@@ -46,8 +46,7 @@ namespace Grand.Business.Checkout.Services.Shipping/// <param name="shippingMethod">The shipping method</param>public virtual async Task DeleteShippingMethod(ShippingMethod shippingMethod){- if (shippingMethod == null)- throw new ArgumentNullException(nameof(shippingMethod));+ ArgumentNullException.ThrowIfNull(shippingMethod);await _shippingMethodRepository.DeleteAsync(shippingMethod);@@ -103,8 +102,7 @@ namespace Grand.Business.Checkout.Services.Shipping/// <param name="shippingMethod">Shipping method</param>public virtual async Task InsertShippingMethod(ShippingMethod shippingMethod){- if (shippingMethod == null)- throw new ArgumentNullException(nameof(shippingMethod));+ ArgumentNullException.ThrowIfNull(shippingMethod);await _shippingMethodRepository.InsertAsync(shippingMethod);@@ -121,8 +119,7 @@ namespace Grand.Business.Checkout.Services.Shipping/// <param name="shippingMethod">Shipping method</param>public virtual async Task UpdateShippingMethod(ShippingMethod shippingMethod){- if (shippingMethod == null)- throw new ArgumentNullException(nameof(shippingMethod));+ ArgumentNullException.ThrowIfNull(shippingMethod);await _shippingMethodRepository.UpdateAsync(shippingMethod);diff --git a/src/Business/Grand.Business.Checkout/Services/Shipping/ShippingService.cs b/src/Business/Grand.Business.Checkout/Services/Shipping/ShippingService.csindex cb4cb259d..8bfed5f0e 100644--- a/src/Business/Grand.Business.Checkout/Services/Shipping/ShippingService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Shipping/ShippingService.cs@@ -158,8 +158,7 @@ namespace Grand.Business.Checkout.Services.ShippingAddress shippingAddress, string allowedShippingRateMethodSystemName = "",Store store = null){- if (cart == null)- throw new ArgumentNullException(nameof(cart));+ ArgumentNullException.ThrowIfNull(cart);var result = new GetShippingOptionResponse();diff --git a/src/Business/Grand.Business.Checkout/Services/Shipping/WarehouseService.cs b/src/Business/Grand.Business.Checkout/Services/Shipping/WarehouseService.csindex cafb374f8..6d2f7f3d4 100644--- a/src/Business/Grand.Business.Checkout/Services/Shipping/WarehouseService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Shipping/WarehouseService.cs@@ -69,8 +69,7 @@ namespace Grand.Business.Checkout.Services.Shipping/// <param name="warehouse">Warehouse</param>public virtual async Task InsertWarehouse(Warehouse warehouse){- if (warehouse == null)- throw new ArgumentNullException(nameof(warehouse));+ ArgumentNullException.ThrowIfNull(warehouse);await _warehouseRepository.InsertAsync(warehouse);@@ -87,8 +86,7 @@ namespace Grand.Business.Checkout.Services.Shipping/// <param name="warehouse">Warehouse</param>public virtual async Task UpdateWarehouse(Warehouse warehouse){- if (warehouse == null)- throw new ArgumentNullException(nameof(warehouse));+ ArgumentNullException.ThrowIfNull(warehouse);await _warehouseRepository.UpdateAsync(warehouse);@@ -105,8 +103,7 @@ namespace Grand.Business.Checkout.Services.Shipping/// <param name="warehouse">The warehouse</param>public virtual async Task DeleteWarehouse(Warehouse warehouse){- if (warehouse == null)- throw new ArgumentNullException(nameof(warehouse));+ ArgumentNullException.ThrowIfNull(warehouse);await _warehouseRepository.DeleteAsync(warehouse);diff --git a/src/Business/Grand.Business.Cms/Services/BlogService.cs b/src/Business/Grand.Business.Cms/Services/BlogService.csindex aab60a19a..2cf52a11e 100644--- a/src/Business/Grand.Business.Cms/Services/BlogService.cs+++ b/src/Business/Grand.Business.Cms/Services/BlogService.cs@@ -77,7 +77,7 @@ namespace Grand.Business.Cms.Servicesif (!string.IsNullOrEmpty(categoryId)){- var category = _blogCategoryRepository.Table.FirstOrDefault(x => x.Id == categoryId);+ var category = await _blogCategoryRepository.GetOneAsync(x => x.Id == categoryId);if (category != null){var postsIds = category.BlogPosts.Select(x => x.BlogPostId);@@ -182,8 +182,7 @@ namespace Grand.Business.Cms.Services/// <param name="blogPost">Blog post</param>public virtual async Task InsertBlogPost(BlogPost blogPost){- if (blogPost == null)- throw new ArgumentNullException(nameof(blogPost));+ ArgumentNullException.ThrowIfNull(blogPost);await _blogPostRepository.InsertAsync(blogPost);@@ -197,8 +196,7 @@ namespace Grand.Business.Cms.Services/// <param name="blogPost">Blog post</param>public virtual async Task UpdateBlogPost(BlogPost blogPost){- if (blogPost == null)- throw new ArgumentNullException(nameof(blogPost));+ ArgumentNullException.ThrowIfNull(blogPost);await _blogPostRepository.UpdateAsync(blogPost);@@ -211,8 +209,7 @@ namespace Grand.Business.Cms.Services/// <param name="blogPost">Blog post</param>public virtual async Task DeleteBlogPost(BlogPost blogPost){- if (blogPost == null)- throw new ArgumentNullException(nameof(blogPost));+ ArgumentNullException.ThrowIfNull(blogPost);await _blogPostRepository.DeleteAsync(blogPost);@@ -280,8 +277,7 @@ namespace Grand.Business.Cms.Services/// <param name="blogComment">Blog post comment</param>public virtual async Task InsertBlogComment(BlogComment blogComment){- if (blogComment == null)- throw new ArgumentNullException(nameof(blogComment));+ ArgumentNullException.ThrowIfNull(blogComment);await _blogCommentRepository.InsertAsync(blogComment);@@ -291,8 +287,7 @@ namespace Grand.Business.Cms.Servicespublic virtual async Task DeleteBlogComment(BlogComment blogComment){- if (blogComment == null)- throw new ArgumentNullException(nameof(blogComment));+ ArgumentNullException.ThrowIfNull(blogComment);await _blogCommentRepository.DeleteAsync(blogComment);}@@ -329,7 +324,7 @@ namespace Grand.Business.Cms.Servicesif (string.IsNullOrEmpty(blogCategorySeName))throw new ArgumentNullException(nameof(blogCategorySeName));- return await Task.FromResult(_blogCategoryRepository.Table.FirstOrDefault(x => x.SeName == blogCategorySeName.ToLowerInvariant()));+ return await _blogCategoryRepository.GetOneAsync(x => x.SeName == blogCategorySeName.ToLowerInvariant());}/// <summary>@@ -355,8 +350,7 @@ namespace Grand.Business.Cms.Services/// <param name="blogCategory">Blog category</param>public virtual async Task<BlogCategory> InsertBlogCategory(BlogCategory blogCategory){- if (blogCategory == null)- throw new ArgumentNullException(nameof(blogCategory));+ ArgumentNullException.ThrowIfNull(blogCategory);await _blogCategoryRepository.InsertAsync(blogCategory);@@ -372,8 +366,7 @@ namespace Grand.Business.Cms.Services/// <param name="blogCategory">Blog category</param>public virtual async Task<BlogCategory> UpdateBlogCategory(BlogCategory blogCategory){- if (blogCategory == null)- throw new ArgumentNullException(nameof(blogCategory));+ ArgumentNullException.ThrowIfNull(blogCategory);await _blogCategoryRepository.UpdateAsync(blogCategory);@@ -389,8 +382,7 @@ namespace Grand.Business.Cms.Services/// <param name="blogCategory">Blog category</param>public virtual async Task DeleteBlogCategory(BlogCategory blogCategory){- if (blogCategory == null)- throw new ArgumentNullException(nameof(blogCategory));+ ArgumentNullException.ThrowIfNull(blogCategory);await _blogCategoryRepository.DeleteAsync(blogCategory);@@ -418,8 +410,7 @@ namespace Grand.Business.Cms.Services/// <param name="blogProduct">Blog product</param>public virtual async Task InsertBlogProduct(BlogProduct blogProduct){- if (blogProduct == null)- throw new ArgumentNullException(nameof(blogProduct));+ ArgumentNullException.ThrowIfNull(blogProduct);await _blogProductRepository.InsertAsync(blogProduct);@@ -434,8 +425,7 @@ namespace Grand.Business.Cms.Services/// <param name="blogProduct">Blog product</param>public virtual async Task UpdateBlogProduct(BlogProduct blogProduct){- if (blogProduct == null)- throw new ArgumentNullException(nameof(blogProduct));+ ArgumentNullException.ThrowIfNull(blogProduct);await _blogProductRepository.UpdateAsync(blogProduct);@@ -450,8 +440,7 @@ namespace Grand.Business.Cms.Services/// <param name="blogProduct">Blog product</param>public virtual async Task DeleteBlogProduct(BlogProduct blogProduct){- if (blogProduct == null)- throw new ArgumentNullException(nameof(blogProduct));+ ArgumentNullException.ThrowIfNull(blogProduct);await _blogProductRepository.DeleteAsync(blogProduct);diff --git a/src/Business/Grand.Business.Cms/Services/KnowledgebaseService.cs b/src/Business/Grand.Business.Cms/Services/KnowledgebaseService.csindex fd18cc55c..4c07eb75b 100644--- a/src/Business/Grand.Business.Cms/Services/KnowledgebaseService.cs+++ b/src/Business/Grand.Business.Cms/Services/KnowledgebaseService.cs@@ -81,7 +81,7 @@ namespace Grand.Business.Cms.Services/// <returns>knowledge base category</returns>public virtual async Task<KnowledgebaseCategory> GetKnowledgebaseCategory(string id){- return await Task.FromResult(_knowledgebaseCategoryRepository.Table.FirstOrDefault(x => x.Id == id));+ return await _knowledgebaseCategoryRepository.GetOneAsync(x => x.Id == id);}/// <summary>@@ -545,8 +545,7 @@ namespace Grand.Business.Cms.Services/// <param name="articleComment">Article comment</param>public virtual async Task InsertArticleComment(KnowledgebaseArticleComment articleComment){- if (articleComment == null)- throw new ArgumentNullException(nameof(articleComment));+ ArgumentNullException.ThrowIfNull(articleComment);await _articleCommentRepository.InsertAsync(articleComment);@@ -613,8 +612,7 @@ namespace Grand.Business.Cms.Servicespublic virtual async Task DeleteArticleComment(KnowledgebaseArticleComment articleComment){- if (articleComment == null)- throw new ArgumentNullException(nameof(articleComment));+ ArgumentNullException.ThrowIfNull(articleComment);await _articleCommentRepository.DeleteAsync(articleComment);}diff --git a/src/Business/Grand.Business.Cms/Services/NewsService.cs b/src/Business/Grand.Business.Cms/Services/NewsService.csindex e9785b390..84fa97c6e 100644--- a/src/Business/Grand.Business.Cms/Services/NewsService.cs+++ b/src/Business/Grand.Business.Cms/Services/NewsService.cs@@ -106,8 +106,7 @@ namespace Grand.Business.Cms.Services/// <param name="news">News item</param>public virtual async Task InsertNews(NewsItem news){- if (news == null)- throw new ArgumentNullException(nameof(news));+ ArgumentNullException.ThrowIfNull(news);await _newsItemRepository.InsertAsync(news);@@ -121,8 +120,7 @@ namespace Grand.Business.Cms.Services/// <param name="news">News item</param>public virtual async Task UpdateNews(NewsItem news){- if (news == null)- throw new ArgumentNullException(nameof(news));+ ArgumentNullException.ThrowIfNull(news);await _newsItemRepository.UpdateAsync(news);@@ -135,8 +133,7 @@ namespace Grand.Business.Cms.Services/// <param name="newsItem">News item</param>public virtual async Task DeleteNews(NewsItem newsItem){- if (newsItem == null)- throw new ArgumentNullException(nameof(newsItem));+ ArgumentNullException.ThrowIfNull(newsItem);await _newsItemRepository.DeleteAsync(newsItem);diff --git a/src/Business/Grand.Business.Cms/Services/PageLayoutService.cs b/src/Business/Grand.Business.Cms/Services/PageLayoutService.csindex 62789401d..9463b15c0 100644--- a/src/Business/Grand.Business.Cms/Services/PageLayoutService.cs+++ b/src/Business/Grand.Business.Cms/Services/PageLayoutService.cs@@ -76,8 +76,7 @@ namespace Grand.Business.Cms.Services/// <param name="pageLayout">Page layout</param>public virtual async Task InsertPageLayout(PageLayout pageLayout){- if (pageLayout == null)- throw new ArgumentNullException(nameof(pageLayout));+ ArgumentNullException.ThrowIfNull(pageLayout);await _pageLayoutRepository.InsertAsync(pageLayout);@@ -94,8 +93,7 @@ namespace Grand.Business.Cms.Services/// <param name="pageLayout">Page layout</param>public virtual async Task UpdatePageLayout(PageLayout pageLayout){- if (pageLayout == null)- throw new ArgumentNullException(nameof(pageLayout));+ ArgumentNullException.ThrowIfNull(pageLayout);await _pageLayoutRepository.UpdateAsync(pageLayout);@@ -111,8 +109,7 @@ namespace Grand.Business.Cms.Services/// <param name="pageLayout">Page layout</param>public virtual async Task DeletePageLayout(PageLayout pageLayout){- if (pageLayout == null)- throw new ArgumentNullException(nameof(pageLayout));+ ArgumentNullException.ThrowIfNull(pageLayout);await _pageLayoutRepository.DeleteAsync(pageLayout);diff --git a/src/Business/Grand.Business.Cms/Services/PageService.cs b/src/Business/Grand.Business.Cms/Services/PageService.csindex aa234189d..7c9f52623 100644--- a/src/Business/Grand.Business.Cms/Services/PageService.cs+++ b/src/Business/Grand.Business.Cms/Services/PageService.cs@@ -133,8 +133,7 @@ namespace Grand.Business.Cms.Services/// <param name="page">Page</param>public virtual async Task InsertPage(Page page){- if (page == null)- throw new ArgumentNullException(nameof(page));+ ArgumentNullException.ThrowIfNull(page);await _pageRepository.InsertAsync(page);@@ -150,8 +149,7 @@ namespace Grand.Business.Cms.Services/// <param name="page">Page</param>public virtual async Task UpdatePage(Page page){- if (page == null)- throw new ArgumentNullException(nameof(page));+ ArgumentNullException.ThrowIfNull(page);await _pageRepository.UpdateAsync(page);@@ -167,8 +165,7 @@ namespace Grand.Business.Cms.Services/// <param name="page">Page</param>public virtual async Task DeletePage(Page page){- if (page == null)- throw new ArgumentNullException(nameof(page));+ ArgumentNullException.ThrowIfNull(page);await _pageRepository.DeleteAsync(page);diff --git a/src/Business/Grand.Business.Cms/Services/RobotsTxtService.cs b/src/Business/Grand.Business.Cms/Services/RobotsTxtService.csindex 9f41ff9b2..94c1b9128 100644--- a/src/Business/Grand.Business.Cms/Services/RobotsTxtService.cs+++ b/src/Business/Grand.Business.Cms/Services/RobotsTxtService.cs@@ -51,11 +51,7 @@ namespace Grand.Business.Cms.Servicesreturn await _cacheBase.GetAsync(key, async () =>{- var query = from p in _robotsRepository.Table- where p.StoreId == storeId- select p;-- var robotsTxt = await Task.FromResult(query.FirstOrDefault());+ var robotsTxt = await _robotsRepository.GetOneAsync(x=>x.StoreId == storeId);return robotsTxt;});}@@ -66,8 +62,7 @@ namespace Grand.Business.Cms.Services/// <param name="robotsTxt">robotsTxt</param>public virtual async Task InsertRobotsTxt(RobotsTxt robotsTxt){- if (robotsTxt == null)- throw new ArgumentNullException(nameof(robotsTxt));+ ArgumentNullException.ThrowIfNull(robotsTxt);await _robotsRepository.InsertAsync(robotsTxt);@@ -83,8 +78,7 @@ namespace Grand.Business.Cms.Services/// <param name="robotsTxt">robotsTxt</param>public virtual async Task UpdateRobotsTxt(RobotsTxt robotsTxt){- if (robotsTxt == null)- throw new ArgumentNullException(nameof(robotsTxt));+ ArgumentNullException.ThrowIfNull(robotsTxt);await _robotsRepository.UpdateAsync(robotsTxt);@@ -100,8 +94,7 @@ namespace Grand.Business.Cms.Services/// <param name="robotsTxt">robotsTxt</param>public virtual async Task DeleteRobotsTxt(RobotsTxt robotsTxt){- if (robotsTxt == null)- throw new ArgumentNullException(nameof(robotsTxt));+ ArgumentNullException.ThrowIfNull(robotsTxt);await _robotsRepository.DeleteAsync(robotsTxt);diff --git a/src/Business/Grand.Business.Common/Services/Addresses/AddressAttributeService.cs b/src/Business/Grand.Business.Common/Services/Addresses/AddressAttributeService.csindex 51a55cd68..aa29c4c83 100644--- a/src/Business/Grand.Business.Common/Services/Addresses/AddressAttributeService.cs+++ b/src/Business/Grand.Business.Common/Services/Addresses/AddressAttributeService.cs@@ -79,8 +79,7 @@ namespace Grand.Business.Common.Services.Addresses/// <param name="addressAttribute">Address attribute</param>public virtual async Task InsertAddressAttribute(AddressAttribute addressAttribute){- if (addressAttribute == null)- throw new ArgumentNullException(nameof(addressAttribute));+ ArgumentNullException.ThrowIfNull(addressAttribute);await _addressAttributeRepository.InsertAsync(addressAttribute);@@ -97,8 +96,7 @@ namespace Grand.Business.Common.Services.Addresses/// <param name="addressAttribute">Address attribute</param>public virtual async Task UpdateAddressAttribute(AddressAttribute addressAttribute){- if (addressAttribute == null)- throw new ArgumentNullException(nameof(addressAttribute));+ ArgumentNullException.ThrowIfNull(addressAttribute);await _addressAttributeRepository.UpdateAsync(addressAttribute);@@ -114,8 +112,7 @@ namespace Grand.Business.Common.Services.Addresses/// <param name="addressAttribute">Address attribute</param>public virtual async Task DeleteAddressAttribute(AddressAttribute addressAttribute){- if (addressAttribute == null)- throw new ArgumentNullException(nameof(addressAttribute));+ ArgumentNullException.ThrowIfNull(addressAttribute);await _addressAttributeRepository.DeleteAsync(addressAttribute);@@ -132,8 +129,7 @@ namespace Grand.Business.Common.Services.Addresses/// <param name="addressAttributeValue">Address attribute value</param>public virtual async Task InsertAddressAttributeValue(AddressAttributeValue addressAttributeValue){- if (addressAttributeValue == null)- throw new ArgumentNullException(nameof(addressAttributeValue));+ ArgumentNullException.ThrowIfNull(addressAttributeValue);await _addressAttributeRepository.AddToSet(addressAttributeValue.AddressAttributeId, x => x.AddressAttributeValues, addressAttributeValue);@@ -150,8 +146,7 @@ namespace Grand.Business.Common.Services.Addresses/// <param name="addressAttributeValue">Address attribute value</param>public virtual async Task UpdateAddressAttributeValue(AddressAttributeValue addressAttributeValue){- if (addressAttributeValue == null)- throw new ArgumentNullException(nameof(addressAttributeValue));+ ArgumentNullException.ThrowIfNull(addressAttributeValue);await _addressAttributeRepository.UpdateToSet(addressAttributeValue.AddressAttributeId,x => x.AddressAttributeValues, z => z.Id, addressAttributeValue.Id, addressAttributeValue);@@ -169,8 +164,7 @@ namespace Grand.Business.Common.Services.Addresses/// <param name="addressAttributeValue">Address attribute value</param>public virtual async Task DeleteAddressAttributeValue(AddressAttributeValue addressAttributeValue){- if (addressAttributeValue == null)- throw new ArgumentNullException(nameof(addressAttributeValue));+ ArgumentNullException.ThrowIfNull(addressAttributeValue);await _addressAttributeRepository.PullFilter(addressAttributeValue.AddressAttributeId, x => x.AddressAttributeValues, z => z.Id, addressAttributeValue.Id);diff --git a/src/Business/Grand.Business.Common/Services/Configuration/SettingService.cs b/src/Business/Grand.Business.Common/Services/Configuration/SettingService.csindex 1b0f70431..d28d2b5b3 100644--- a/src/Business/Grand.Business.Common/Services/Configuration/SettingService.cs+++ b/src/Business/Grand.Business.Common/Services/Configuration/SettingService.cs@@ -61,8 +61,7 @@ namespace Grand.Business.Common.Services.Configuration/// <param name="clearCache">A value indicating whether to clear cache after setting update</param>public virtual async Task InsertSetting(Setting setting, bool clearCache = true){- if (setting == null)- throw new ArgumentNullException(nameof(setting));+ ArgumentNullException.ThrowIfNull(setting);await _settingRepository.InsertAsync(setting);@@ -79,8 +78,7 @@ namespace Grand.Business.Common.Services.Configuration/// <param name="clearCache">A value indicating whether to clear cache after setting update</param>public virtual async Task UpdateSetting(Setting setting, bool clearCache = true){- if (setting == null)- throw new ArgumentNullException(nameof(setting));+ ArgumentNullException.ThrowIfNull(setting);await _settingRepository.UpdateAsync(setting);@@ -96,8 +94,7 @@ namespace Grand.Business.Common.Services.Configuration/// <param name="setting">Setting</param>public virtual async Task DeleteSetting(Setting setting){- if (setting == null)- throw new ArgumentNullException(nameof(setting));+ ArgumentNullException.ThrowIfNull(setting);await _settingRepository.DeleteAsync(setting);@@ -152,8 +149,7 @@ namespace Grand.Business.Common.Services.Configuration/// <param name="clearCache">A value indicating whether to clear cache after setting update</param>public virtual async Task SetSetting<T>(string key, T value, string storeId = "", bool clearCache = true){- if (key == null)- throw new ArgumentNullException(nameof(key));+ ArgumentNullException.ThrowIfNull(key);key = key.Trim().ToLowerInvariant();diff --git a/src/Business/Grand.Business.Common/Services/Directory/CountryService.cs b/src/Business/Grand.Business.Common/Services/Directory/CountryService.csindex de677e8c7..6bd301201 100644--- a/src/Business/Grand.Business.Common/Services/Directory/CountryService.cs+++ b/src/Business/Grand.Business.Common/Services/Directory/CountryService.cs@@ -156,7 +156,7 @@ namespace Grand.Business.Common.Services.Directoryvar key = string.Format(CacheKey.COUNTRIES_BY_TWOLETTER, twoLetterIsoCode);return await _cacheBase.GetAsync(key, async () =>{- return await Task.FromResult(_countryRepository.Table.FirstOrDefault(x => x.TwoLetterIsoCode == twoLetterIsoCode));+ return await _countryRepository.GetOneAsync(x => x.TwoLetterIsoCode == twoLetterIsoCode);});}@@ -170,7 +170,7 @@ namespace Grand.Business.Common.Services.Directoryvar key = string.Format(CacheKey.COUNTRIES_BY_THREELETTER, threeLetterIsoCode);return await _cacheBase.GetAsync(key, async () =>{- return await Task.FromResult(_countryRepository.Table.FirstOrDefault(x => x.ThreeLetterIsoCode == threeLetterIsoCode));+ return await _countryRepository.GetOneAsync(x => x.ThreeLetterIsoCode == threeLetterIsoCode);});}@@ -180,8 +180,7 @@ namespace Grand.Business.Common.Services.Directory/// <param name="country">Country</param>public virtual async Task InsertCountry(Country country){- if (country == null)- throw new ArgumentNullException(nameof(country));+ ArgumentNullException.ThrowIfNull(country);await _countryRepository.InsertAsync(country);@@ -197,8 +196,7 @@ namespace Grand.Business.Common.Services.Directory/// <param name="country">Country</param>public virtual async Task UpdateCountry(Country country){- if (country == null)- throw new ArgumentNullException(nameof(country));+ ArgumentNullException.ThrowIfNull(country);await _countryRepository.UpdateAsync(country);@@ -213,8 +211,7 @@ namespace Grand.Business.Common.Services.Directory/// <param name="country">Country</param>public virtual async Task DeleteCountry(Country country){- if (country == null)- throw new ArgumentNullException(nameof(country));+ ArgumentNullException.ThrowIfNull(country);await _countryRepository.DeleteAsync(country);@@ -252,8 +249,7 @@ namespace Grand.Business.Common.Services.Directory/// <param name="countryId">Country ident</param>public virtual async Task InsertStateProvince(StateProvince stateProvince, string countryId){- if (stateProvince == null)- throw new ArgumentNullException(nameof(stateProvince));+ ArgumentNullException.ThrowIfNull(stateProvince);var country = await GetCountryById(countryId);if (country == null)@@ -271,8 +267,7 @@ namespace Grand.Business.Common.Services.Directory/// <param name="countryId">Country ident</param>public virtual async Task UpdateStateProvince(StateProvince stateProvince, string countryId){- if (stateProvince == null)- throw new ArgumentNullException(nameof(stateProvince));+ ArgumentNullException.ThrowIfNull(stateProvince);var country = await GetCountryById(countryId);if (country == null)@@ -299,8 +294,7 @@ namespace Grand.Business.Common.Services.Directory/// <param name="countryId">Country ident</param>public virtual async Task DeleteStateProvince(StateProvince stateProvince, string countryId){- if (stateProvince == null)- throw new ArgumentNullException(nameof(stateProvince));+ ArgumentNullException.ThrowIfNull(stateProvince);var country = await GetCountryById(countryId);if (country == null)diff --git a/src/Business/Grand.Business.Common/Services/Directory/CurrencyService.cs b/src/Business/Grand.Business.Common/Services/Directory/CurrencyService.csindex 3425d96a4..36cbdf433 100644--- a/src/Business/Grand.Business.Common/Services/Directory/CurrencyService.cs+++ b/src/Business/Grand.Business.Common/Services/Directory/CurrencyService.cs@@ -137,8 +137,7 @@ namespace Grand.Business.Common.Services.Directory/// <param name="currency">Currency</param>public virtual async Task InsertCurrency(Currency currency){- if (currency == null)- throw new ArgumentNullException(nameof(currency));+ ArgumentNullException.ThrowIfNull(currency);await _currencyRepository.InsertAsync(currency);@@ -154,8 +153,7 @@ namespace Grand.Business.Common.Services.Directory/// <param name="currency">Currency</param>public virtual async Task UpdateCurrency(Currency currency){- if (currency == null)- throw new ArgumentNullException(nameof(currency));+ ArgumentNullException.ThrowIfNull(currency);await _currencyRepository.UpdateAsync(currency);@@ -171,8 +169,7 @@ namespace Grand.Business.Common.Services.Directory/// <param name="currency">Currency</param>public virtual async Task DeleteCurrency(Currency currency){- if (currency == null)- throw new ArgumentNullException(nameof(currency));+ ArgumentNullException.ThrowIfNull(currency);await _currencyRepository.DeleteAsync(currency);@@ -205,11 +202,8 @@ namespace Grand.Business.Common.Services.Directory/// <returns>Converted value</returns>public virtual async Task<double> ConvertCurrency(double amount, Currency sourceCurrencyCode, Currency targetCurrencyCode){- if (sourceCurrencyCode == null)- throw new ArgumentNullException(nameof(sourceCurrencyCode));-- if (targetCurrencyCode == null)- throw new ArgumentNullException(nameof(targetCurrencyCode));+ ArgumentNullException.ThrowIfNull(sourceCurrencyCode);+ ArgumentNullException.ThrowIfNull(targetCurrencyCode);var result = amount;@@ -231,8 +225,7 @@ namespace Grand.Business.Common.Services.Directory/// <returns>Converted value</returns>public virtual async Task<double> ConvertToPrimaryExchangeRateCurrency(double amount, Currency sourceCurrencyCode){- if (sourceCurrencyCode == null)- throw new ArgumentNullException(nameof(sourceCurrencyCode));+ ArgumentNullException.ThrowIfNull(sourceCurrencyCode);var primaryExchangeRateCurrency = await GetPrimaryExchangeRateCurrency();if (primaryExchangeRateCurrency == null)@@ -254,8 +247,7 @@ namespace Grand.Business.Common.Services.Directory/// <returns>Converted value</returns>public virtual async Task<double> ConvertFromPrimaryExchangeRateCurrency(double amount, Currency targetCurrencyCode){- if (targetCurrencyCode == null)- throw new ArgumentNullException(nameof(targetCurrencyCode));+ ArgumentNullException.ThrowIfNull(targetCurrencyCode);var primaryExchangeRateCurrency = await GetPrimaryExchangeRateCurrency();if (primaryExchangeRateCurrency == null)@@ -280,8 +272,7 @@ namespace Grand.Business.Common.Services.Directory/// <returns>Converted value</returns>public virtual async Task<double> ConvertToPrimaryStoreCurrency(double amount, Currency sourceCurrencyCode){- if (sourceCurrencyCode == null)- throw new ArgumentNullException(nameof(sourceCurrencyCode));+ ArgumentNullException.ThrowIfNull(sourceCurrencyCode);var primaryStoreCurrency = await GetPrimaryStoreCurrency();var result = await ConvertCurrency(amount, sourceCurrencyCode, primaryStoreCurrency);diff --git a/src/Business/Grand.Business.Common/Services/Directory/GroupService.cs b/src/Business/Grand.Business.Common/Services/Directory/GroupService.csindex 08ffe2e33..2691ad43a 100644--- a/src/Business/Grand.Business.Common/Services/Directory/GroupService.cs+++ b/src/Business/Grand.Business.Common/Services/Directory/GroupService.cs@@ -84,8 +84,7 @@ namespace Grand.Business.Common.Services.Directory/// <param name="customerGroup">Customer group</param>public virtual async Task InsertCustomerGroup(CustomerGroup customerGroup){- if (customerGroup == null)- throw new ArgumentNullException(nameof(customerGroup));+ ArgumentNullException.ThrowIfNull(customerGroup);await _customerGroupRepository.InsertAsync(customerGroup);@@ -101,8 +100,7 @@ namespace Grand.Business.Common.Services.Directory/// <param name="customerGroup">Customer group</param>public virtual async Task UpdateCustomerGroup(CustomerGroup customerGroup){- if (customerGroup == null)- throw new ArgumentNullException(nameof(customerGroup));+ ArgumentNullException.ThrowIfNull(customerGroup);await _customerGroupRepository.UpdateAsync(customerGroup);@@ -118,8 +116,7 @@ namespace Grand.Business.Common.Services.Directory/// <param name="customerGroup">Customer group</param>public virtual async Task DeleteCustomerGroup(CustomerGroup customerGroup){- if (customerGroup == null)- throw new ArgumentNullException(nameof(customerGroup));+ ArgumentNullException.ThrowIfNull(customerGroup);if (customerGroup.IsSystem)throw new GrandException("System group could not be deleted");@@ -146,8 +143,7 @@ namespace Grand.Business.Common.Services.Directorybool onlyActiveCustomerGroups = true,bool? isSystem = null){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);if (string.IsNullOrEmpty(customerGroupSystemName))throw new ArgumentNullException(nameof(customerGroupSystemName));diff --git a/src/Business/Grand.Business.Common/Services/Directory/HistoryService.cs b/src/Business/Grand.Business.Common/Services/Directory/HistoryService.csindex 53ef245d0..ac0f8a849 100644--- a/src/Business/Grand.Business.Common/Services/Directory/HistoryService.cs+++ b/src/Business/Grand.Business.Common/Services/Directory/HistoryService.cs@@ -19,8 +19,7 @@ namespace Grand.Business.Common.Services.Directorypublic virtual async Task SaveObject<T>(T entity) where T : BaseEntity{- if (entity == null)- throw new ArgumentNullException(nameof(entity));+ ArgumentNullException.ThrowIfNull(entity);var history = new HistoryObject{Object = entity@@ -30,8 +29,7 @@ namespace Grand.Business.Common.Services.Directorypublic virtual async Task<IList<T>> GetHistoryForEntity<T>(BaseEntity entity) where T : BaseEntity{- if (entity == null)- throw new ArgumentNullException(nameof(entity));+ ArgumentNullException.ThrowIfNull(entity);var history = await Task.FromResult(_historyRepository.Table.Where(x => x.Object.Id == entity.Id).Select(x => (T)x.Object).ToList());return history;@@ -39,8 +37,7 @@ namespace Grand.Business.Common.Services.Directorypublic virtual async Task<IList<HistoryObject>> GetHistoryObjectForEntity(BaseEntity entity){- if (entity == null)- throw new ArgumentNullException(nameof(entity));+ ArgumentNullException.ThrowIfNull(entity);var history = await Task.FromResult(_historyRepository.Table.Where(x => x.Object.Id == entity.Id).ToList());return history;diff --git a/src/Business/Grand.Business.Common/Services/Directory/UserFieldService.cs b/src/Business/Grand.Business.Common/Services/Directory/UserFieldService.csindex 622744df9..a7d9d972f 100644--- a/src/Business/Grand.Business.Common/Services/Directory/UserFieldService.cs+++ b/src/Business/Grand.Business.Common/Services/Directory/UserFieldService.cs@@ -38,11 +38,8 @@ namespace Grand.Business.Common.Services.Directory/// <param name="storeId">Store identifier; pass "" if this attribute will be available for all stores</param>public virtual async Task SaveField<TPropType>(BaseEntity entity, string key, TPropType value, string storeId = ""){- if (entity == null)- throw new ArgumentNullException(nameof(entity));-- if (key == null)- throw new ArgumentNullException(nameof(key));+ ArgumentNullException.ThrowIfNull(entity);+ ArgumentNullException.ThrowIfNull(key);var collectionName = entity.GetType().Name;@@ -98,8 +95,7 @@ namespace Grand.Business.Common.Services.Directorypublic virtual async Task<TPropType> GetFieldsForEntity<TPropType>(BaseEntity entity, string key, string storeId = ""){- if (entity == null)- throw new ArgumentNullException(nameof(entity));+ ArgumentNullException.ThrowIfNull(entity);var collectionName = entity.GetType().Name;_ = _userFieldBaseEntityRepository.SetCollection(collectionName);diff --git a/src/Business/Grand.Business.Common/Services/Localization/LanguageService.cs b/src/Business/Grand.Business.Common/Services/Localization/LanguageService.csindex 54cb4386d..469a9885c 100644--- a/src/Business/Grand.Business.Common/Services/Localization/LanguageService.cs+++ b/src/Business/Grand.Business.Common/Services/Localization/LanguageService.cs@@ -111,8 +111,7 @@ namespace Grand.Business.Common.Services.Localization/// <param name="language">Language</param>public virtual async Task InsertLanguage(Language language){- if (language == null)- throw new ArgumentNullException(nameof(language));+ ArgumentNullException.ThrowIfNull(language);await _languageRepository.InsertAsync(language);@@ -129,8 +128,7 @@ namespace Grand.Business.Common.Services.Localization/// <param name="language">Language</param>public virtual async Task UpdateLanguage(Language language){- if (language == null)- throw new ArgumentNullException(nameof(language));+ ArgumentNullException.ThrowIfNull(language);//update languageawait _languageRepository.UpdateAsync(language);@@ -147,8 +145,7 @@ namespace Grand.Business.Common.Services.Localization/// <param name="language">Language</param>public virtual async Task DeleteLanguage(Language language){- if (language == null)- throw new ArgumentNullException(nameof(language));+ ArgumentNullException.ThrowIfNull(language);await _languageRepository.DeleteAsync(language);diff --git a/src/Business/Grand.Business.Common/Services/Localization/TranslationService.cs b/src/Business/Grand.Business.Common/Services/Localization/TranslationService.csindex cf9854ce2..5c89e22fa 100644--- a/src/Business/Grand.Business.Common/Services/Localization/TranslationService.cs+++ b/src/Business/Grand.Business.Common/Services/Localization/TranslationService.cs@@ -193,8 +193,7 @@ namespace Grand.Business.Common.Services.Localization/// <returns>Result in XML format</returns>public virtual async Task<string> ExportResourcesToXml(Language language){- if (language == null)- throw new ArgumentNullException(nameof(language));+ ArgumentNullException.ThrowIfNull(language);var sb = new StringBuilder();var xwSettings = new XmlWriterSettings {@@ -231,8 +230,7 @@ namespace Grand.Business.Common.Services.Localization/// <param name="xml">XML</param>public virtual async Task ImportResourcesFromXml(Language language, string xml){- if (language == null)- throw new ArgumentNullException(nameof(language));+ ArgumentNullException.ThrowIfNull(language);if (string.IsNullOrEmpty(xml))return;@@ -290,8 +288,7 @@ namespace Grand.Business.Common.Services.Localization/// <param name="xml">XML</param>public virtual async Task ImportResourcesFromXmlInstall(Language language, string xml){- if (language == null)- throw new ArgumentNullException(nameof(language));+ ArgumentNullException.ThrowIfNull(language);if (string.IsNullOrEmpty(xml))return;diff --git a/src/Business/Grand.Business.Common/Services/Pdf/HtmlToPdfService.cs b/src/Business/Grand.Business.Common/Services/Pdf/HtmlToPdfService.csindex 6fa3a6aa3..7dec69f3c 100644--- a/src/Business/Grand.Business.Common/Services/Pdf/HtmlToPdfService.cs+++ b/src/Business/Grand.Business.Common/Services/Pdf/HtmlToPdfService.cs@@ -33,11 +33,8 @@ namespace Grand.Business.Common.Services.Pdfpublic async Task PrintOrdersToPdf(Stream stream, IList<Order> orders, string languageId = "",string vendorId = ""){- if (stream == null)- throw new ArgumentNullException(nameof(stream));-- if (orders == null)- throw new ArgumentNullException(nameof(orders));+ ArgumentNullException.ThrowIfNull(stream);+ ArgumentNullException.ThrowIfNull(orders);var html = await _viewRenderService.RenderToStringAsync<(IList<Order>, string)>(OrderTemplate,new(orders, vendorId));@@ -48,8 +45,7 @@ namespace Grand.Business.Common.Services.Pdfpublic async Task<string> PrintOrderToPdf(Order order, string languageId, string vendorId = ""){- if (order == null)- throw new ArgumentNullException(nameof(order));+ ArgumentNullException.ThrowIfNull(order);var fileName = $"order_{order.OrderGuid}_{CommonHelper.GenerateRandomDigitCode(4)}.pdf";@@ -73,11 +69,8 @@ namespace Grand.Business.Common.Services.Pdfpublic async Task PrintPackagingSlipsToPdf(Stream stream, IList<Shipment> shipments, string languageId = ""){- if (stream == null)- throw new ArgumentNullException(nameof(stream));-- if (shipments == null)- throw new ArgumentNullException(nameof(shipments));+ ArgumentNullException.ThrowIfNull(stream);+ ArgumentNullException.ThrowIfNull(shipments);var lang = await _languageService.GetLanguageById(languageId);if (lang == null)@@ -91,8 +84,7 @@ namespace Grand.Business.Common.Services.Pdfpublic async Task<string> SaveOrderToBinary(Order order, string languageId, string vendorId = ""){- if (order == null)- throw new ArgumentNullException(nameof(order));+ ArgumentNullException.ThrowIfNull(order);var fileName = $"order_{order.OrderGuid}_{CommonHelper.GenerateRandomDigitCode(4)}";using MemoryStream ms = new MemoryStream();diff --git a/src/Business/Grand.Business.Common/Services/Security/PermissionService.cs b/src/Business/Grand.Business.Common/Services/Security/PermissionService.csindex ec9e3e309..00c0e12d3 100644--- a/src/Business/Grand.Business.Common/Services/Security/PermissionService.cs+++ b/src/Business/Grand.Business.Common/Services/Security/PermissionService.cs@@ -81,8 +81,7 @@ namespace Grand.Business.Common.Services.Security/// <param name="permission">Permission</param>public virtual async Task DeletePermission(Permission permission){- if (permission == null)- throw new ArgumentNullException(nameof(permission));+ ArgumentNullException.ThrowIfNull(permission);await _permissionRepository.DeleteAsync(permission);@@ -134,8 +133,7 @@ namespace Grand.Business.Common.Services.Security/// <param name="permission">Permission</param>public virtual async Task InsertPermission(Permission permission){- if (permission == null)- throw new ArgumentNullException(nameof(permission));+ ArgumentNullException.ThrowIfNull(permission);await _permissionRepository.InsertAsync(permission);@@ -148,8 +146,7 @@ namespace Grand.Business.Common.Services.Security/// <param name="permission">Permission</param>public virtual async Task UpdatePermission(Permission permission){- if (permission == null)- throw new ArgumentNullException(nameof(permission));+ ArgumentNullException.ThrowIfNull(permission);await _permissionRepository.UpdateAsync(permission);@@ -232,8 +229,7 @@ namespace Grand.Business.Common.Services.Security/// <param name="permissionAction">Permission action</param>public virtual async Task InsertPermissionAction(PermissionAction permissionAction){- if (permissionAction == null)- throw new ArgumentNullException(nameof(permissionAction));+ ArgumentNullException.ThrowIfNull(permissionAction);//insertawait _permissionActionRepository.InsertAsync(permissionAction);@@ -247,8 +243,7 @@ namespace Grand.Business.Common.Services.Security/// <param name="permissionAction">Permission action</param>public virtual async Task DeletePermissionAction(PermissionAction permissionAction){- if (permissionAction == null)- throw new ArgumentNullException(nameof(permissionAction));+ ArgumentNullException.ThrowIfNull(permissionAction);//deleteawait _permissionActionRepository.DeleteAsync(permissionAction);diff --git a/src/Business/Grand.Business.Common/Services/Seo/SlugService.cs b/src/Business/Grand.Business.Common/Services/Seo/SlugService.csindex 962fa9869..90d342d81 100644--- a/src/Business/Grand.Business.Common/Services/Seo/SlugService.cs+++ b/src/Business/Grand.Business.Common/Services/Seo/SlugService.cs@@ -51,8 +51,7 @@ namespace Grand.Business.Common.Services.Seo/// <param name="urlEntity">URL Entity</param>public virtual async Task InsertEntityUrl(EntityUrl urlEntity){- if (urlEntity == null)- throw new ArgumentNullException(nameof(urlEntity));+ ArgumentNullException.ThrowIfNull(urlEntity);await _urlEntityRepository.InsertAsync(urlEntity);@@ -66,8 +65,7 @@ namespace Grand.Business.Common.Services.Seo/// <param name="urlEntity">URL Entity</param>public virtual async Task UpdateEntityUrl(EntityUrl urlEntity){- if (urlEntity == null)- throw new ArgumentNullException(nameof(urlEntity));+ ArgumentNullException.ThrowIfNull(urlEntity);await _urlEntityRepository.UpdateAsync(urlEntity);@@ -81,8 +79,7 @@ namespace Grand.Business.Common.Services.Seo/// <param name="urlEntity">URL Entity</param>public virtual async Task DeleteEntityUrl(EntityUrl urlEntity){- if (urlEntity == null)- throw new ArgumentNullException(nameof(urlEntity));+ ArgumentNullException.ThrowIfNull(urlEntity);await _urlEntityRepository.DeleteAsync(urlEntity);@@ -189,8 +186,7 @@ namespace Grand.Business.Common.Services.Seopublic virtual async Task SaveSlug<T>(T entity, string slug, string languageId)where T : BaseEntity, ISlugEntity{- if (entity == null)- throw new ArgumentNullException(nameof(entity));+ ArgumentNullException.ThrowIfNull(entity);var entityId = entity.Id;var entityName = typeof(T).Name;diff --git a/src/Business/Grand.Business.Common/Services/Stores/StoreService.cs b/src/Business/Grand.Business.Common/Services/Stores/StoreService.csindex 4147a37ab..c65533b68 100644--- a/src/Business/Grand.Business.Common/Services/Stores/StoreService.cs+++ b/src/Business/Grand.Business.Common/Services/Stores/StoreService.cs@@ -85,8 +85,7 @@ namespace Grand.Business.Common.Services.Stores/// <param name="store">Store</param>public virtual async Task InsertStore(Store store){- if (store == null)- throw new ArgumentNullException(nameof(store));+ ArgumentNullException.ThrowIfNull(store);await _storeRepository.InsertAsync(store);@@ -103,8 +102,7 @@ namespace Grand.Business.Common.Services.Stores/// <param name="store">Store</param>public virtual async Task UpdateStore(Store store){- if (store == null)- throw new ArgumentNullException(nameof(store));+ ArgumentNullException.ThrowIfNull(store);await _storeRepository.UpdateAsync(store);@@ -121,8 +119,7 @@ namespace Grand.Business.Common.Services.Stores/// <param name="store">Store</param>public virtual async Task DeleteStore(Store store){- if (store == null)- throw new ArgumentNullException(nameof(store));+ ArgumentNullException.ThrowIfNull(store);var allStores = await GetAllStores();if (allStores.Count == 1)diff --git a/src/Business/Grand.Business.Core/Extensions/AffiliateExtensions.cs b/src/Business/Grand.Business.Core/Extensions/AffiliateExtensions.csindex 30f9b85ed..552edb61e 100644--- a/src/Business/Grand.Business.Core/Extensions/AffiliateExtensions.cs+++ b/src/Business/Grand.Business.Core/Extensions/AffiliateExtensions.cs@@ -15,8 +15,7 @@ namespace Grand.Business.Core.Extensions/// <returns>Affiliate full name</returns>public static string GetFullName(this Affiliate affiliate){- if (affiliate == null)- throw new ArgumentNullException(nameof(affiliate));+ ArgumentNullException.ThrowIfNull(affiliate);var firstName = affiliate.Address.FirstName;var lastName = affiliate.Address.LastName;@@ -44,8 +43,7 @@ namespace Grand.Business.Core.Extensions/// <returns>Generated affiliate URL</returns>public static string GenerateUrl(this Affiliate affiliate, string host){- if (affiliate == null)- throw new ArgumentNullException(nameof(affiliate));+ ArgumentNullException.ThrowIfNull(affiliate);if (string.IsNullOrEmpty(host))throw new ArgumentNullException(nameof(host));@@ -68,8 +66,7 @@ namespace Grand.Business.Core.Extensions/// <returns>Valid friendly name</returns>public static async Task<string> ValidateFriendlyUrlName(this Affiliate affiliate, IAffiliateService affiliateService, SeoSettings seoSettings, string friendlyUrlName, string name){- if (affiliate == null)- throw new ArgumentNullException(nameof(affiliate));+ ArgumentNullException.ThrowIfNull(affiliate);if (string.IsNullOrEmpty(friendlyUrlName))friendlyUrlName = name;diff --git a/src/Business/Grand.Business.Core/Extensions/ExternalAuthenticationProviderExtensions.cs b/src/Business/Grand.Business.Core/Extensions/ExternalAuthenticationProviderExtensions.csindex af0626e57..f4d9af6a4 100644--- a/src/Business/Grand.Business.Core/Extensions/ExternalAuthenticationProviderExtensions.cs+++ b/src/Business/Grand.Business.Core/Extensions/ExternalAuthenticationProviderExtensions.cs@@ -16,11 +16,8 @@ namespace Grand.Business.Core.Extensions/// <returns>True if method is active; otherwise false</returns>public static bool IsMethodActive(this IExternalAuthenticationProvider method, ExternalAuthenticationSettings settings){- if (method == null)- throw new ArgumentNullException(nameof(method));-- if (settings == null)- throw new ArgumentNullException(nameof(settings));+ ArgumentNullException.ThrowIfNull(method);+ ArgumentNullException.ThrowIfNull(settings);return settings.ActiveAuthenticationMethodSystemNames != null && settings.ActiveAuthenticationMethodSystemNames.Any(activeMethodSystemName => method.SystemName.Equals(activeMethodSystemName, StringComparison.OrdinalIgnoreCase));}diff --git a/src/Business/Grand.Business.Core/Extensions/HistoryExtensions.cs b/src/Business/Grand.Business.Core/Extensions/HistoryExtensions.csindex 66d8a3095..1e22cce51 100644--- a/src/Business/Grand.Business.Core/Extensions/HistoryExtensions.cs+++ b/src/Business/Grand.Business.Core/Extensions/HistoryExtensions.cs@@ -13,8 +13,7 @@ namespace Grand.Business.Core.Extensions/// <param name="historyService"></param>public static async Task SaveHistory<T>(this BaseEntity entity, IHistoryService historyService) where T : BaseEntity, IHistory{- if (entity == null)- throw new ArgumentNullException(nameof(entity));+ ArgumentNullException.ThrowIfNull(entity);await historyService.SaveObject(entity);}diff --git a/src/Business/Grand.Business.Core/Extensions/PaymentExtensions.cs b/src/Business/Grand.Business.Core/Extensions/PaymentExtensions.csindex db19c3d75..507579b84 100644--- a/src/Business/Grand.Business.Core/Extensions/PaymentExtensions.cs+++ b/src/Business/Grand.Business.Core/Extensions/PaymentExtensions.cs@@ -19,11 +19,8 @@ namespace Grand.Business.Core.Extensionspublic static bool IsPaymentMethodActive(this IPaymentProvider paymentMethod,PaymentSettings paymentSettings){- if (paymentMethod == null)- throw new ArgumentNullException(nameof(paymentMethod));-- if (paymentSettings == null)- throw new ArgumentNullException(nameof(paymentSettings));+ ArgumentNullException.ThrowIfNull(paymentMethod);+ ArgumentNullException.ThrowIfNull(paymentSettings);return paymentSettings.ActivePaymentProviderSystemNames != null && paymentSettings.ActivePaymentProviderSystemNames.Any(activeMethodSystemName => paymentMethod.SystemName.Equals(activeMethodSystemName, StringComparison.OrdinalIgnoreCase));}@@ -41,8 +38,7 @@ namespace Grand.Business.Core.ExtensionsIOrderCalculationService orderTotalCalculationService, IList<ShoppingCartItem> cart,double fee, bool usePercentage){- if (paymentMethod == null)- throw new ArgumentNullException(nameof(paymentMethod));+ ArgumentNullException.ThrowIfNull(paymentMethod);if (fee <= 0)return fee;diff --git a/src/Business/Grand.Business.Core/Extensions/SeoExtensions.cs b/src/Business/Grand.Business.Core/Extensions/SeoExtensions.csindex e54ee971e..8cd083ed4 100644--- a/src/Business/Grand.Business.Core/Extensions/SeoExtensions.cs+++ b/src/Business/Grand.Business.Core/Extensions/SeoExtensions.cs@@ -27,8 +27,7 @@ namespace Grand.Business.Core.Extensions/// <returns>Product tag SE (search engine) name</returns>public static string GetSeName(this ProductTag productTag, string languageId){- if (productTag == null)- throw new ArgumentNullException(nameof(productTag));+ ArgumentNullException.ThrowIfNull(productTag);var seName = GenerateSlug(productTag.GetTranslation(x => x.Name, languageId), false, false, false);return seName;}@@ -48,8 +47,7 @@ namespace Grand.Business.Core.Extensionspublic static string GetSeName<T>(this T entity, string languageId, bool returnDefaultValue = true)where T : BaseEntity, ISlugEntity, ITranslationEntity{- if (entity == null)- throw new ArgumentNullException(nameof(entity));+ ArgumentNullException.ThrowIfNull(entity);var seName = string.Empty;if (!string.IsNullOrEmpty(languageId))@@ -84,8 +82,7 @@ namespace Grand.Business.Core.ExtensionsSeoSettings seoSettings, ISlugService slugService, ILanguageService languageService)where T : BaseEntity, ISlugEntity{- if (entity == null)- throw new ArgumentNullException(nameof(entity));+ ArgumentNullException.ThrowIfNull(entity);//use name if se-name is not specifiedif (string.IsNullOrWhiteSpace(seName) && !string.IsNullOrWhiteSpace(name))diff --git a/src/Business/Grand.Business.Core/Extensions/ShippingExtensions.cs b/src/Business/Grand.Business.Core/Extensions/ShippingExtensions.csindex eec154019..deeedb0b3 100644--- a/src/Business/Grand.Business.Core/Extensions/ShippingExtensions.cs+++ b/src/Business/Grand.Business.Core/Extensions/ShippingExtensions.cs@@ -8,11 +8,8 @@ namespace Grand.Business.Core.Extensionspublic static bool IsShippingRateMethodActive(this IShippingRateCalculationProvider srcm,ShippingProviderSettings shippingProviderSettings){- if (srcm == null)- throw new ArgumentNullException(nameof(srcm));-- if (shippingProviderSettings == null)- throw new ArgumentNullException(nameof(shippingProviderSettings));+ ArgumentNullException.ThrowIfNull(srcm);+ ArgumentNullException.ThrowIfNull(shippingProviderSettings);return shippingProviderSettings.ActiveSystemNames != null && shippingProviderSettings.ActiveSystemNames.Any(activeMethodSystemName => srcm.SystemName.Equals(activeMethodSystemName, StringComparison.OrdinalIgnoreCase));}@@ -20,8 +17,7 @@ namespace Grand.Business.Core.Extensionspublic static bool CountryRestrictionExists(this ShippingMethod shippingMethod,string countryId){- if (shippingMethod == null)- throw new ArgumentNullException(nameof(shippingMethod));+ ArgumentNullException.ThrowIfNull(shippingMethod);var result = shippingMethod.RestrictedCountries.ToList().Find(c => c.Id == countryId) != null;return result;@@ -29,8 +25,7 @@ namespace Grand.Business.Core.Extensionspublic static bool CustomerGroupRestrictionExists(this ShippingMethod shippingMethod,string roleId){- if (shippingMethod == null)- throw new ArgumentNullException(nameof(shippingMethod));+ ArgumentNullException.ThrowIfNull(shippingMethod);var result = shippingMethod.RestrictedGroups.ToList().Find(c => c == roleId) != null;return result;@@ -39,8 +34,7 @@ namespace Grand.Business.Core.Extensionspublic static bool CustomerGroupRestrictionExists(this ShippingMethod shippingMethod,List<string> roleIds){- if (shippingMethod == null)- throw new ArgumentNullException(nameof(shippingMethod));+ ArgumentNullException.ThrowIfNull(shippingMethod);var result = shippingMethod.RestrictedGroups.ToList().Find(roleIds.Contains) != null;return result;diff --git a/src/Business/Grand.Business.Core/Extensions/TranslateExtensions.cs b/src/Business/Grand.Business.Core/Extensions/TranslateExtensions.csindex 76055b730..3c2ada54d 100644--- a/src/Business/Grand.Business.Core/Extensions/TranslateExtensions.cs+++ b/src/Business/Grand.Business.Core/Extensions/TranslateExtensions.cs@@ -27,8 +27,7 @@ namespace Grand.Business.Core.Extensionsbool returnDefaultValue = true)where T : ParentEntity, ITranslationEntity{- if (entity == null)- throw new ArgumentNullException(nameof(entity));+ ArgumentNullException.ThrowIfNull(entity);if (keySelector.Body is not MemberExpression member)throw new ArgumentException($"Expression '{keySelector}' refers to a method, not a property.");@@ -77,8 +76,7 @@ namespace Grand.Business.Core.ExtensionsIWorkContext workContext)where T : struct{- if (workContext == null)- throw new ArgumentNullException(nameof(workContext));+ ArgumentNullException.ThrowIfNull(workContext);return GetTranslationEnum(enumValue, translationService, workContext.WorkingLanguage.Id);}@@ -94,8 +92,7 @@ namespace Grand.Business.Core.ExtensionsITranslationService translationService, string languageId)where T : struct{- if (translationService == null)- throw new ArgumentNullException(nameof(translationService));+ ArgumentNullException.ThrowIfNull(translationService);if (!typeof(T).GetTypeInfo().IsEnum) throw new ArgumentException("T must be enum type");@@ -122,8 +119,7 @@ namespace Grand.Business.Core.Extensionspublic static string GetTranslationPermissionName(this Permission permissionRecord,ITranslationService translationService, IWorkContext workContext){- if (workContext == null)- throw new ArgumentNullException(nameof(workContext));+ ArgumentNullException.ThrowIfNull(workContext);return GetTranslationPermissionName(permissionRecord, translationService, workContext.WorkingLanguage.Id);}@@ -138,11 +134,8 @@ namespace Grand.Business.Core.Extensionspublic static string GetTranslationPermissionName(this Permission permissionRecord,ITranslationService translationService, string languageId){- if (permissionRecord == null)- throw new ArgumentNullException(nameof(permissionRecord));-- if (translationService == null)- throw new ArgumentNullException(nameof(translationService));+ ArgumentNullException.ThrowIfNull(permissionRecord);+ ArgumentNullException.ThrowIfNull(translationService);//Translation valuevar name = $"Permission.{permissionRecord.SystemName}";@@ -164,12 +157,9 @@ namespace Grand.Business.Core.Extensionspublic static async Task SaveTranslationPermissionName(this Permission permissionRecord,ITranslationService translationService, ILanguageService languageService){- if (permissionRecord == null)- throw new ArgumentNullException(nameof(permissionRecord));- if (translationService == null)- throw new ArgumentNullException(nameof(translationService));- if (languageService == null)- throw new ArgumentNullException(nameof(languageService));+ ArgumentNullException.ThrowIfNull(permissionRecord);+ ArgumentNullException.ThrowIfNull(translationService);+ ArgumentNullException.ThrowIfNull(languageService);var name = $"Permission.{permissionRecord.SystemName}";var value = permissionRecord.Name;@@ -203,12 +193,9 @@ namespace Grand.Business.Core.Extensionspublic static async Task DeleteTranslationPermissionName(this Permission permissionRecord,ITranslationService translationService, ILanguageService languageService){- if (permissionRecord == null)- throw new ArgumentNullException(nameof(permissionRecord));- if (translationService == null)- throw new ArgumentNullException(nameof(translationService));- if (languageService == null)- throw new ArgumentNullException(nameof(languageService));+ ArgumentNullException.ThrowIfNull(permissionRecord);+ ArgumentNullException.ThrowIfNull(translationService);+ ArgumentNullException.ThrowIfNull(languageService);var name = $"Permission.{permissionRecord.SystemName}";foreach (var lang in await languageService.GetAllLanguages(true))@@ -230,12 +217,9 @@ namespace Grand.Business.Core.ExtensionsITranslationService translationService, ILanguageService languageService,string name){- if (plugin == null)- throw new ArgumentNullException(nameof(plugin));- if (translationService == null)- throw new ArgumentNullException(nameof(translationService));- if (languageService == null)- throw new ArgumentNullException(nameof(languageService));+ ArgumentNullException.ThrowIfNull(plugin);+ ArgumentNullException.ThrowIfNull(translationService);+ ArgumentNullException.ThrowIfNull(languageService);if (!string.IsNullOrEmpty(name))name = name.ToLowerInvariant();foreach (var lang in await languageService.GetAllLanguages(true))@@ -261,12 +245,9 @@ namespace Grand.Business.Core.Extensionsstring name, string value, TranslationResourceArea area = TranslationResourceArea.Common, string languageCulture = null){//actually plugin instance is not required- if (plugin == null)- throw new ArgumentNullException(nameof(plugin));- if (translationService == null)- throw new ArgumentNullException(nameof(translationService));- if (languageService == null)- throw new ArgumentNullException(nameof(languageService));+ ArgumentNullException.ThrowIfNull(plugin);+ ArgumentNullException.ThrowIfNull(translationService);+ ArgumentNullException.ThrowIfNull(languageService);if (!string.IsNullOrEmpty(name))name = name.ToLowerInvariant();foreach (var lang in await languageService.GetAllLanguages(true))diff --git a/src/Business/Grand.Business.Core/Extensions/UserFieldExtensions.cs b/src/Business/Grand.Business.Core/Extensions/UserFieldExtensions.csindex 0e130f3e0..5c9df1bcb 100644--- a/src/Business/Grand.Business.Core/Extensions/UserFieldExtensions.cs+++ b/src/Business/Grand.Business.Core/Extensions/UserFieldExtensions.cs@@ -16,8 +16,7 @@ namespace Grand.Business.Core.Extensions/// <returns>Attribute</returns>public static async Task<TPropType> GetUserField<TPropType>(this BaseEntity entity, IUserFieldService userFieldService, string key, string storeId = ""){- if (entity == null)- throw new ArgumentNullException(nameof(entity));+ ArgumentNullException.ThrowIfNull(entity);return await userFieldService.GetFieldsForEntity<TPropType>(entity, key, storeId);}diff --git a/src/Business/Grand.Business.Core/Interfaces/Customers/ICustomerService.cs b/src/Business/Grand.Business.Core/Interfaces/Customers/ICustomerService.csindex 9bddf3bff..4ee367450 100644--- a/src/Business/Grand.Business.Core/Interfaces/Customers/ICustomerService.cs+++ b/src/Business/Grand.Business.Core/Interfaces/Customers/ICustomerService.cs@@ -2,7 +2,6 @@ using Grand.Domain;using Grand.Domain.Common;using Grand.Domain.Customers;using Grand.Domain.Orders;-using Grand.Domain.Stores;using System.Linq.Expressions;namespace Grand.Business.Core.Interfaces.Customersdiff --git a/src/Business/Grand.Business.Customers/Services/AffiliateService.cs b/src/Business/Grand.Business.Customers/Services/AffiliateService.csindex 0531b9cf4..f38bf0061 100644--- a/src/Business/Grand.Business.Customers/Services/AffiliateService.cs+++ b/src/Business/Grand.Business.Customers/Services/AffiliateService.cs@@ -114,8 +114,7 @@ namespace Grand.Business.Customers.Services/// <param name="affiliate">Affiliate</param>public virtual async Task InsertAffiliate(Affiliate affiliate){- if (affiliate == null)- throw new ArgumentNullException(nameof(affiliate));+ ArgumentNullException.ThrowIfNull(affiliate);await _affiliateRepository.InsertAsync(affiliate);@@ -129,8 +128,7 @@ namespace Grand.Business.Customers.Services/// <param name="affiliate">Affiliate</param>public virtual async Task UpdateAffiliate(Affiliate affiliate){- if (affiliate == null)- throw new ArgumentNullException(nameof(affiliate));+ ArgumentNullException.ThrowIfNull(affiliate);await _affiliateRepository.UpdateAsync(affiliate);@@ -144,8 +142,7 @@ namespace Grand.Business.Customers.Services/// <param name="affiliate">Affiliate</param>public virtual async Task DeleteAffiliate(Affiliate affiliate){- if (affiliate == null)- throw new ArgumentNullException(nameof(affiliate));+ ArgumentNullException.ThrowIfNull(affiliate);await _affiliateRepository.DeleteAsync(affiliate);diff --git a/src/Business/Grand.Business.Customers/Services/CustomerAttributeService.cs b/src/Business/Grand.Business.Customers/Services/CustomerAttributeService.csindex f16c2c212..da17517de 100644--- a/src/Business/Grand.Business.Customers/Services/CustomerAttributeService.cs+++ b/src/Business/Grand.Business.Customers/Services/CustomerAttributeService.cs@@ -75,8 +75,7 @@ namespace Grand.Business.Customers.Services/// <param name="customerAttribute">Customer attribute</param>public virtual async Task InsertCustomerAttribute(CustomerAttribute customerAttribute){- if (customerAttribute == null)- throw new ArgumentNullException(nameof(customerAttribute));+ ArgumentNullException.ThrowIfNull(customerAttribute);await _customerAttributeRepository.InsertAsync(customerAttribute);@@ -93,8 +92,7 @@ namespace Grand.Business.Customers.Services/// <param name="customerAttribute">Customer attribute</param>public virtual async Task UpdateCustomerAttribute(CustomerAttribute customerAttribute){- if (customerAttribute == null)- throw new ArgumentNullException(nameof(customerAttribute));+ ArgumentNullException.ThrowIfNull(customerAttribute);await _customerAttributeRepository.UpdateAsync(customerAttribute);@@ -111,8 +109,7 @@ namespace Grand.Business.Customers.Services/// <param name="customerAttribute">Customer attribute</param>public virtual async Task DeleteCustomerAttribute(CustomerAttribute customerAttribute){- if (customerAttribute == null)- throw new ArgumentNullException(nameof(customerAttribute));+ ArgumentNullException.ThrowIfNull(customerAttribute);await _customerAttributeRepository.DeleteAsync(customerAttribute);@@ -130,8 +127,7 @@ namespace Grand.Business.Customers.Services/// <param name="customerAttributeValue">Customer attribute value</param>public virtual async Task InsertCustomerAttributeValue(CustomerAttributeValue customerAttributeValue){- if (customerAttributeValue == null)- throw new ArgumentNullException(nameof(customerAttributeValue));+ ArgumentNullException.ThrowIfNull(customerAttributeValue);var ca = await _customerAttributeRepository.GetByIdAsync(customerAttributeValue.CustomerAttributeId);ca.CustomerAttributeValues.Add(customerAttributeValue);@@ -151,8 +147,7 @@ namespace Grand.Business.Customers.Services/// <param name="customerAttributeValue">Customer attribute value</param>public virtual async Task UpdateCustomerAttributeValue(CustomerAttributeValue customerAttributeValue){- if (customerAttributeValue == null)- throw new ArgumentNullException(nameof(customerAttributeValue));+ ArgumentNullException.ThrowIfNull(customerAttributeValue);var ca = await _customerAttributeRepository.GetByIdAsync(customerAttributeValue.CustomerAttributeId);ca.CustomerAttributeValues.Remove(ca.CustomerAttributeValues.FirstOrDefault(c => c.Id == customerAttributeValue.Id));@@ -173,8 +168,7 @@ namespace Grand.Business.Customers.Services/// <param name="customerAttributeValue">Customer attribute value</param>public virtual async Task DeleteCustomerAttributeValue(CustomerAttributeValue customerAttributeValue){- if (customerAttributeValue == null)- throw new ArgumentNullException(nameof(customerAttributeValue));+ ArgumentNullException.ThrowIfNull(customerAttributeValue);var ca = await _customerAttributeRepository.GetByIdAsync(customerAttributeValue.CustomerAttributeId);ca.CustomerAttributeValues.Remove(ca.CustomerAttributeValues.FirstOrDefault(c => c.Id == customerAttributeValue.Id));diff --git a/src/Business/Grand.Business.Customers/Services/CustomerHistoryPasswordService.cs b/src/Business/Grand.Business.Customers/Services/CustomerHistoryPasswordService.csindex a01b0bad2..2678eddd9 100644--- a/src/Business/Grand.Business.Customers/Services/CustomerHistoryPasswordService.cs+++ b/src/Business/Grand.Business.Customers/Services/CustomerHistoryPasswordService.cs@@ -24,8 +24,7 @@ namespace Grand.Business.Customers.Services/// <param name="customer">Customer</param>public virtual async Task InsertCustomerPassword(Customer customer){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);var chp = new CustomerHistoryPassword{diff --git a/src/Business/Grand.Business.Customers/Services/CustomerManagerService.cs b/src/Business/Grand.Business.Customers/Services/CustomerManagerService.csindex 38e43007e..d2c9ed5fe 100644--- a/src/Business/Grand.Business.Customers/Services/CustomerManagerService.cs+++ b/src/Business/Grand.Business.Customers/Services/CustomerManagerService.cs@@ -107,8 +107,7 @@ namespace Grand.Business.Customers.Services/// <returns>Result</returns>public virtual async Task RegisterCustomer(RegistrationRequest request){- if (request == null)- throw new ArgumentNullException(nameof(request));+ ArgumentNullException.ThrowIfNull(request);if (request.Customer == null)throw new ArgumentException("Can't load current customer");@@ -165,8 +164,7 @@ namespace Grand.Business.Customers.Services/// <param name="request">Request</param>public virtual async Task ChangePassword(ChangePasswordRequest request){- if (request == null)- throw new ArgumentNullException(nameof(request));+ ArgumentNullException.ThrowIfNull(request);var customer = await _customerService.GetCustomerByEmail(request.Email);if (customer == null)diff --git a/src/Business/Grand.Business.Customers/Services/CustomerNoteService.cs b/src/Business/Grand.Business.Customers/Services/CustomerNoteService.csindex 7d16b07f7..547b8631c 100644--- a/src/Business/Grand.Business.Customers/Services/CustomerNoteService.cs+++ b/src/Business/Grand.Business.Customers/Services/CustomerNoteService.cs@@ -36,8 +36,7 @@ namespace Grand.Business.Customers.Services/// <param name="customerNote">The customer note</param>public virtual async Task InsertCustomerNote(CustomerNote customerNote){- if (customerNote == null)- throw new ArgumentNullException(nameof(customerNote));+ ArgumentNullException.ThrowIfNull(customerNote);await _customerNoteRepository.InsertAsync(customerNote);@@ -51,8 +50,7 @@ namespace Grand.Business.Customers.Services/// <param name="customerNote">The customer note</param>public virtual async Task DeleteCustomerNote(CustomerNote customerNote){- if (customerNote == null)- throw new ArgumentNullException(nameof(customerNote));+ ArgumentNullException.ThrowIfNull(customerNote);await _customerNoteRepository.DeleteAsync(customerNote);diff --git a/src/Business/Grand.Business.Customers/Services/CustomerService.cs b/src/Business/Grand.Business.Customers/Services/CustomerService.csindex d3e5e55e5..f120d9c2b 100644--- a/src/Business/Grand.Business.Customers/Services/CustomerService.cs+++ b/src/Business/Grand.Business.Customers/Services/CustomerService.cs@@ -7,7 +7,6 @@ using Grand.Domain.Customers;using Grand.Data;using Grand.Domain.Orders;using Grand.Domain.Shipping;-using Grand.Domain.Stores;using Grand.Infrastructure.Extensions;using Grand.SharedKernel;using MediatR;@@ -198,7 +197,7 @@ namespace Grand.Business.Customers.Services/// <returns>A customer</returns>public virtual async Task<Customer> GetCustomerByGuid(Guid customerGuid){- return await Task.FromResult(_customerRepository.Table.FirstOrDefault(x => x.CustomerGuid == customerGuid));+ return await _customerRepository.GetOneAsync(x => x.CustomerGuid == customerGuid);}/// <summary>@@ -208,10 +207,7 @@ namespace Grand.Business.Customers.Services/// <returns>Customer</returns>public virtual async Task<Customer> GetCustomerByEmail(string email){- if (string.IsNullOrWhiteSpace(email))- return null;-- return await Task.FromResult(_customerRepository.Table.FirstOrDefault(x => x.Email == email.ToLowerInvariant()));+ return string.IsNullOrWhiteSpace(email) ? null : await _customerRepository.GetOneAsync(x => x.Email == email.ToLowerInvariant());}/// <summary>@@ -224,7 +220,7 @@ namespace Grand.Business.Customers.Servicesif (string.IsNullOrWhiteSpace(systemName))return null;- return await Task.FromResult(_customerRepository.Table.FirstOrDefault(x => x.SystemName == systemName));+ return await _customerRepository.GetOneAsync(x => x.SystemName == systemName);}/// <summary>@@ -237,7 +233,7 @@ namespace Grand.Business.Customers.Servicesif (string.IsNullOrWhiteSpace(username))return null;- return await Task.FromResult(_customerRepository.Table.FirstOrDefault(x => x.Username == username.ToLowerInvariant()));+ return await _customerRepository.GetOneAsync(x => x.Username == username.ToLowerInvariant());}/// <summary>@@ -268,8 +264,7 @@ namespace Grand.Business.Customers.Services/// <param name="customer">Customer</param>public virtual async Task InsertCustomer(Customer customer){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);if (!string.IsNullOrEmpty(customer.Email))customer.Email = customer.Email.ToLowerInvariant();@@ -292,8 +287,7 @@ namespace Grand.Business.Customers.Servicespublic virtual async Task UpdateCustomerField<T>(Customer customer,Expression<Func<Customer, T>> expression, T value){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);await UpdateCustomerField(customer.Id, expression, value);@@ -320,8 +314,7 @@ namespace Grand.Business.Customers.Services/// <param name="customer">Customer</param>public virtual async Task UpdateCustomer(Customer customer){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);if (customer.IsSystemAccount)throw new GrandException($"System customer account ({(string.IsNullOrEmpty(customer.SystemName) ? customer.Email : customer.SystemName)}) could not be updated");@@ -351,8 +344,7 @@ namespace Grand.Business.Customers.Services/// <param name="hard">Hard delete from database</param>public virtual async Task DeleteCustomer(Customer customer, bool hard = false){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);if (customer.IsSystemAccount)throw new GrandException($"System customer account ({(string.IsNullOrEmpty(customer.SystemName) ? customer.Email : customer.SystemName)}) could not be deleted");@@ -390,8 +382,7 @@ namespace Grand.Business.Customers.Services/// <param name="customer">Customer</param>public virtual async Task UpdateCustomerLastLoginDate(Customer customer){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);var update = UpdateBuilder<Customer>.Create().Set(x => x.LastLoginDateUtc, customer.LastLoginDateUtc)@@ -404,8 +395,7 @@ namespace Grand.Business.Customers.Servicespublic virtual async Task UpdateCustomerInAdminPanel(Customer customer){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);if (customer.IsSystemAccount)throw new GrandException($"System customer account ({(string.IsNullOrEmpty(customer.SystemName) ? customer.Email : customer.SystemName)}) could not be updated");@@ -437,8 +427,7 @@ namespace Grand.Business.Customers.Servicespublic virtual async Task UpdateActive(Customer customer){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);var update = UpdateBuilder<Customer>.Create().Set(x => x.Active, customer.Active)@@ -452,8 +441,7 @@ namespace Grand.Business.Customers.Servicespublic virtual async Task UpdateContributions(Customer customer){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);await UpdateCustomerField(customer.Id, x => x.HasContributions, true);@@ -475,8 +463,7 @@ namespace Grand.Business.Customers.Servicesbool clearCouponCodes = false, bool clearCheckoutAttributes = false,bool clearLoyaltyPoints = true, bool clearShipping = true, bool clearPayment = true){- if (customer == null)- throw new ArgumentNullException();+ ArgumentNullException.ThrowIfNull(customer);//clear entered coupon codesif (clearCouponCodes)@@ -557,8 +544,7 @@ namespace Grand.Business.Customers.Servicespublic virtual async Task DeleteCustomerGroupInCustomer(CustomerGroup customerGroup, string customerId){- if (customerGroup == null)- throw new ArgumentNullException(nameof(customerGroup));+ ArgumentNullException.ThrowIfNull(customerGroup);if (string.IsNullOrEmpty(customerId))throw new ArgumentNullException(nameof(customerId));@@ -568,8 +554,7 @@ namespace Grand.Business.Customers.Servicespublic virtual async Task InsertCustomerGroupInCustomer(CustomerGroup customerGroup, string customerId){- if (customerGroup == null)- throw new ArgumentNullException(nameof(customerGroup));+ ArgumentNullException.ThrowIfNull(customerGroup);if (string.IsNullOrEmpty(customerId))throw new ArgumentNullException(nameof(customerId));@@ -584,8 +569,7 @@ namespace Grand.Business.Customers.Servicespublic virtual async Task DeleteAddress(Address address, string customerId){- if (address == null)- throw new ArgumentNullException(nameof(address));+ ArgumentNullException.ThrowIfNull(address);if (string.IsNullOrEmpty(customerId))throw new ArgumentNullException(nameof(customerId));@@ -599,8 +583,7 @@ namespace Grand.Business.Customers.Servicespublic virtual async Task InsertAddress(Address address, string customerId){- if (address == null)- throw new ArgumentNullException(nameof(address));+ ArgumentNullException.ThrowIfNull(address);if (string.IsNullOrEmpty(customerId))throw new ArgumentNullException(nameof(customerId));@@ -616,8 +599,7 @@ namespace Grand.Business.Customers.Servicespublic virtual async Task UpdateAddress(Address address, string customerId){- if (address == null)- throw new ArgumentNullException(nameof(address));+ ArgumentNullException.ThrowIfNull(address);if (string.IsNullOrEmpty(customerId))throw new ArgumentNullException(nameof(customerId));@@ -631,8 +613,7 @@ namespace Grand.Business.Customers.Servicespublic virtual async Task UpdateBillingAddress(Address address, string customerId){- if (address == null)- throw new ArgumentNullException(nameof(address));+ ArgumentNullException.ThrowIfNull(address);if (string.IsNullOrEmpty(customerId))throw new ArgumentNullException(nameof(customerId));@@ -642,8 +623,7 @@ namespace Grand.Business.Customers.Services}public virtual async Task UpdateShippingAddress(Address address, string customerId){- if (address == null)- throw new ArgumentNullException(nameof(address));+ ArgumentNullException.ThrowIfNull(address);if (string.IsNullOrEmpty(customerId))throw new ArgumentNullException(nameof(customerId));@@ -657,8 +637,7 @@ namespace Grand.Business.Customers.Servicespublic virtual async Task DeleteShoppingCartItem(string customerId, ShoppingCartItem shoppingCartItem){- if (shoppingCartItem == null)- throw new ArgumentNullException(nameof(shoppingCartItem));+ ArgumentNullException.ThrowIfNull(shoppingCartItem);await _customerRepository.PullFilter(customerId, x => x.ShoppingCartItems, x => x.Id, shoppingCartItem.Id);@@ -684,8 +663,7 @@ namespace Grand.Business.Customers.Servicespublic virtual async Task InsertShoppingCartItem(string customerId, ShoppingCartItem shoppingCartItem){- if (shoppingCartItem == null)- throw new ArgumentNullException(nameof(shoppingCartItem));+ ArgumentNullException.ThrowIfNull(shoppingCartItem);await _customerRepository.AddToSet(customerId, x => x.ShoppingCartItems, shoppingCartItem);@@ -697,8 +675,7 @@ namespace Grand.Business.Customers.Servicespublic virtual async Task UpdateShoppingCartItem(string customerId, ShoppingCartItem shoppingCartItem){- if (shoppingCartItem == null)- throw new ArgumentNullException(nameof(shoppingCartItem));+ ArgumentNullException.ThrowIfNull(shoppingCartItem);await _customerRepository.UpdateToSet(customerId, x => x.ShoppingCartItems, z => z.Id, shoppingCartItem.Id, shoppingCartItem);diff --git a/src/Business/Grand.Business.Customers/Services/SalesEmployeeService.cs b/src/Business/Grand.Business.Customers/Services/SalesEmployeeService.csindex 68150c874..3074cddbc 100644--- a/src/Business/Grand.Business.Customers/Services/SalesEmployeeService.cs+++ b/src/Business/Grand.Business.Customers/Services/SalesEmployeeService.cs@@ -60,8 +60,7 @@ namespace Grand.Business.Customers.Services/// <param name="salesEmployee">Sales Employee</param>public virtual async Task InsertSalesEmployee(SalesEmployee salesEmployee){- if (salesEmployee == null)- throw new ArgumentNullException(nameof(salesEmployee));+ ArgumentNullException.ThrowIfNull(salesEmployee);await _salesEmployeeRepository.InsertAsync(salesEmployee);@@ -78,8 +77,7 @@ namespace Grand.Business.Customers.Services/// <param name="salesEmployee">Sales Employee</param>public virtual async Task UpdateSalesEmployee(SalesEmployee salesEmployee){- if (salesEmployee == null)- throw new ArgumentNullException(nameof(salesEmployee));+ ArgumentNullException.ThrowIfNull(salesEmployee);await _salesEmployeeRepository.UpdateAsync(salesEmployee);@@ -96,8 +94,7 @@ namespace Grand.Business.Customers.Services/// <param name="salesEmployee">The sales employee</param>public virtual async Task DeleteSalesEmployee(SalesEmployee salesEmployee){- if (salesEmployee == null)- throw new ArgumentNullException(nameof(salesEmployee));+ ArgumentNullException.ThrowIfNull(salesEmployee);await _salesEmployeeRepository.DeleteAsync(salesEmployee);diff --git a/src/Business/Grand.Business.Customers/Services/VendorService.cs b/src/Business/Grand.Business.Customers/Services/VendorService.csindex 37b0456cb..93dbe20fa 100644--- a/src/Business/Grand.Business.Customers/Services/VendorService.cs+++ b/src/Business/Grand.Business.Customers/Services/VendorService.cs@@ -79,8 +79,7 @@ namespace Grand.Business.Customers.Services/// <param name="vendor">Vendor</param>public virtual async Task InsertVendor(Vendor vendor){- if (vendor == null)- throw new ArgumentNullException(nameof(vendor));+ ArgumentNullException.ThrowIfNull(vendor);await _vendorRepository.InsertAsync(vendor);@@ -94,8 +93,7 @@ namespace Grand.Business.Customers.Services/// <param name="vendor">Vendor</param>public virtual async Task UpdateVendor(Vendor vendor){- if (vendor == null)- throw new ArgumentNullException(nameof(vendor));+ ArgumentNullException.ThrowIfNull(vendor);await _vendorRepository.UpdateAsync(vendor);@@ -109,8 +107,7 @@ namespace Grand.Business.Customers.Services/// <param name="vendor">Vendor</param>public virtual async Task DeleteVendor(Vendor vendor){- if (vendor == null)- throw new ArgumentNullException(nameof(vendor));+ ArgumentNullException.ThrowIfNull(vendor);vendor.Deleted = true;await UpdateVendor(vendor);@@ -138,8 +135,7 @@ namespace Grand.Business.Customers.Services/// <returns></returns>public virtual async Task InsertVendorNote(VendorNote vendorNote, string vendorId){- if (vendorNote == null)- throw new ArgumentNullException(nameof(vendorNote));+ ArgumentNullException.ThrowIfNull(vendorNote);await _vendorRepository.AddToSet(vendorId, x => x.VendorNotes, vendorNote);@@ -154,8 +150,7 @@ namespace Grand.Business.Customers.Services/// <param name="vendorId">Vendor ident</param>public virtual async Task DeleteVendorNote(VendorNote vendorNote, string vendorId){- if (vendorNote == null)- throw new ArgumentNullException(nameof(vendorNote));+ ArgumentNullException.ThrowIfNull(vendorNote);await _vendorRepository.PullFilter(vendorId, x => x.VendorNotes, x => x.Id, vendorNote.Id);@@ -220,8 +215,7 @@ namespace Grand.Business.Customers.Services/// <param name="vendor">Vendor</param>public virtual async Task UpdateVendorReviewTotals(Vendor vendor){- if (vendor == null)- throw new ArgumentNullException(nameof(vendor));+ ArgumentNullException.ThrowIfNull(vendor);var approvedRatingSum = 0;var notApprovedRatingSum = 0;@@ -261,8 +255,7 @@ namespace Grand.Business.Customers.Servicespublic virtual async Task UpdateVendorReview(VendorReview vendorReview){- if (vendorReview == null)- throw new ArgumentNullException(nameof(vendorReview));+ ArgumentNullException.ThrowIfNull(vendorReview);var update = UpdateBuilder<VendorReview>.Create().Set(x => x.Title, vendorReview.Title)@@ -283,8 +276,7 @@ namespace Grand.Business.Customers.Services/// <param name="vendorReview">Vendor review</param>public virtual async Task InsertVendorReview(VendorReview vendorReview){- if (vendorReview == null)- throw new ArgumentNullException(nameof(vendorReview));+ ArgumentNullException.ThrowIfNull(vendorReview);await _vendorReviewRepository.InsertAsync(vendorReview);@@ -298,8 +290,7 @@ namespace Grand.Business.Customers.Services/// <param name="vendorReview">Vendor review</param>public virtual async Task DeleteVendorReview(VendorReview vendorReview){- if (vendorReview == null)- throw new ArgumentNullException(nameof(vendorReview));+ ArgumentNullException.ThrowIfNull(vendorReview);await _vendorReviewRepository.DeleteAsync(vendorReview);diff --git a/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.cs b/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.csindex b4e1fb644..da7df1bc0 100644--- a/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.cs@@ -32,8 +32,7 @@ namespace Grand.Business.Marketing.Services.Campaigns/// <param name="campaign">Campaign</param>public virtual async Task InsertCampaign(Campaign campaign){- if (campaign == null)- throw new ArgumentNullException(nameof(campaign));+ ArgumentNullException.ThrowIfNull(campaign);await campaignRepository.InsertAsync(campaign);@@ -47,8 +46,7 @@ namespace Grand.Business.Marketing.Services.Campaigns/// <param name="campaignHistory">Campaign</param>public virtual async Task InsertCampaignHistory(CampaignHistory campaignHistory){- if (campaignHistory == null)- throw new ArgumentNullException(nameof(campaignHistory));+ ArgumentNullException.ThrowIfNull(campaignHistory);await campaignHistoryRepository.InsertAsync(campaignHistory);@@ -60,8 +58,7 @@ namespace Grand.Business.Marketing.Services.Campaigns/// <param name="campaign">Campaign</param>public virtual async Task UpdateCampaign(Campaign campaign){- if (campaign == null)- throw new ArgumentNullException(nameof(campaign));+ ArgumentNullException.ThrowIfNull(campaign);await campaignRepository.UpdateAsync(campaign);@@ -75,8 +72,7 @@ namespace Grand.Business.Marketing.Services.Campaigns/// <param name="campaign">Campaign</param>public virtual async Task DeleteCampaign(Campaign campaign){- if (campaign == null)- throw new ArgumentNullException(nameof(campaign));+ ArgumentNullException.ThrowIfNull(campaign);await campaignRepository.DeleteAsync(campaign);@@ -110,8 +106,7 @@ namespace Grand.Business.Marketing.Services.Campaignspublic virtual async Task<IPagedList<CampaignHistory>> GetCampaignHistory(Campaign campaign, int pageIndex = 0, int pageSize = int.MaxValue){- if (campaign == null)- throw new ArgumentNullException(nameof(campaign));+ ArgumentNullException.ThrowIfNull(campaign);var query = from c in campaignHistoryRepository.Tablewhere c.CampaignId == campaign.Id@@ -121,8 +116,7 @@ namespace Grand.Business.Marketing.Services.Campaigns}public virtual async Task<IPagedList<NewsLetterSubscription>> CustomerSubscriptions(Campaign campaign, int pageIndex = 0, int pageSize = int.MaxValue){- if (campaign == null)- throw new ArgumentNullException(nameof(campaign));+ ArgumentNullException.ThrowIfNull(campaign);PagedList<NewsLetterSubscription> model;if (campaign.CustomerCreatedDateFrom.HasValue || campaign.CustomerCreatedDateTo.HasValue ||@@ -261,11 +255,8 @@ namespace Grand.Business.Marketing.Services.Campaignspublic virtual async Task<int> SendCampaign(Campaign campaign, EmailAccount emailAccount,IEnumerable<NewsLetterSubscription> subscriptions){- if (campaign == null)- throw new ArgumentNullException(nameof(campaign));-- if (emailAccount == null)- throw new ArgumentNullException(nameof(emailAccount));+ ArgumentNullException.ThrowIfNull(campaign);+ ArgumentNullException.ThrowIfNull(emailAccount);var totalEmailsSent = 0;var language = await languageService.GetLanguageById(campaign.LanguageId) ?? (await languageService.GetAllLanguages()).FirstOrDefault();@@ -327,11 +318,8 @@ namespace Grand.Business.Marketing.Services.Campaigns/// <param name="email">Email</param>public virtual async Task SendCampaign(Campaign campaign, EmailAccount emailAccount, string email){- if (campaign == null)- throw new ArgumentNullException(nameof(campaign));-- if (emailAccount == null)- throw new ArgumentNullException(nameof(emailAccount));+ ArgumentNullException.ThrowIfNull(campaign);+ ArgumentNullException.ThrowIfNull(emailAccount);var language = await languageService.GetLanguageById(campaign.LanguageId) ?? (await languageService.GetAllLanguages()).FirstOrDefault();diff --git a/src/Business/Grand.Business.Marketing/Services/Contacts/ContactAttributeParser.cs b/src/Business/Grand.Business.Marketing/Services/Contacts/ContactAttributeParser.csindex 17449997a..0f7eb3338 100644--- a/src/Business/Grand.Business.Marketing/Services/Contacts/ContactAttributeParser.cs+++ b/src/Business/Grand.Business.Marketing/Services/Contacts/ContactAttributeParser.cs@@ -106,9 +106,7 @@ namespace Grand.Business.Marketing.Services.Contactspublic virtual async Task<bool?> IsConditionMet(ContactAttribute attribute,IList<CustomAttribute> customAttributes){- if (attribute == null)- throw new ArgumentNullException(nameof(attribute));-+ ArgumentNullException.ThrowIfNull(attribute);customAttributes ??= new List<CustomAttribute>();var conditionAttribute = attribute.ConditionAttribute;diff --git a/src/Business/Grand.Business.Marketing/Services/Contacts/ContactAttributeService.cs b/src/Business/Grand.Business.Marketing/Services/Contacts/ContactAttributeService.csindex d8e22cf18..d737fa0a0 100644--- a/src/Business/Grand.Business.Marketing/Services/Contacts/ContactAttributeService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Contacts/ContactAttributeService.cs@@ -55,8 +55,7 @@ namespace Grand.Business.Marketing.Services.Contacts/// <param name="contactAttribute">Contact attribute</param>public virtual async Task DeleteContactAttribute(ContactAttribute contactAttribute){- if (contactAttribute == null)- throw new ArgumentNullException(nameof(contactAttribute));+ ArgumentNullException.ThrowIfNull(contactAttribute);await _contactAttributeRepository.DeleteAsync(contactAttribute);@@ -121,8 +120,7 @@ namespace Grand.Business.Marketing.Services.Contacts/// <param name="contactAttribute">Contact attribute</param>public virtual async Task InsertContactAttribute(ContactAttribute contactAttribute){- if (contactAttribute == null)- throw new ArgumentNullException(nameof(contactAttribute));+ ArgumentNullException.ThrowIfNull(contactAttribute);await _contactAttributeRepository.InsertAsync(contactAttribute);@@ -139,8 +137,7 @@ namespace Grand.Business.Marketing.Services.Contacts/// <param name="contactAttribute">Contact attribute</param>public virtual async Task UpdateContactAttribute(ContactAttribute contactAttribute){- if (contactAttribute == null)- throw new ArgumentNullException(nameof(contactAttribute));+ ArgumentNullException.ThrowIfNull(contactAttribute);await _contactAttributeRepository.UpdateAsync(contactAttribute);diff --git a/src/Business/Grand.Business.Marketing/Services/Contacts/ContactUsService.cs b/src/Business/Grand.Business.Marketing/Services/Contacts/ContactUsService.csindex 0737ae77f..fba07d19b 100644--- a/src/Business/Grand.Business.Marketing/Services/Contacts/ContactUsService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Contacts/ContactUsService.cs@@ -29,8 +29,7 @@ namespace Grand.Business.Marketing.Services.Contacts/// <param name="contactus">ContactUs item</param>public virtual async Task DeleteContactUs(ContactUs contactus){- if (contactus == null)- throw new ArgumentNullException(nameof(contactus));+ ArgumentNullException.ThrowIfNull(contactus);await _contactusRepository.DeleteAsync(contactus);@@ -103,8 +102,7 @@ namespace Grand.Business.Marketing.Services.Contacts/// <returns>A contactus item</returns>public virtual async Task InsertContactUs(ContactUs contactus){- if (contactus == null)- throw new ArgumentNullException(nameof(contactus));+ ArgumentNullException.ThrowIfNull(contactus);await _contactusRepository.InsertAsync(contactus);diff --git a/src/Business/Grand.Business.Marketing/Services/Courses/CourseActionService.cs b/src/Business/Grand.Business.Marketing/Services/Courses/CourseActionService.csindex 8a3067273..15b4e68ee 100644--- a/src/Business/Grand.Business.Marketing/Services/Courses/CourseActionService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Courses/CourseActionService.cs@@ -41,8 +41,7 @@ namespace Grand.Business.Marketing.Services.Coursespublic virtual async Task<CourseAction> InsertAsync(CourseAction courseAction){- if (courseAction == null)- throw new ArgumentNullException(nameof(courseAction));+ ArgumentNullException.ThrowIfNull(courseAction);await _courseActionRepository.InsertAsync(courseAction);@@ -54,8 +53,7 @@ namespace Grand.Business.Marketing.Services.Coursespublic virtual async Task<CourseAction> Update(CourseAction courseAction){- if (courseAction == null)- throw new ArgumentNullException(nameof(courseAction));+ ArgumentNullException.ThrowIfNull(courseAction);await _courseActionRepository.UpdateAsync(courseAction);diff --git a/src/Business/Grand.Business.Marketing/Services/Courses/CourseLessonService.cs b/src/Business/Grand.Business.Marketing/Services/Courses/CourseLessonService.csindex 293380c0f..a9f6d8632 100644--- a/src/Business/Grand.Business.Marketing/Services/Courses/CourseLessonService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Courses/CourseLessonService.cs@@ -19,8 +19,7 @@ namespace Grand.Business.Marketing.Services.Coursespublic virtual async Task Delete(CourseLesson courseLesson){- if (courseLesson == null)- throw new ArgumentNullException(nameof(courseLesson));+ ArgumentNullException.ThrowIfNull(courseLesson);await _courseLessonRepository.DeleteAsync(courseLesson);@@ -47,8 +46,7 @@ namespace Grand.Business.Marketing.Services.Coursespublic virtual async Task<CourseLesson> Insert(CourseLesson courseLesson){- if (courseLesson == null)- throw new ArgumentNullException(nameof(courseLesson));+ ArgumentNullException.ThrowIfNull(courseLesson);await _courseLessonRepository.InsertAsync(courseLesson);@@ -60,8 +58,7 @@ namespace Grand.Business.Marketing.Services.Coursespublic virtual async Task<CourseLesson> Update(CourseLesson courseLesson){- if (courseLesson == null)- throw new ArgumentNullException(nameof(courseLesson));+ ArgumentNullException.ThrowIfNull(courseLesson);await _courseLessonRepository.UpdateAsync(courseLesson);diff --git a/src/Business/Grand.Business.Marketing/Services/Courses/CourseLevelService.cs b/src/Business/Grand.Business.Marketing/Services/Courses/CourseLevelService.csindex 3edc41029..5d1a7f08c 100644--- a/src/Business/Grand.Business.Marketing/Services/Courses/CourseLevelService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Courses/CourseLevelService.cs@@ -19,8 +19,7 @@ namespace Grand.Business.Marketing.Services.Coursespublic virtual async Task Delete(CourseLevel courseLevel){- if (courseLevel == null)- throw new ArgumentNullException(nameof(courseLevel));+ ArgumentNullException.ThrowIfNull(courseLevel);await _courseLevelRepository.DeleteAsync(courseLevel);@@ -44,8 +43,7 @@ namespace Grand.Business.Marketing.Services.Coursespublic virtual async Task<CourseLevel> Insert(CourseLevel courseLevel){- if (courseLevel == null)- throw new ArgumentNullException(nameof(courseLevel));+ ArgumentNullException.ThrowIfNull(courseLevel);await _courseLevelRepository.InsertAsync(courseLevel);@@ -57,8 +55,7 @@ namespace Grand.Business.Marketing.Services.Coursespublic virtual async Task<CourseLevel> Update(CourseLevel courseLevel){- if (courseLevel == null)- throw new ArgumentNullException(nameof(courseLevel));+ ArgumentNullException.ThrowIfNull(courseLevel);await _courseLevelRepository.UpdateAsync(courseLevel);diff --git a/src/Business/Grand.Business.Marketing/Services/Courses/CourseService.cs b/src/Business/Grand.Business.Marketing/Services/Courses/CourseService.csindex 83c4355d7..4ddc17cda 100644--- a/src/Business/Grand.Business.Marketing/Services/Courses/CourseService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Courses/CourseService.cs@@ -30,8 +30,7 @@ namespace Grand.Business.Marketing.Services.Coursespublic virtual async Task Delete(Course course){- if (course == null)- throw new ArgumentNullException(nameof(course));+ ArgumentNullException.ThrowIfNull(course);await _courseRepository.DeleteAsync(course);@@ -94,8 +93,7 @@ namespace Grand.Business.Marketing.Services.Coursespublic virtual async Task<Course> Insert(Course course){- if (course == null)- throw new ArgumentNullException(nameof(course));+ ArgumentNullException.ThrowIfNull(course);await _courseRepository.InsertAsync(course);@@ -107,8 +105,7 @@ namespace Grand.Business.Marketing.Services.Coursespublic virtual async Task<Course> Update(Course course){- if (course == null)- throw new ArgumentNullException(nameof(course));+ ArgumentNullException.ThrowIfNull(course);await _courseRepository.UpdateAsync(course);diff --git a/src/Business/Grand.Business.Marketing/Services/Courses/CourseSubjectService.cs b/src/Business/Grand.Business.Marketing/Services/Courses/CourseSubjectService.csindex 812b305c7..752891a49 100644--- a/src/Business/Grand.Business.Marketing/Services/Courses/CourseSubjectService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Courses/CourseSubjectService.cs@@ -19,8 +19,7 @@ namespace Grand.Business.Marketing.Services.Coursespublic virtual async Task Delete(CourseSubject courseSubject){- if (courseSubject == null)- throw new ArgumentNullException(nameof(courseSubject));+ ArgumentNullException.ThrowIfNull(courseSubject);await _courseSubjectRepository.DeleteAsync(courseSubject);@@ -48,8 +47,7 @@ namespace Grand.Business.Marketing.Services.Coursespublic virtual async Task<CourseSubject> Insert(CourseSubject courseSubject){- if (courseSubject == null)- throw new ArgumentNullException(nameof(courseSubject));+ ArgumentNullException.ThrowIfNull(courseSubject);await _courseSubjectRepository.InsertAsync(courseSubject);@@ -61,8 +59,7 @@ namespace Grand.Business.Marketing.Services.Coursespublic virtual async Task<CourseSubject> Update(CourseSubject courseSubject){- if (courseSubject == null)- throw new ArgumentNullException(nameof(courseSubject));+ ArgumentNullException.ThrowIfNull(courseSubject);await _courseSubjectRepository.UpdateAsync(courseSubject);diff --git a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerCoordinatesService.cs b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerCoordinatesService.csindex d4695b58e..4195c7d34 100644--- a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerCoordinatesService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerCoordinatesService.cs@@ -30,8 +30,7 @@ namespace Grand.Business.Marketing.Services.Customerspublic async Task<(double longitude, double latitude)> GetGeoCoordinate(Customer customer){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);if (customer.Coordinates == null)await Task.FromResult((0, 0));diff --git a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerProductService.cs b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerProductService.csindex ade41bfed..9c0e596b1 100644--- a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerProductService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerProductService.cs@@ -70,8 +70,7 @@ namespace Grand.Business.Marketing.Services.Customers/// <param name="customerProductPrice">Customer product price</param>public virtual async Task InsertCustomerProductPrice(CustomerProductPrice customerProductPrice){- if (customerProductPrice == null)- throw new ArgumentNullException(nameof(customerProductPrice));+ ArgumentNullException.ThrowIfNull(customerProductPrice);await _customerProductPriceRepository.InsertAsync(customerProductPrice);@@ -88,8 +87,7 @@ namespace Grand.Business.Marketing.Services.Customers/// <param name="customerProductPrice">Customer product price</param>public virtual async Task UpdateCustomerProductPrice(CustomerProductPrice customerProductPrice){- if (customerProductPrice == null)- throw new ArgumentNullException(nameof(customerProductPrice));+ ArgumentNullException.ThrowIfNull(customerProductPrice);await _customerProductPriceRepository.UpdateAsync(customerProductPrice);@@ -106,8 +104,7 @@ namespace Grand.Business.Marketing.Services.Customers/// <param name="customerProductPrice">Customer product price</param>public virtual async Task DeleteCustomerProductPrice(CustomerProductPrice customerProductPrice){- if (customerProductPrice == null)- throw new ArgumentNullException(nameof(customerProductPrice));+ ArgumentNullException.ThrowIfNull(customerProductPrice);await _customerProductPriceRepository.DeleteAsync(customerProductPrice);@@ -161,8 +158,7 @@ namespace Grand.Business.Marketing.Services.Customers/// <param name="customerProduct">Customer product</param>public virtual async Task InsertCustomerProduct(CustomerProduct customerProduct){- if (customerProduct == null)- throw new ArgumentNullException(nameof(customerProduct));+ ArgumentNullException.ThrowIfNull(customerProduct);await _customerProductRepository.InsertAsync(customerProduct);@@ -179,8 +175,7 @@ namespace Grand.Business.Marketing.Services.Customers/// <param name="customerProduct">Customer product </param>public virtual async Task UpdateCustomerProduct(CustomerProduct customerProduct){- if (customerProduct == null)- throw new ArgumentNullException(nameof(customerProduct));+ ArgumentNullException.ThrowIfNull(customerProduct);await _customerProductRepository.UpdateAsync(customerProduct);@@ -197,8 +192,7 @@ namespace Grand.Business.Marketing.Services.Customers/// <param name="customerProduct">Customer product</param>public virtual async Task DeleteCustomerProduct(CustomerProduct customerProduct){- if (customerProduct == null)- throw new ArgumentNullException(nameof(customerProduct));+ ArgumentNullException.ThrowIfNull(customerProduct);await _customerProductRepository.DeleteAsync(customerProduct);diff --git a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerTagService.cs b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerTagService.csindex d3838fd44..859a1e7c3 100644--- a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerTagService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerTagService.cs@@ -63,8 +63,7 @@ namespace Grand.Business.Marketing.Services.Customers/// <param name="customerTag">Customer tag</param>public virtual async Task DeleteCustomerTag(CustomerTag customerTag){- if (customerTag == null)- throw new ArgumentNullException(nameof(customerTag));+ ArgumentNullException.ThrowIfNull(customerTag);//update customerawait _customerRepository.Pull(string.Empty, x => x.CustomerTags, customerTag.Id);@@ -128,8 +127,7 @@ namespace Grand.Business.Marketing.Services.Customers/// <param name="customerTag">Customer tag</param>public virtual async Task InsertCustomerTag(CustomerTag customerTag){- if (customerTag == null)- throw new ArgumentNullException(nameof(customerTag));+ ArgumentNullException.ThrowIfNull(customerTag);await _customerTagRepository.InsertAsync(customerTag);@@ -159,8 +157,7 @@ namespace Grand.Business.Marketing.Services.Customers/// <param name="customerTag">Customer tag</param>public virtual async Task UpdateCustomerTag(CustomerTag customerTag){- if (customerTag == null)- throw new ArgumentNullException(nameof(customerTag));+ ArgumentNullException.ThrowIfNull(customerTag);await _customerTagRepository.UpdateAsync(customerTag);@@ -234,8 +231,7 @@ namespace Grand.Business.Marketing.Services.Customers/// <param name="customerTagProduct">Customer tag product</param>public virtual async Task InsertCustomerTagProduct(CustomerTagProduct customerTagProduct){- if (customerTagProduct == null)- throw new ArgumentNullException(nameof(customerTagProduct));+ ArgumentNullException.ThrowIfNull(customerTagProduct);await _customerTagProductRepository.InsertAsync(customerTagProduct);@@ -253,8 +249,7 @@ namespace Grand.Business.Marketing.Services.Customers/// <param name="customerTagProduct">Customer tag product</param>public virtual async Task UpdateCustomerTagProduct(CustomerTagProduct customerTagProduct){- if (customerTagProduct == null)- throw new ArgumentNullException(nameof(customerTagProduct));+ ArgumentNullException.ThrowIfNull(customerTagProduct);await _customerTagProductRepository.UpdateAsync(customerTagProduct);@@ -272,8 +267,7 @@ namespace Grand.Business.Marketing.Services.Customers/// <param name="customerTagProduct">Customer tag product</param>public virtual async Task DeleteCustomerTagProduct(CustomerTagProduct customerTagProduct){- if (customerTagProduct == null)- throw new ArgumentNullException(nameof(customerTagProduct));+ ArgumentNullException.ThrowIfNull(customerTagProduct);await _customerTagProductRepository.DeleteAsync(customerTagProduct);diff --git a/src/Business/Grand.Business.Marketing/Services/Documents/DocumentService.cs b/src/Business/Grand.Business.Marketing/Services/Documents/DocumentService.csindex dd3fb40d6..269a0eaa5 100644--- a/src/Business/Grand.Business.Marketing/Services/Documents/DocumentService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Documents/DocumentService.cs@@ -21,8 +21,7 @@ namespace Grand.Business.Marketing.Services.Documentspublic virtual async Task Delete(Document document){- if (document == null)- throw new ArgumentNullException(nameof(document));+ ArgumentNullException.ThrowIfNull(document);await _documentRepository.DeleteAsync(document);@@ -71,8 +70,7 @@ namespace Grand.Business.Marketing.Services.Documentspublic virtual async Task Insert(Document document){- if (document == null)- throw new ArgumentNullException(nameof(document));+ ArgumentNullException.ThrowIfNull(document);await _documentRepository.InsertAsync(document);@@ -83,8 +81,7 @@ namespace Grand.Business.Marketing.Services.Documentspublic virtual async Task Update(Document document){- if (document == null)- throw new ArgumentNullException(nameof(document));+ ArgumentNullException.ThrowIfNull(document);await _documentRepository.UpdateAsync(document);diff --git a/src/Business/Grand.Business.Marketing/Services/Documents/DocumentTypeService.cs b/src/Business/Grand.Business.Marketing/Services/Documents/DocumentTypeService.csindex b138de552..e71a17660 100644--- a/src/Business/Grand.Business.Marketing/Services/Documents/DocumentTypeService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Documents/DocumentTypeService.cs@@ -19,8 +19,7 @@ namespace Grand.Business.Marketing.Services.Documentspublic virtual async Task Delete(DocumentType documentType){- if (documentType == null)- throw new ArgumentNullException(nameof(documentType));+ ArgumentNullException.ThrowIfNull(documentType);await _documentTypeRepository.DeleteAsync(documentType);@@ -43,8 +42,7 @@ namespace Grand.Business.Marketing.Services.Documentspublic virtual async Task Insert(DocumentType documentType){- if (documentType == null)- throw new ArgumentNullException(nameof(documentType));+ ArgumentNullException.ThrowIfNull(documentType);await _documentTypeRepository.InsertAsync(documentType);@@ -54,8 +52,7 @@ namespace Grand.Business.Marketing.Services.Documentspublic virtual async Task Update(DocumentType documentType){- if (documentType == null)- throw new ArgumentNullException(nameof(documentType));+ ArgumentNullException.ThrowIfNull(documentType);await _documentTypeRepository.UpdateAsync(documentType);diff --git a/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsLetterSubscriptionService.cs b/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsLetterSubscriptionService.csindex d417d354c..ceb63d43f 100644--- a/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsLetterSubscriptionService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsLetterSubscriptionService.cs@@ -72,10 +72,7 @@ namespace Grand.Business.Marketing.Services.Newsletters/// <param name="publishSubscriptionEvents">if set to <c>true</c> [publish subscription events].</param>public virtual async Task InsertNewsLetterSubscription(NewsLetterSubscription newsLetterSubscription, bool publishSubscriptionEvents = true){- if (newsLetterSubscription == null)- {- throw new ArgumentNullException(nameof(newsLetterSubscription));- }+ ArgumentNullException.ThrowIfNull(newsLetterSubscription);//Handle e-mailnewsLetterSubscription.Email = CommonHelper.EnsureSubscriberEmailOrThrow(newsLetterSubscription.Email);@@ -103,10 +100,7 @@ namespace Grand.Business.Marketing.Services.Newsletters/// <param name="publishSubscriptionEvents">if set to <c>true</c> [publish subscription events].</param>public virtual async Task UpdateNewsLetterSubscription(NewsLetterSubscription newsLetterSubscription, bool publishSubscriptionEvents = true){- if (newsLetterSubscription == null)- {- throw new ArgumentNullException(nameof(newsLetterSubscription));- }+ ArgumentNullException.ThrowIfNull(newsLetterSubscription);//Handle e-mailnewsLetterSubscription.Email = CommonHelper.EnsureSubscriberEmailOrThrow(newsLetterSubscription.Email);@@ -144,8 +138,7 @@ namespace Grand.Business.Marketing.Services.Newsletters/// <param name="publishSubscriptionEvents">if set to <c>true</c> [publish subscription events].</param>public virtual async Task DeleteNewsLetterSubscription(NewsLetterSubscription newsLetterSubscription, bool publishSubscriptionEvents = true){- if (newsLetterSubscription == null)- throw new ArgumentNullException(nameof(newsLetterSubscription));+ ArgumentNullException.ThrowIfNull(newsLetterSubscription);await _subscriptionRepository.DeleteAsync(newsLetterSubscription);@@ -257,8 +250,7 @@ namespace Grand.Business.Marketing.Services.Newsletters/// <returns>Result in TXT (string) format</returns>public virtual string ExportNewsletterSubscribersToTxt(IList<NewsLetterSubscription> subscriptions){- if (subscriptions == null)- throw new ArgumentNullException(nameof(subscriptions));+ ArgumentNullException.ThrowIfNull(subscriptions);const char separator = ',';var sb = new StringBuilder();diff --git a/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsletterCategoryService.cs b/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsletterCategoryService.csindex 80011b8ef..73b5e7dfb 100644--- a/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsletterCategoryService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsletterCategoryService.cs@@ -31,8 +31,7 @@ namespace Grand.Business.Marketing.Services.Newsletters/// <param name="newsletterCategory">NewsletterCategory</param>public virtual async Task InsertNewsletterCategory(NewsletterCategory newsletterCategory){- if (newsletterCategory == null)- throw new ArgumentNullException(nameof(newsletterCategory));+ ArgumentNullException.ThrowIfNull(newsletterCategory);await _newsletterCategoryRepository.InsertAsync(newsletterCategory);@@ -46,8 +45,7 @@ namespace Grand.Business.Marketing.Services.Newsletters/// <param name="newsletterCategory">NewsletterCategory</param>public virtual async Task UpdateNewsletterCategory(NewsletterCategory newsletterCategory){- if (newsletterCategory == null)- throw new ArgumentNullException(nameof(newsletterCategory));+ ArgumentNullException.ThrowIfNull(newsletterCategory);await _newsletterCategoryRepository.UpdateAsync(newsletterCategory);@@ -62,8 +60,7 @@ namespace Grand.Business.Marketing.Services.Newsletters/// <param name="newsletterCategory">NewsletterCategory</param>public virtual async Task DeleteNewsletterCategory(NewsletterCategory newsletterCategory){- if (newsletterCategory == null)- throw new ArgumentNullException(nameof(newsletterCategory));+ ArgumentNullException.ThrowIfNull(newsletterCategory);await _newsletterCategoryRepository.DeleteAsync(newsletterCategory);diff --git a/src/Business/Grand.Business.Messages/Services/EmailAccountService.cs b/src/Business/Grand.Business.Messages/Services/EmailAccountService.csindex 2e44d614a..1e71f197b 100644--- a/src/Business/Grand.Business.Messages/Services/EmailAccountService.cs+++ b/src/Business/Grand.Business.Messages/Services/EmailAccountService.cs@@ -38,8 +38,7 @@ namespace Grand.Business.Messages.Services/// <param name="emailAccount">Email account</param>public virtual async Task InsertEmailAccount(EmailAccount emailAccount){- if (emailAccount == null)- throw new ArgumentNullException(nameof(emailAccount));+ ArgumentNullException.ThrowIfNull(emailAccount);emailAccount.Email = CommonHelper.EnsureNotNull(emailAccount.Email);emailAccount.DisplayName = CommonHelper.EnsureNotNull(emailAccount.DisplayName);@@ -74,8 +73,7 @@ namespace Grand.Business.Messages.Services/// <param name="emailAccount">Email account</param>public virtual async Task UpdateEmailAccount(EmailAccount emailAccount){- if (emailAccount == null)- throw new ArgumentNullException(nameof(emailAccount));+ ArgumentNullException.ThrowIfNull(emailAccount);emailAccount.Email = CommonHelper.EnsureNotNull(emailAccount.Email);emailAccount.DisplayName = CommonHelper.EnsureNotNull(emailAccount.DisplayName);@@ -110,8 +108,7 @@ namespace Grand.Business.Messages.Services/// <param name="emailAccount">Email account</param>public virtual async Task DeleteEmailAccount(EmailAccount emailAccount){- if (emailAccount == null)- throw new ArgumentNullException(nameof(emailAccount));+ ArgumentNullException.ThrowIfNull(emailAccount);var emailAccounts = await GetAllEmailAccounts();if (emailAccounts.Count == 1)throw new GrandException("You cannot delete this email account. At least one account is required.");diff --git a/src/Business/Grand.Business.Messages/Services/MessageProviderService.cs b/src/Business/Grand.Business.Messages/Services/MessageProviderService.csindex 22035c901..0f382315f 100644--- a/src/Business/Grand.Business.Messages/Services/MessageProviderService.cs+++ b/src/Business/Grand.Business.Messages/Services/MessageProviderService.cs@@ -137,8 +137,7 @@ namespace Grand.Business.Messages.Services/// <param name="customerNote">Customer note</param>protected virtual async Task<int> SendCustomerMessage(Customer customer, Store store, string languageId, string templateName, bool toEmailAccount = false, CustomerNote customerNote = null){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -291,8 +290,7 @@ namespace Grand.Business.Messages.Services/// <param name="refundedAmount"></param>private async Task<int> SendOrderStoreOwnerMessage(string template, Order order, Customer customer, string languageId, double refundedAmount = 0){- if (order == null)- throw new ArgumentNullException(nameof(order));+ ArgumentNullException.ThrowIfNull(order);var store = await GetStore(order.StoreId);var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -404,8 +402,7 @@ namespace Grand.Business.Messages.Servicesprivate async Task<int> SendOrderCustomerMessage(string message, Order order, Customer customer, string languageId,string attachmentFilePath = null, string attachmentFileName = null, IEnumerable<string> attachments = null, double refundedAmount = 0){- if (order == null)- throw new ArgumentNullException(nameof(order));+ ArgumentNullException.ThrowIfNull(order);var store = await GetStore(order.StoreId);var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -480,11 +477,8 @@ namespace Grand.Business.Messages.Services/// <param name="languageId">Message language identifier</param>private async Task<int> SendOrderVendorMessage(string message, Order order, Vendor vendor, string languageId){- if (order == null)- throw new ArgumentNullException(nameof(order));-- if (vendor == null)- throw new ArgumentNullException(nameof(vendor));+ ArgumentNullException.ThrowIfNull(order);+ ArgumentNullException.ThrowIfNull(vendor);var store = await GetStore(order.StoreId);var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -546,8 +540,7 @@ namespace Grand.Business.Messages.Services/// <param name="order">Order</param>private async Task<int> SendShipmentCustomerMessage(string message, Shipment shipment, Order order){- if (shipment == null)- throw new ArgumentNullException(nameof(shipment));+ ArgumentNullException.ThrowIfNull(shipment);if (order == null)throw new Exception("Order cannot be loaded");@@ -592,11 +585,8 @@ namespace Grand.Business.Messages.Services/// <param name="orderNote">Order note</param>public virtual async Task<int> SendNewOrderNoteAddedCustomerMessage(Order order, OrderNote orderNote){- if (orderNote == null)- throw new ArgumentNullException(nameof(orderNote));-- if (order == null)- throw new ArgumentNullException(nameof(order));+ ArgumentNullException.ThrowIfNull(orderNote);+ ArgumentNullException.ThrowIfNull(order);var store = await GetStore(order.StoreId);var language = await EnsureLanguageIsActive(order.CustomerLanguageId, store.Id);@@ -663,8 +653,7 @@ namespace Grand.Business.Messages.Servicesprivate async Task<int> SendNewsLetterSubscriptionMessage(string message, NewsLetterSubscription subscription,string languageId){- if (subscription == null)- throw new ArgumentNullException(nameof(subscription));+ ArgumentNullException.ThrowIfNull(subscription);var store = await GetStore(subscription.StoreId);var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -708,11 +697,8 @@ namespace Grand.Business.Messages.Servicespublic virtual async Task<int> SendProductEmailAFriendMessage(Customer customer, Store store, string languageId,Product product, string customerEmail, string friendsEmail, string personalMessage){- if (customer == null)- throw new ArgumentNullException(nameof(customer));-- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(customer);+ ArgumentNullException.ThrowIfNull(product);var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -754,8 +740,7 @@ namespace Grand.Business.Messages.Servicespublic virtual async Task<int> SendWishlistEmailAFriendMessage(Customer customer, Store store, string languageId,string customerEmail, string friendsEmail, string personalMessage){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -793,11 +778,8 @@ namespace Grand.Business.Messages.Servicespublic virtual async Task<int> SendProductQuestionMessage(Customer customer, Store store, string languageId,Product product, string customerEmail, string fullName, string phone, string message, string ipaddress){- if (customer == null)- throw new ArgumentNullException(nameof(customer));-- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(customer);+ ArgumentNullException.ThrowIfNull(product);var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -870,8 +852,7 @@ namespace Grand.Business.Messages.Services/// <param name="languageId">Message language identifier</param>public virtual async Task<int> SendNewMerchandiseReturnStoreOwnerMessage(MerchandiseReturn merchandiseReturn, Order order, string languageId){- if (merchandiseReturn == null)- throw new ArgumentNullException(nameof(merchandiseReturn));+ ArgumentNullException.ThrowIfNull(merchandiseReturn);var store = await GetStore(order.StoreId);var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -926,8 +907,7 @@ namespace Grand.Business.Messages.Services/// <param name="languageId">Message language identifier</param>public virtual async Task<int> SendMerchandiseReturnStatusChangedCustomerMessage(MerchandiseReturn merchandiseReturn, Order order, string languageId){- if (merchandiseReturn == null)- throw new ArgumentNullException(nameof(merchandiseReturn));+ ArgumentNullException.ThrowIfNull(merchandiseReturn);var store = await GetStore(order.StoreId);var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -971,8 +951,7 @@ namespace Grand.Business.Messages.Services/// <param name="languageId">Message language identifier</param>public virtual async Task<int> SendNewMerchandiseReturnCustomerMessage(MerchandiseReturn merchandiseReturn, Order order, string languageId){- if (merchandiseReturn == null)- throw new ArgumentNullException(nameof(merchandiseReturn));+ ArgumentNullException.ThrowIfNull(merchandiseReturn);var store = await GetStore(order.StoreId);var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -1016,11 +995,8 @@ namespace Grand.Business.Messages.Services/// <param name="order">Order</param>public virtual async Task<int> SendNewMerchandiseReturnNoteAddedCustomerMessage(MerchandiseReturn merchandiseReturn, MerchandiseReturnNote merchandiseReturnNote, Order order){- if (merchandiseReturnNote == null)- throw new ArgumentNullException(nameof(merchandiseReturnNote));-- if (merchandiseReturn == null)- throw new ArgumentNullException(nameof(merchandiseReturn));+ ArgumentNullException.ThrowIfNull(merchandiseReturnNote);+ ArgumentNullException.ThrowIfNull(merchandiseReturn);var store = await GetStore(order.StoreId);var language = await EnsureLanguageIsActive(order.CustomerLanguageId, store.Id);@@ -1069,11 +1045,8 @@ namespace Grand.Business.Messages.Services/// <param name="languageId">Message language identifier</param>public virtual async Task<int> SendNewVendorAccountApplyStoreOwnerMessage(Customer customer, Vendor vendor, Store store, string languageId){- if (customer == null)- throw new ArgumentNullException(nameof(customer));-- if (vendor == null)- throw new ArgumentNullException(nameof(vendor));+ ArgumentNullException.ThrowIfNull(customer);+ ArgumentNullException.ThrowIfNull(vendor);var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -1108,8 +1081,7 @@ namespace Grand.Business.Messages.Services/// <param name="languageId">Message language identifier</param>public virtual async Task<int> SendVendorInformationChangeMessage(Vendor vendor, Store store, string languageId){- if (vendor == null)- throw new ArgumentNullException(nameof(vendor));+ ArgumentNullException.ThrowIfNull(vendor);var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -1143,8 +1115,7 @@ namespace Grand.Business.Messages.Services/// <param name="languageId">Message language identifier</param>public virtual async Task<int> SendGiftVoucherMessage(GiftVoucher giftVoucher, Order order, string languageId){- if (giftVoucher == null)- throw new ArgumentNullException(nameof(giftVoucher));+ ArgumentNullException.ThrowIfNull(giftVoucher);Store store = null;if (order != null) store = await _storeService.GetStoreById(order.StoreId);@@ -1182,8 +1153,7 @@ namespace Grand.Business.Messages.Servicespublic virtual async Task<int> SendProductReviewMessage(Product product, ProductReview productReview,Store store, string languageId){- if (productReview == null)- throw new ArgumentNullException(nameof(productReview));+ ArgumentNullException.ThrowIfNull(productReview);var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -1225,8 +1195,7 @@ namespace Grand.Business.Messages.Servicespublic virtual async Task<int> SendVendorReviewMessage(VendorReview vendorReview, Store store,string languageId){- if (vendorReview == null)- throw new ArgumentNullException(nameof(vendorReview));+ ArgumentNullException.ThrowIfNull(vendorReview);var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -1269,8 +1238,7 @@ namespace Grand.Business.Messages.Services/// <param name="languageId">Message language identifier</param>public virtual async Task<int> SendQuantityBelowStoreOwnerMessage(Product product, string languageId){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);var store = await GetStore("");var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -1305,8 +1273,7 @@ namespace Grand.Business.Messages.Services/// <param name="languageId">Message language identifier</param>public virtual async Task<int> SendQuantityBelowStoreOwnerMessage(Product product, ProductAttributeCombination combination, string languageId){- if (combination == null)- throw new ArgumentNullException(nameof(combination));+ ArgumentNullException.ThrowIfNull(combination);var store = await GetStore("");var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -1341,8 +1308,7 @@ namespace Grand.Business.Messages.Services/// <param name="languageId">Message language identifier</param>public virtual async Task<int> SendCustomerDeleteStoreOwnerMessage(Customer customer, string languageId){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);var store = await GetStore("");var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -1373,8 +1339,7 @@ namespace Grand.Business.Messages.Services/// </summary>public virtual async Task<int> SendBlogCommentMessage(BlogPost blogPost, BlogComment blogComment, string languageId){- if (blogComment == null)- throw new ArgumentNullException(nameof(blogComment));+ ArgumentNullException.ThrowIfNull(blogComment);var store = await GetStore(blogComment.StoreId);var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -1414,8 +1379,7 @@ namespace Grand.Business.Messages.Services/// <param name="languageId">Message language identifier</param>public virtual async Task<int> SendArticleCommentMessage(KnowledgebaseArticle article, KnowledgebaseArticleComment articleComment, string languageId){- if (articleComment == null)- throw new ArgumentNullException(nameof(articleComment));+ ArgumentNullException.ThrowIfNull(articleComment);var store = await GetStore("");var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -1453,8 +1417,7 @@ namespace Grand.Business.Messages.Services/// <param name="languageId">Message language identifier</param>public virtual async Task<int> SendNewsCommentMessage(NewsItem newsItem, NewsComment newsComment, string languageId){- if (newsComment == null)- throw new ArgumentNullException(nameof(newsComment));+ ArgumentNullException.ThrowIfNull(newsComment);var store = await GetStore(newsComment.StoreId);var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -1493,8 +1456,7 @@ namespace Grand.Business.Messages.Services/// <param name="languageId">Message language identifier</param>public virtual async Task<int> SendBackInStockMessage(Customer customer, Product product, OutOfStockSubscription subscription, string languageId){- if (subscription == null)- throw new ArgumentNullException(nameof(subscription));+ ArgumentNullException.ThrowIfNull(subscription);var store = await GetStore(subscription.StoreId);var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -1616,8 +1578,7 @@ namespace Grand.Business.Messages.Servicespublic virtual async Task<int> SendContactVendorMessage(Customer customer, Store store, Vendor vendor, string languageId, string senderEmail,string senderName, string subject, string body, string ipaddress){- if (vendor == null)- throw new ArgumentNullException(nameof(vendor));+ ArgumentNullException.ThrowIfNull(vendor);var language = await EnsureLanguageIsActive(languageId, store.Id);@@ -1686,8 +1647,7 @@ namespace Grand.Business.Messages.Servicespublic virtual async Task<int> SendAuctionWinEndedCustomerMessage(Product product, string languageId, Bid bid){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);var customer = await _mediator.Send(new GetCustomerByIdQuery { Id = bid.CustomerId });if (customer == null) return 0;@@ -1725,8 +1685,7 @@ namespace Grand.Business.Messages.Servicespublic virtual async Task<int> SendAuctionEndedLostCustomerMessage(Product product, string languageId, Bid bid){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);var winner = await _mediator.Send(new GetCustomerByIdQuery { Id = bid.CustomerId });if (winner == null) return 0;@@ -1774,8 +1733,7 @@ namespace Grand.Business.Messages.Servicespublic virtual async Task<int> SendAuctionEndedBinCustomerMessage(Product product, string customerId, string languageId, string storeId){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);var store = await GetStore(storeId);@@ -1821,8 +1779,7 @@ namespace Grand.Business.Messages.Services}public virtual async Task<int> SendAuctionEndedStoreOwnerMessage(Product product, string languageId, Bid bid){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);var builder = new LiquidObjectBuilder(_mediator);MessageTemplate messageTemplate;@@ -1881,8 +1838,7 @@ namespace Grand.Business.Messages.Services/// <param name="bid"></param>public virtual async Task<int> SendOutBidCustomerMessage(Product product, string languageId, Bid bid){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);var customer = await _mediator.Send(new GetCustomerByIdQuery { Id = bid.CustomerId });if (string.IsNullOrEmpty(languageId))diff --git a/src/Business/Grand.Business.Messages/Services/MessageTemplateService.cs b/src/Business/Grand.Business.Messages/Services/MessageTemplateService.csindex 0139f81df..58f27d2f1 100644--- a/src/Business/Grand.Business.Messages/Services/MessageTemplateService.cs+++ b/src/Business/Grand.Business.Messages/Services/MessageTemplateService.cs@@ -49,8 +49,7 @@ namespace Grand.Business.Messages.Services/// <param name="messageTemplate">Message template</param>public virtual async Task InsertMessageTemplate(MessageTemplate messageTemplate){- if (messageTemplate == null)- throw new ArgumentNullException(nameof(messageTemplate));+ ArgumentNullException.ThrowIfNull(messageTemplate);await _messageTemplateRepository.InsertAsync(messageTemplate);@@ -66,8 +65,7 @@ namespace Grand.Business.Messages.Services/// <param name="messageTemplate">Message template</param>public virtual async Task UpdateMessageTemplate(MessageTemplate messageTemplate){- if (messageTemplate == null)- throw new ArgumentNullException(nameof(messageTemplate));+ ArgumentNullException.ThrowIfNull(messageTemplate);await _messageTemplateRepository.UpdateAsync(messageTemplate);@@ -83,8 +81,7 @@ namespace Grand.Business.Messages.Services/// <param name="messageTemplate">Message template</param>public virtual async Task DeleteMessageTemplate(MessageTemplate messageTemplate){- if (messageTemplate == null)- throw new ArgumentNullException(nameof(messageTemplate));+ ArgumentNullException.ThrowIfNull(messageTemplate);await _messageTemplateRepository.DeleteAsync(messageTemplate);@@ -172,8 +169,7 @@ namespace Grand.Business.Messages.Services/// <returns>Message template copy</returns>public virtual async Task<MessageTemplate> CopyMessageTemplate(MessageTemplate messageTemplate){- if (messageTemplate == null)- throw new ArgumentNullException(nameof(messageTemplate));+ ArgumentNullException.ThrowIfNull(messageTemplate);var mtCopy = new MessageTemplate {Name = messageTemplate.Name,diff --git a/src/Business/Grand.Business.Messages/Services/QueuedEmailService.cs b/src/Business/Grand.Business.Messages/Services/QueuedEmailService.csindex 232047c80..c8ecad649 100644--- a/src/Business/Grand.Business.Messages/Services/QueuedEmailService.cs+++ b/src/Business/Grand.Business.Messages/Services/QueuedEmailService.cs@@ -31,8 +31,7 @@ namespace Grand.Business.Messages.Services/// <param name="queuedEmail">Queued email</param>public virtual async Task InsertQueuedEmail(QueuedEmail queuedEmail){- if (queuedEmail == null)- throw new ArgumentNullException(nameof(queuedEmail));+ ArgumentNullException.ThrowIfNull(queuedEmail);await _queuedEmailRepository.InsertAsync(queuedEmail);@@ -46,8 +45,7 @@ namespace Grand.Business.Messages.Services/// <param name="queuedEmail">Queued email</param>public virtual async Task UpdateQueuedEmail(QueuedEmail queuedEmail){- if (queuedEmail == null)- throw new ArgumentNullException(nameof(queuedEmail));+ ArgumentNullException.ThrowIfNull(queuedEmail);await _queuedEmailRepository.UpdateAsync(queuedEmail);@@ -61,8 +59,7 @@ namespace Grand.Business.Messages.Services/// <param name="queuedEmail">Queued email</param>public virtual async Task DeleteQueuedEmail(QueuedEmail queuedEmail){- if (queuedEmail == null)- throw new ArgumentNullException(nameof(queuedEmail));+ ArgumentNullException.ThrowIfNull(queuedEmail);await _queuedEmailRepository.DeleteAsync(queuedEmail);@@ -76,8 +73,7 @@ namespace Grand.Business.Messages.Services/// <param name="email">email</param>public virtual async Task DeleteCustomerEmail(string email){- if (email == null)- throw new ArgumentNullException(nameof(email));+ ArgumentNullException.ThrowIfNull(email);var deleteCustomerEmail = _queuedEmailRepository.Table.Where(x => x.To == email);diff --git a/src/Business/Grand.Business.Storage/Services/DownloadService.cs b/src/Business/Grand.Business.Storage/Services/DownloadService.csindex c424b59bc..2a1eb5928 100644--- a/src/Business/Grand.Business.Storage/Services/DownloadService.cs+++ b/src/Business/Grand.Business.Storage/Services/DownloadService.cs@@ -89,8 +89,7 @@ namespace Grand.Business.Storage.Services/// <param name="download">Download</param>public virtual async Task InsertDownload(Download download){- if (download == null)- throw new ArgumentNullException(nameof(download));+ ArgumentNullException.ThrowIfNull(download);if (!download.UseDownloadUrl){download.DownloadObjectId = await _storeFilesContext.BucketUploadFromBytes(download.Filename, download.DownloadBinary);@@ -108,8 +107,7 @@ namespace Grand.Business.Storage.Services/// <param name="download">Download</param>public virtual async Task UpdateDownload(Download download){- if (download == null)- throw new ArgumentNullException(nameof(download));+ ArgumentNullException.ThrowIfNull(download);await _downloadRepository.UpdateAsync(download);@@ -122,8 +120,7 @@ namespace Grand.Business.Storage.Services/// <param name="download">Download</param>public virtual async Task DeleteDownload(Download download){- if (download == null)- throw new ArgumentNullException(nameof(download));+ ArgumentNullException.ThrowIfNull(download);await _downloadRepository.DeleteAsync(download);diff --git a/src/Business/Grand.Business.Storage/Services/PictureService.cs b/src/Business/Grand.Business.Storage/Services/PictureService.csindex 6a0b9abee..d2f01a04c 100644--- a/src/Business/Grand.Business.Storage/Services/PictureService.cs+++ b/src/Business/Grand.Business.Storage/Services/PictureService.cs@@ -179,8 +179,7 @@ namespace Grand.Business.Storage.Services/// <returns>Picture binary</returns>public virtual async Task<byte[]> LoadPictureBinary(Picture picture, bool fromDb){- if (picture == null)- throw new ArgumentNullException(nameof(picture));+ ArgumentNullException.ThrowIfNull(picture);var result = fromDb? (await _pictureRepository.GetByIdAsync(picture.Id)).PictureBinary@@ -446,8 +445,7 @@ namespace Grand.Business.Storage.Services/// <param name="picture">Picture</param>public virtual async Task DeletePicture(Picture picture){- if (picture == null)- throw new ArgumentNullException(nameof(picture));+ ArgumentNullException.ThrowIfNull(picture);//delete thumbsawait DeletePictureThumbs(picture);@@ -469,8 +467,7 @@ namespace Grand.Business.Storage.Services/// <param name="picture">Picture</param>public virtual async Task DeletePictureOnFileSystem(Picture picture){- if (picture == null)- throw new ArgumentNullException(nameof(picture));+ ArgumentNullException.ThrowIfNull(picture);var lastPart = GetFileExtensionFromMimeType(picture.MimeType);var fileName = $"{picture.Id}_0.{lastPart}";@@ -646,8 +643,7 @@ namespace Grand.Business.Storage.Services/// <returns>Picture</returns>public virtual async Task<Picture> UpdatePicture(Picture picture){- if (picture == null)- throw new ArgumentNullException(nameof(picture));+ ArgumentNullException.ThrowIfNull(picture);await _pictureRepository.UpdateAsync(picture);@@ -669,8 +665,7 @@ namespace Grand.Business.Storage.Services/// <returns>Picture</returns>public virtual async Task UpdatePictureField<T>(Picture picture, Expression<Func<Picture, T>> expression, T value){- if (picture == null)- throw new ArgumentNullException(nameof(picture));+ ArgumentNullException.ThrowIfNull(picture);await _pictureRepository.UpdateField(picture.Id, expression, value);@@ -830,8 +825,7 @@ namespace Grand.Business.Storage.Servicesprivate byte[] ApplyResize(SKBitmap image, SKEncodedImageFormat format, int targetSize){- if (image == null)- throw new ArgumentNullException(nameof(image));+ ArgumentNullException.ThrowIfNull(image);if (targetSize <= 0){diff --git a/src/Business/Grand.Business.System/Services/Admin/AdminSiteMapService.cs b/src/Business/Grand.Business.System/Services/Admin/AdminSiteMapService.csindex 6b8ea0eda..eab288c9a 100644--- a/src/Business/Grand.Business.System/Services/Admin/AdminSiteMapService.cs+++ b/src/Business/Grand.Business.System/Services/Admin/AdminSiteMapService.cs@@ -38,8 +38,7 @@ namespace Grand.Business.System.Services.Adminpublic virtual async Task InsertSiteMap(AdminSiteMap entity){- if (entity == null)- throw new ArgumentNullException(nameof(entity));+ ArgumentNullException.ThrowIfNull(entity);await _adminSiteMapRepository.InsertAsync(entity);@@ -53,8 +52,7 @@ namespace Grand.Business.System.Services.Adminpublic virtual async Task UpdateSiteMap(AdminSiteMap entity){- if (entity == null)- throw new ArgumentNullException(nameof(entity));+ ArgumentNullException.ThrowIfNull(entity);await _adminSiteMapRepository.UpdateAsync(entity);@@ -67,8 +65,7 @@ namespace Grand.Business.System.Services.Adminpublic virtual async Task DeleteSiteMap(AdminSiteMap entity){- if (entity == null)- throw new ArgumentNullException(nameof(entity));+ ArgumentNullException.ThrowIfNull(entity);await _adminSiteMapRepository.DeleteAsync(entity);diff --git a/src/Business/Grand.Business.System/Services/BackgroundServices/ScheduleTasks/ScheduleTaskService.cs b/src/Business/Grand.Business.System/Services/BackgroundServices/ScheduleTasks/ScheduleTaskService.csindex a934b77e5..0f646be4e 100644--- a/src/Business/Grand.Business.System/Services/BackgroundServices/ScheduleTasks/ScheduleTaskService.cs+++ b/src/Business/Grand.Business.System/Services/BackgroundServices/ScheduleTasks/ScheduleTaskService.cs@@ -63,8 +63,7 @@ namespace Grand.Business.System.Services.BackgroundServices.ScheduleTasks/// <param name="task">Task</param>public virtual async Task<ScheduleTask> InsertTask(ScheduleTask task){- if (task == null)- throw new ArgumentNullException(nameof(task));+ ArgumentNullException.ThrowIfNull(task);return await _taskRepository.InsertAsync(task);}@@ -75,8 +74,7 @@ namespace Grand.Business.System.Services.BackgroundServices.ScheduleTasks/// <param name="task">Task</param>public virtual async Task UpdateTask(ScheduleTask task){- if (task == null)- throw new ArgumentNullException(nameof(task));+ ArgumentNullException.ThrowIfNull(task);await _taskRepository.UpdateAsync(task);}@@ -87,8 +85,7 @@ namespace Grand.Business.System.Services.BackgroundServices.ScheduleTasks/// <param name="task">Task</param>public virtual async Task DeleteTask(ScheduleTask task){- if (task == null)- throw new ArgumentNullException(nameof(task));+ ArgumentNullException.ThrowIfNull(task);await _taskRepository.DeleteAsync(task);}diff --git a/src/Core/Grand.Data/IRepository.cs b/src/Core/Grand.Data/IRepository.csindex 7e07051f2..0a69bef49 100644--- a/src/Core/Grand.Data/IRepository.cs+++ b/src/Core/Grand.Data/IRepository.cs@@ -29,6 +29,13 @@ namespace Grand.Data/// <returns>Entity</returns>Task<T> GetByIdAsync(string id);+ /// <summary>+ /// Get entity by identifier+ /// </summary>+ /// <param name="predicate"></param>+ /// <returns>Entity</returns>+ Task<T> GetOneAsync(Expression<Func<T, bool>> predicate);+/// <summary>/// Insert entity/// </summary>diff --git a/src/Core/Grand.Data/LiteDb/LiteDBRepository.cs b/src/Core/Grand.Data/LiteDb/LiteDBRepository.csindex e5c3a1372..76577dd79 100644--- a/src/Core/Grand.Data/LiteDb/LiteDBRepository.cs+++ b/src/Core/Grand.Data/LiteDb/LiteDBRepository.cs@@ -92,6 +92,16 @@ namespace Grand.Data.LiteDb{return await Task.FromResult(GetById(id));}++ /// <summary>+ /// Get async entity by expression+ /// </summary>+ /// <param name="predicate"></param>+ /// <returns>Entity</returns>+ public virtual Task<T> GetOneAsync(Expression<Func<T, bool>> predicate)+ {+ return Task.FromResult(_collection.Find(predicate).FirstOrDefault());+ }/// <summary>/// Insert entitydiff --git a/src/Core/Grand.Data/Mongo/MongoRepository.cs b/src/Core/Grand.Data/Mongo/MongoRepository.csindex a4e4594e2..3ab9a7bfe 100644--- a/src/Core/Grand.Data/Mongo/MongoRepository.cs+++ b/src/Core/Grand.Data/Mongo/MongoRepository.cs@@ -100,6 +100,16 @@ namespace Grand.Data.Mongoreturn _collection.Find(e => e.Id == id).FirstOrDefaultAsync();}+ /// <summary>+ /// Get async entity by expression+ /// </summary>+ /// <param name="predicate"></param>+ /// <returns>Entity</returns>+ public virtual Task<T> GetOneAsync(Expression<Func<T, bool>> predicate)+ {+ return _collection.Find(predicate).FirstOrDefaultAsync();+ }+/// <summary>/// Insert entity/// </summary>diff --git a/src/Core/Grand.Domain/Blogs/BlogExtensions.cs b/src/Core/Grand.Domain/Blogs/BlogExtensions.csindex c47f38161..2e65d1fd2 100644--- a/src/Core/Grand.Domain/Blogs/BlogExtensions.cs+++ b/src/Core/Grand.Domain/Blogs/BlogExtensions.cs@@ -4,8 +4,7 @@{public static string[] ParseTags(this BlogPost blogPost){- if (blogPost == null)- throw new ArgumentNullException(nameof(blogPost));+ ArgumentNullException.ThrowIfNull(blogPost);var parsedTags = new List<string>();if (!String.IsNullOrEmpty(blogPost.Tags))diff --git a/src/Core/Grand.Domain/Catalog/ProductExtensions.cs b/src/Core/Grand.Domain/Catalog/ProductExtensions.csindex 9e271a4fa..dfacdee67 100644--- a/src/Core/Grand.Domain/Catalog/ProductExtensions.cs+++ b/src/Core/Grand.Domain/Catalog/ProductExtensions.cs@@ -44,8 +44,7 @@ namespace Grand.Domain.Catalogpublic static bool ProductTagExists(this Product product,string productTagName){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);var result = product.ProductTags.FirstOrDefault(pt => pt == productTagName) != null;return result;@@ -58,8 +57,7 @@ namespace Grand.Domain.Catalog/// <returns>Result</returns>public static int[] ParseAllowedQuantities(this Product product){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);var result = new List<int>();if (!String.IsNullOrWhiteSpace(product.AllowedQuantities))@@ -91,8 +89,7 @@ namespace Grand.Domain.Catalogprivate static void GetSkuMpnGtin(this Product product, IList<CustomAttribute> attributes,out string sku, out string mpn, out string gtin){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);sku = null;mpn = null;@@ -127,8 +124,7 @@ namespace Grand.Domain.Catalogpublic static ProductAttributeCombination FindProductAttributeCombination(this Product product,IList<CustomAttribute> customAttributes, bool ignoreNonCombinableAttributes = true){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);var combinations = product.ProductAttributeCombinations;return combinations.FirstOrDefault(x =>@@ -221,9 +217,7 @@ namespace Grand.Domain.Catalog/// <returns>Attributes</returns>public static IList<CustomAttribute> AddProductAttribute(IList<CustomAttribute> customAttributes, ProductAttributeMapping productAttributeMapping, string value){- if (customAttributes == null)- customAttributes = new List<CustomAttribute>();-+ customAttributes ??= new List<CustomAttribute>();customAttributes.Add(new CustomAttribute { Key = productAttributeMapping.Id, Value = value });return customAttributes;@@ -325,11 +319,9 @@ namespace Grand.Domain.Catalog/// <returns>Result</returns>public static bool? IsConditionMet(this Product product, ProductAttributeMapping pam, IList<CustomAttribute> selectedAttributes){- if (pam == null)- throw new ArgumentNullException(nameof(pam));+ ArgumentNullException.ThrowIfNull(pam);- if (selectedAttributes == null)- selectedAttributes = new List<CustomAttribute>();+ selectedAttributes ??= new List<CustomAttribute>();var conditionAttribute = pam.ConditionAttribute;if (!conditionAttribute.Any())@@ -370,8 +362,7 @@ namespace Grand.Domain.Catalog/// <returns>Attribute combinations</returns>public static IList<IEnumerable<CustomAttribute>> GenerateAllCombinations(this Product product){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);var allProductAttributMappings = product.ProductAttributeMappings.Where(x => !x.IsNonCombinable()).ToList();@@ -398,8 +389,7 @@ namespace Grand.Domain.Catalog/// <returns>SKU</returns>public static string FormatSku(this Product product, IList<CustomAttribute> attributes = null){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);product.GetSkuMpnGtin(attributes, out var sku, out _, out _);@@ -414,8 +404,7 @@ namespace Grand.Domain.Catalog/// <returns>Collection part number</returns>public static string FormatMpn(this Product product, IList<CustomAttribute> attributes = null){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);product.GetSkuMpnGtin(attributes, out _, out var Mpn, out _);@@ -430,8 +419,7 @@ namespace Grand.Domain.Catalog/// <returns>GTIN</returns>public static string FormatGtin(this Product product, IList<CustomAttribute> attributes = null){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);product.GetSkuMpnGtin(attributes, out _, out _, out var gtin);@@ -445,8 +433,7 @@ namespace Grand.Domain.Catalog/// <returns>A list of required product IDs</returns>public static string[] ParseRequiredProductIds(this Product product){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);if (string.IsNullOrEmpty(product.RequiredProductIds))return Array.Empty<string>();@@ -481,8 +468,7 @@ namespace Grand.Domain.Catalog/// <returns>Result</returns>public static bool IsAvailable(this Product product, DateTime dateTime){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);if (product.AvailableStartDateTimeUtc.HasValue && product.AvailableStartDateTimeUtc.Value > dateTime){diff --git a/src/Core/Grand.Domain/Catalog/TierPriceExtensions.cs b/src/Core/Grand.Domain/Catalog/TierPriceExtensions.csindex 86e94c247..d718bc15a 100644--- a/src/Core/Grand.Domain/Catalog/TierPriceExtensions.cs+++ b/src/Core/Grand.Domain/Catalog/TierPriceExtensions.cs@@ -12,11 +12,9 @@ namespace Grand.Domain.Catalog/// <returns>Tier prices</returns>public static IEnumerable<TierPrice> FilterByDate(this IEnumerable<TierPrice> source, DateTime? date = null){- if (source == null)- throw new ArgumentNullException(nameof(source));+ ArgumentNullException.ThrowIfNull(source);- if (!date.HasValue)- date = DateTime.UtcNow;+ date ??= DateTime.UtcNow;return source.Where(tierPrice =>(!tierPrice.StartDateTimeUtc.HasValue || tierPrice.StartDateTimeUtc.Value < date.Value) &&@@ -30,8 +28,7 @@ namespace Grand.Domain.Catalog/// <returns>Tier prices</returns>public static IEnumerable<TierPrice> FilterByStore(this IEnumerable<TierPrice> source, string storeId){- if (source == null)- throw new ArgumentNullException(nameof(source));+ ArgumentNullException.ThrowIfNull(source);return source.Where(tierPrice => string.IsNullOrEmpty(tierPrice.StoreId) || tierPrice.StoreId == storeId);}@@ -44,8 +41,7 @@ namespace Grand.Domain.Catalog/// <returns>Tier prices</returns>public static IEnumerable<TierPrice> FilterForCustomer(this IEnumerable<TierPrice> source, Customer customer){- if (source == null)- throw new ArgumentNullException(nameof(source));+ ArgumentNullException.ThrowIfNull(source);if (customer == null)return source.Where(tierPrice => string.IsNullOrEmpty(tierPrice.CustomerGroupId));@@ -62,8 +58,7 @@ namespace Grand.Domain.Catalog/// <returns>Tier prices</returns>public static IEnumerable<TierPrice> FilterByCurrency(this IEnumerable<TierPrice> source, string currencyCode){- if (source == null)- throw new ArgumentNullException(nameof(source));+ ArgumentNullException.ThrowIfNull(source);return source.Where(tierPrice => string.IsNullOrEmpty(tierPrice.CurrencyCode) || tierPrice.CurrencyCode == currencyCode);}@@ -75,8 +70,7 @@ namespace Grand.Domain.Catalog/// <returns>Tier prices</returns>public static IEnumerable<TierPrice> RemoveDuplicatedQuantities(this IEnumerable<TierPrice> source){- if (source == null)- throw new ArgumentNullException(nameof(source));+ ArgumentNullException.ThrowIfNull(source);var result = source.OrderBy(x => x.Price).GroupBy(x => x.Quantity).Select(x => x.First()).OrderBy(x => x.Quantity).ToList();return result;}diff --git a/src/Core/Grand.Domain/Common/UserFieldExtensions.cs b/src/Core/Grand.Domain/Common/UserFieldExtensions.csindex cb0d39624..0e75acaf5 100644--- a/src/Core/Grand.Domain/Common/UserFieldExtensions.cs+++ b/src/Core/Grand.Domain/Common/UserFieldExtensions.cs@@ -14,8 +14,7 @@ namespace Grand.Domain.Common/// <returns>Attribute</returns>public static TPropType GetUserFieldFromEntity<TPropType>(this BaseEntity entity, string key, string storeId = ""){- if (entity == null)- throw new ArgumentNullException(nameof(entity));+ ArgumentNullException.ThrowIfNull(entity);var props = entity.UserFields;if (props == null)diff --git a/src/Core/Grand.Domain/Customers/CustomerExtensions.cs b/src/Core/Grand.Domain/Customers/CustomerExtensions.csindex e0fd6287d..dec44651f 100644--- a/src/Core/Grand.Domain/Customers/CustomerExtensions.cs+++ b/src/Core/Grand.Domain/Customers/CustomerExtensions.cs@@ -13,8 +13,7 @@ namespace Grand.Domain.Customers/// <returns>Result</returns>public static bool IsSystemAccount(this Customer customer){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);return customer.IsSystemAccount && !string.IsNullOrEmpty(customer.SystemName);}@@ -27,8 +26,7 @@ namespace Grand.Domain.Customers/// <returns>Result</returns>public static bool IsSearchEngineAccount(this Customer customer){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);if (!customer.IsSystemAccount || string.IsNullOrEmpty(customer.SystemName))return false;@@ -65,20 +63,19 @@ namespace Grand.Domain.Customers/// <returns>Customer full name</returns>public static string GetFullName(this Customer customer){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);var firstName = customer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.FirstName);var lastName = customer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.LastName);var fullName = "";- if (!String.IsNullOrWhiteSpace(firstName) && !String.IsNullOrWhiteSpace(lastName))+ if (!string.IsNullOrWhiteSpace(firstName) && !string.IsNullOrWhiteSpace(lastName))fullName = $"{firstName} {lastName}";else{- if (!String.IsNullOrWhiteSpace(firstName))+ if (!string.IsNullOrWhiteSpace(firstName))fullName = firstName;- if (!String.IsNullOrWhiteSpace(lastName))+ if (!string.IsNullOrWhiteSpace(lastName))fullName = lastName;}return fullName;@@ -128,8 +125,7 @@ namespace Grand.Domain.Customers/// <returns>Coupon codes</returns>public static string[] ParseAppliedCouponCodes(this Customer customer, string key){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);var existingCouponCodes = customer.GetUserFieldFromEntity<string>(key);@@ -150,8 +146,7 @@ namespace Grand.Domain.Customers/// <returns>New coupon codes document</returns>public static string ApplyCouponCode(this Customer customer, string key, string couponCode){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);var existingCouponCodes = customer.GetUserFieldFromEntity<string>(key);return string.IsNullOrEmpty(existingCouponCodes) ? couponCode : string.Join(CouponSeparator, existingCouponCodes.Split(CouponSeparator).Append(couponCode).Distinct());@@ -166,8 +161,7 @@ namespace Grand.Domain.Customers/// <returns>New coupon codes document</returns>public static string ApplyCouponCode(this Customer customer, string key, string[] couponCodes){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);var existingCouponCodes = customer.GetUserFieldFromEntity<string>(key);if (string.IsNullOrEmpty(existingCouponCodes))@@ -189,16 +183,10 @@ namespace Grand.Domain.Customers/// <returns>New coupon codes document</returns>public static string RemoveCouponCode(this Customer customer, string key, string couponCode){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);var existingCouponCodes = customer.GetUserFieldFromEntity<string>(key);- if (string.IsNullOrEmpty(existingCouponCodes))- {- return "";- }-- return string.Join(CouponSeparator, existingCouponCodes.Split(CouponSeparator).Except(new List<string> { couponCode }).Distinct());+ return string.IsNullOrEmpty(existingCouponCodes) ? "" : string.Join(CouponSeparator, existingCouponCodes.Split(CouponSeparator).Except(new List<string> { couponCode }).Distinct());}/// <summary>@@ -209,17 +197,10 @@ namespace Grand.Domain.Customers/// <returns>Result</returns>public static bool IsPasswordRecoveryTokenValid(this Customer customer, string token){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);var cPrt = customer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.PasswordRecoveryToken);- if (String.IsNullOrEmpty(cPrt))- return false;-- if (!cPrt.Equals(token, StringComparison.OrdinalIgnoreCase))- return false;-- return true;+ return !string.IsNullOrEmpty(cPrt) && cPrt.Equals(token, StringComparison.OrdinalIgnoreCase);}/// <summary>@@ -230,11 +211,9 @@ namespace Grand.Domain.Customers/// <returns>Result</returns>public static bool IsPasswordRecoveryLinkExpired(this Customer customer, CustomerSettings customerSettings){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);- if (customerSettings == null)- throw new ArgumentNullException(nameof(customerSettings));+ ArgumentNullException.ThrowIfNull(customerSettings);if (customerSettings.PasswordRecoveryLinkDaysValid == 0)return false;@@ -244,10 +223,7 @@ namespace Grand.Domain.Customersreturn false;var daysPassed = (DateTime.UtcNow - geneatedDate.Value).TotalDays;- if (daysPassed > customerSettings.PasswordRecoveryLinkDaysValid)- return true;-- return false;+ return daysPassed > customerSettings.PasswordRecoveryLinkDaysValid;}/// <summary>@@ -257,8 +233,7 @@ namespace Grand.Domain.Customers/// <returns>Customer group identifiers</returns>public static string[] GetCustomerGroupIds(this Customer customer){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);return customer.Groups.ToArray();}diff --git a/src/Core/Grand.Domain/Orders/OrderExtensions.cs b/src/Core/Grand.Domain/Orders/OrderExtensions.csindex 1730d1782..57189cb62 100644--- a/src/Core/Grand.Domain/Orders/OrderExtensions.cs+++ b/src/Core/Grand.Domain/Orders/OrderExtensions.cs@@ -94,8 +94,7 @@ namespace Grand.Domain.Orders/// <returns>A value indicating whether an order has items to be added to a shipment</returns>public static bool HasItemsToAddToShipment(this Order order){- if (order == null)- throw new ArgumentNullException(nameof(order));+ ArgumentNullException.ThrowIfNull(order);foreach (var orderItem in order.OrderItems){@@ -120,8 +119,7 @@ namespace Grand.Domain.Orders/// <returns>Result</returns>public static bool OrderTagExists(this Order order, OrderTag orderTag){- if (order == null)- throw new ArgumentNullException(nameof(order));+ ArgumentNullException.ThrowIfNull(order);var result = order.OrderTags.FirstOrDefault(t => t == orderTag.Id) != null;return result;diff --git a/src/Core/Grand.Domain/PagedList.cs b/src/Core/Grand.Domain/PagedList.csindex c5a14efa2..36ea6d6d0 100644--- a/src/Core/Grand.Domain/PagedList.cs+++ b/src/Core/Grand.Domain/PagedList.cs@@ -10,8 +10,7 @@private void Initialize(IEnumerable<T> source, int pageIndex, int pageSize, int? totalCount = null){- if (source == null)- throw new ArgumentNullException(nameof(source));+ ArgumentNullException.ThrowIfNull(source);if (pageSize <= 0)pageSize = 1;@@ -46,8 +45,7 @@private Task InitializeAsync(IQueryable<T> source, int pageIndex, int pageSize, int? totalCount = null){- if (source == null)- throw new ArgumentNullException(nameof(source));+ ArgumentNullException.ThrowIfNull(source);if (pageSize <= 0)pageSize = 1;diff --git a/src/Core/Grand.Domain/Stores/StoreExtensions.cs b/src/Core/Grand.Domain/Stores/StoreExtensions.csindex c22ca2bb1..32a8f8487 100644--- a/src/Core/Grand.Domain/Stores/StoreExtensions.cs+++ b/src/Core/Grand.Domain/Stores/StoreExtensions.cs@@ -10,8 +10,7 @@/// <returns>true - contains, false - no</returns>public static bool ContainsHostValue(this Store store, string host){- if (store == null)- throw new ArgumentNullException(nameof(store));+ ArgumentNullException.ThrowIfNull(store);if (string.IsNullOrEmpty(host))return false;@@ -28,13 +27,8 @@/// <returns>DomainHost</returns>public static DomainHost HostValue(this Store store, string host){- if (store == null)- throw new ArgumentNullException(nameof(store));-- if (string.IsNullOrEmpty(host))- return null;-- return store.Domains.FirstOrDefault(x => x.HostName.Equals(host, StringComparison.OrdinalIgnoreCase));+ ArgumentNullException.ThrowIfNull(store);+ return string.IsNullOrEmpty(host) ? null : store.Domains.FirstOrDefault(x => x.HostName.Equals(host, StringComparison.OrdinalIgnoreCase));}}}diff --git a/src/Core/Grand.Infrastructure/Roslyn/RoslynCompiler.cs b/src/Core/Grand.Infrastructure/Roslyn/RoslynCompiler.csindex 22076ee0f..04914ecca 100644--- a/src/Core/Grand.Infrastructure/Roslyn/RoslynCompiler.cs+++ b/src/Core/Grand.Infrastructure/Roslyn/RoslynCompiler.cs@@ -29,15 +29,11 @@ namespace Grand.Infrastructure.Roslynpublic static void Load(ApplicationPartManager applicationPartManager, IConfiguration configuration){+ ArgumentNullException.ThrowIfNull(applicationPartManager);+var config = new ExtensionsConfig();configuration.GetSection("Extensions").Bind(config);- if (applicationPartManager == null)- throw new ArgumentNullException(nameof(applicationPartManager));-- if (config == null)- throw new ArgumentNullException(nameof(config));-if (!config.UseRoslynScripts)return;diff --git a/src/Core/Grand.Infrastructure/StartupBase.cs b/src/Core/Grand.Infrastructure/StartupBase.csindex 5a501d2f9..ddcc41ad4 100644--- a/src/Core/Grand.Infrastructure/StartupBase.cs+++ b/src/Core/Grand.Infrastructure/StartupBase.cs@@ -106,11 +106,8 @@ namespace Grand.Infrastructureprivate static T StartupConfig<T>(this IServiceCollection services, IConfiguration configuration)where T : class, new(){- if (services == null)- throw new ArgumentNullException(nameof(services));-- if (configuration == null)- throw new ArgumentNullException(nameof(configuration));+ ArgumentNullException.ThrowIfNull(services);+ ArgumentNullException.ThrowIfNull(configuration);var config = new T();configuration.Bind(config);diff --git a/src/Plugins/DiscountRules.Standard/Providers/CustomerGroupDiscountRule.cs b/src/Plugins/DiscountRules.Standard/Providers/CustomerGroupDiscountRule.csindex bac6007c1..0fd5bebcf 100644--- a/src/Plugins/DiscountRules.Standard/Providers/CustomerGroupDiscountRule.cs+++ b/src/Plugins/DiscountRules.Standard/Providers/CustomerGroupDiscountRule.cs@@ -12,8 +12,7 @@ namespace DiscountRules.Standard.Providers/// <returns>true - requirement is met; otherwise, false</returns>public async Task<DiscountRuleValidationResult> CheckRequirement(DiscountRuleValidationRequest request){- if (request == null)- throw new ArgumentNullException(nameof(request));+ ArgumentNullException.ThrowIfNull(request);//invalid by defaultvar result = new DiscountRuleValidationResult();diff --git a/src/Plugins/DiscountRules.Standard/Providers/HadSpentAmountDiscountRule.cs b/src/Plugins/DiscountRules.Standard/Providers/HadSpentAmountDiscountRule.csindex b8aaa147f..0f85cd95e 100644--- a/src/Plugins/DiscountRules.Standard/Providers/HadSpentAmountDiscountRule.cs+++ b/src/Plugins/DiscountRules.Standard/Providers/HadSpentAmountDiscountRule.cs@@ -24,8 +24,7 @@ namespace DiscountRules.Standard.Providers/// <returns>true - requirement is met; otherwise, false</returns>public async Task<DiscountRuleValidationResult> CheckRequirement(DiscountRuleValidationRequest request){- if (request == null)- throw new ArgumentNullException(nameof(request));+ ArgumentNullException.ThrowIfNull(request);//invalid by defaultvar result = new DiscountRuleValidationResult();diff --git a/src/Plugins/DiscountRules.Standard/Providers/HasAllProductsDiscountRule.cs b/src/Plugins/DiscountRules.Standard/Providers/HasAllProductsDiscountRule.csindex 0a78bd28a..9f6883fbd 100644--- a/src/Plugins/DiscountRules.Standard/Providers/HasAllProductsDiscountRule.cs+++ b/src/Plugins/DiscountRules.Standard/Providers/HasAllProductsDiscountRule.cs@@ -20,8 +20,7 @@ namespace DiscountRules.Standard.Providers/// <returns>true - requirement is met; otherwise, false</returns>public async Task<DiscountRuleValidationResult> CheckRequirement(DiscountRuleValidationRequest request){- if (request == null)- throw new ArgumentNullException(nameof(request));+ ArgumentNullException.ThrowIfNull(request);//invalid by defaultvar result = new DiscountRuleValidationResult();diff --git a/src/Plugins/DiscountRules.Standard/Providers/HasOneProductDiscountRule.cs b/src/Plugins/DiscountRules.Standard/Providers/HasOneProductDiscountRule.csindex af724d510..6e6dd1019 100644--- a/src/Plugins/DiscountRules.Standard/Providers/HasOneProductDiscountRule.cs+++ b/src/Plugins/DiscountRules.Standard/Providers/HasOneProductDiscountRule.cs@@ -20,8 +20,7 @@ namespace DiscountRules.Standard.Providers/// <returns>true - requirement is met; otherwise, false</returns>public async Task<DiscountRuleValidationResult> CheckRequirement(DiscountRuleValidationRequest request){- if (request == null)- throw new ArgumentNullException(nameof(request));+ ArgumentNullException.ThrowIfNull(request);//invalid by defaultvar result = new DiscountRuleValidationResult();diff --git a/src/Plugins/DiscountRules.Standard/Providers/ShoppingCartDiscountRule.cs b/src/Plugins/DiscountRules.Standard/Providers/ShoppingCartDiscountRule.csindex ff19ec0a1..0de79ba08 100644--- a/src/Plugins/DiscountRules.Standard/Providers/ShoppingCartDiscountRule.cs+++ b/src/Plugins/DiscountRules.Standard/Providers/ShoppingCartDiscountRule.cs@@ -35,8 +35,7 @@ namespace DiscountRules.Standard.Providers/// <returns>true - requirement is met; otherwise, false</returns>public async Task<DiscountRuleValidationResult> CheckRequirement(DiscountRuleValidationRequest request){- if (request == null)- throw new ArgumentNullException(nameof(request));+ ArgumentNullException.ThrowIfNull(request);var result = new DiscountRuleValidationResult();diff --git a/src/Plugins/Payments.BrainTree/BrainTreePaymentProvider.cs b/src/Plugins/Payments.BrainTree/BrainTreePaymentProvider.csindex 1c3c38d6b..6d894cd1a 100644--- a/src/Plugins/Payments.BrainTree/BrainTreePaymentProvider.cs+++ b/src/Plugins/Payments.BrainTree/BrainTreePaymentProvider.cs@@ -295,8 +295,7 @@ namespace Payments.BrainTree/// <returns>Result</returns>public async Task<bool> CanRePostRedirectPayment(PaymentTransaction paymentTransaction){- if (paymentTransaction == null)- throw new ArgumentNullException(nameof(paymentTransaction));+ ArgumentNullException.ThrowIfNull(paymentTransaction);//it's not a redirection payment method. So we always return falsereturn await Task.FromResult(false);diff --git a/src/Plugins/Payments.CashOnDelivery/CashOnDeliveryPaymentProvider.cs b/src/Plugins/Payments.CashOnDelivery/CashOnDeliveryPaymentProvider.csindex 87c4c493e..38cd4730c 100644--- a/src/Plugins/Payments.CashOnDelivery/CashOnDeliveryPaymentProvider.cs+++ b/src/Plugins/Payments.CashOnDelivery/CashOnDeliveryPaymentProvider.cs@@ -132,8 +132,7 @@ namespace Payments.CashOnDeliverypublic async Task<bool> CanRePostRedirectPayment(PaymentTransaction paymentTransaction){- if (paymentTransaction == null)- throw new ArgumentNullException(nameof(paymentTransaction));+ ArgumentNullException.ThrowIfNull(paymentTransaction);//it's not a redirection payment method. So we always return falsereturn await Task.FromResult(false);diff --git a/src/Plugins/Shipping.ByWeight/ByWeightShippingProvider.cs b/src/Plugins/Shipping.ByWeight/ByWeightShippingProvider.csindex 72fe6f76d..c20d0ac2a 100644--- a/src/Plugins/Shipping.ByWeight/ByWeightShippingProvider.cs+++ b/src/Plugins/Shipping.ByWeight/ByWeightShippingProvider.cs@@ -106,8 +106,7 @@ namespace Shipping.ByWeight/// <returns>Shopping cart item weight</returns>private async Task<double> GetShoppingCartItemWeight(ShoppingCartItem shoppingCartItem){- if (shoppingCartItem == null)- throw new ArgumentNullException(nameof(shoppingCartItem));+ ArgumentNullException.ThrowIfNull(shoppingCartItem);var product = await _productService.GetProductById(shoppingCartItem.ProductId);if (product == null)@@ -152,8 +151,7 @@ namespace Shipping.ByWeight/// <returns>Total weight</returns>private async Task<double> GetTotalWeight(GetShippingOptionRequest request, bool includeCheckoutAttributes = true){- if (request == null)- throw new ArgumentNullException(nameof(request));+ ArgumentNullException.ThrowIfNull(request);Customer customer = request.Customer;@@ -185,8 +183,7 @@ namespace Shipping.ByWeight/// <returns>Represents a response of getting shipping rate options</returns>public async Task<GetShippingOptionResponse> GetShippingOptions(GetShippingOptionRequest getShippingOptionRequest){- if (getShippingOptionRequest == null)- throw new ArgumentNullException(nameof(getShippingOptionRequest));+ ArgumentNullException.ThrowIfNull(getShippingOptionRequest);var response = new GetShippingOptionResponse();diff --git a/src/Plugins/Shipping.ByWeight/Services/ShippingByWeightService.cs b/src/Plugins/Shipping.ByWeight/Services/ShippingByWeightService.csindex ea6328025..a847ade3e 100644--- a/src/Plugins/Shipping.ByWeight/Services/ShippingByWeightService.cs+++ b/src/Plugins/Shipping.ByWeight/Services/ShippingByWeightService.cs@@ -34,8 +34,7 @@ namespace Shipping.ByWeight.Servicespublic virtual async Task DeleteShippingByWeightRecord(ShippingByWeightRecord shippingByWeightRecord){- if (shippingByWeightRecord == null)- throw new ArgumentNullException(nameof(shippingByWeightRecord));+ ArgumentNullException.ThrowIfNull(shippingByWeightRecord);await _sbwRepository.DeleteAsync(shippingByWeightRecord);@@ -101,8 +100,7 @@ namespace Shipping.ByWeight.Servicespublic virtual async Task InsertShippingByWeightRecord(ShippingByWeightRecord shippingByWeightRecord){- if (shippingByWeightRecord == null)- throw new ArgumentNullException(nameof(shippingByWeightRecord));+ ArgumentNullException.ThrowIfNull(shippingByWeightRecord);await _sbwRepository.InsertAsync(shippingByWeightRecord);@@ -111,8 +109,7 @@ namespace Shipping.ByWeight.Servicespublic virtual async Task UpdateShippingByWeightRecord(ShippingByWeightRecord shippingByWeightRecord){- if (shippingByWeightRecord == null)- throw new ArgumentNullException(nameof(shippingByWeightRecord));+ ArgumentNullException.ThrowIfNull(shippingByWeightRecord);await _sbwRepository.UpdateAsync(shippingByWeightRecord);diff --git a/src/Plugins/Shipping.FixedRateShipping/FixedRateShippingProvider.cs b/src/Plugins/Shipping.FixedRateShipping/FixedRateShippingProvider.csindex e8fc51e3d..d1e3d2f68 100644--- a/src/Plugins/Shipping.FixedRateShipping/FixedRateShippingProvider.cs+++ b/src/Plugins/Shipping.FixedRateShipping/FixedRateShippingProvider.cs@@ -58,8 +58,7 @@ namespace Shipping.FixedRateShipping/// <returns>Represents a response of getting shipping rate options</returns>public async Task<GetShippingOptionResponse> GetShippingOptions(GetShippingOptionRequest getShippingOptionRequest){- if (getShippingOptionRequest == null)- throw new ArgumentNullException(nameof(getShippingOptionRequest));+ ArgumentNullException.ThrowIfNull(getShippingOptionRequest);var response = new GetShippingOptionResponse();@@ -92,8 +91,7 @@ namespace Shipping.FixedRateShipping/// <returns>Fixed shipping rate; or null in case there's no fixed shipping rate</returns>public async Task<double?> GetFixedRate(GetShippingOptionRequest getShippingOptionRequest){- if (getShippingOptionRequest == null)- throw new ArgumentNullException(nameof(getShippingOptionRequest));+ ArgumentNullException.ThrowIfNull(getShippingOptionRequest);var restrictByCountryId = getShippingOptionRequest.ShippingAddress != null && !string.IsNullOrEmpty(getShippingOptionRequest.ShippingAddress.CountryId) ? getShippingOptionRequest.ShippingAddress.CountryId : "";var shippingMethods = await _shippingMethodService.GetAllShippingMethods(restrictByCountryId);diff --git a/src/Plugins/Shipping.ShippingPoint/Services/ShippingPointService.cs b/src/Plugins/Shipping.ShippingPoint/Services/ShippingPointService.csindex 44c69f0a2..e152ac84f 100644--- a/src/Plugins/Shipping.ShippingPoint/Services/ShippingPointService.cs+++ b/src/Plugins/Shipping.ShippingPoint/Services/ShippingPointService.cs@@ -85,8 +85,7 @@ namespace Shipping.ShippingPoint.Services/// <param name="pickupPoint">Pickup point</param>public virtual async Task InsertStoreShippingPoint(ShippingPoints pickupPoint){- if (pickupPoint == null)- throw new ArgumentNullException(nameof(pickupPoint));+ ArgumentNullException.ThrowIfNull(pickupPoint);await _shippingPointRepository.InsertAsync(pickupPoint);await _cacheBase.RemoveByPrefix(PICKUP_POINT_PATTERN_KEY);@@ -98,8 +97,7 @@ namespace Shipping.ShippingPoint.Services/// <param name="pickupPoint">Pickup point</param>public virtual async Task UpdateStoreShippingPoint(ShippingPoints pickupPoint){- if (pickupPoint == null)- throw new ArgumentNullException(nameof(pickupPoint));+ ArgumentNullException.ThrowIfNull(pickupPoint);await _shippingPointRepository.UpdateAsync(pickupPoint);await _cacheBase.RemoveByPrefix(PICKUP_POINT_PATTERN_KEY);@@ -111,8 +109,7 @@ namespace Shipping.ShippingPoint.Services/// <param name="pickupPoint">Pickup point</param>public virtual async Task DeleteStoreShippingPoint(ShippingPoints pickupPoint){- if (pickupPoint == null)- throw new ArgumentNullException(nameof(pickupPoint));+ ArgumentNullException.ThrowIfNull(pickupPoint);await _shippingPointRepository.DeleteAsync(pickupPoint);await _cacheBase.RemoveByPrefix(PICKUP_POINT_PATTERN_KEY);diff --git a/src/Plugins/Shipping.ShippingPoint/ShippingPointRateProvider.cs b/src/Plugins/Shipping.ShippingPoint/ShippingPointRateProvider.csindex 1c791fb03..c1b35613b 100644--- a/src/Plugins/Shipping.ShippingPoint/ShippingPointRateProvider.cs+++ b/src/Plugins/Shipping.ShippingPoint/ShippingPointRateProvider.cs@@ -58,8 +58,7 @@ namespace Shipping.ShippingPoint/// <returns>Represents a response of getting shipping rate options</returns>public async Task<GetShippingOptionResponse> GetShippingOptions(GetShippingOptionRequest getShippingOptionRequest){- if (getShippingOptionRequest == null)- throw new ArgumentNullException(nameof(getShippingOptionRequest));+ ArgumentNullException.ThrowIfNull(getShippingOptionRequest);var response = new GetShippingOptionResponse();diff --git a/src/Plugins/Tax.CountryStateZip/Infrastructure/Cache/ModelCacheEventConsumer.cs b/src/Plugins/Tax.CountryStateZip/Infrastructure/Cache/ModelCacheEventConsumer.csindex c5aaf19c9..a9be130ef 100644--- a/src/Plugins/Tax.CountryStateZip/Infrastructure/Cache/ModelCacheEventConsumer.cs+++ b/src/Plugins/Tax.CountryStateZip/Infrastructure/Cache/ModelCacheEventConsumer.cs@@ -1,7 +1,6 @@using Grand.Infrastructure.Caching;using Grand.Infrastructure.Events;using MediatR;-using Microsoft.Extensions.DependencyInjection;using Tax.CountryStateZip.Domain;namespace Tax.CountryStateZip.Infrastructure.Cachediff --git a/src/Plugins/Tax.CountryStateZip/Services/TaxRateService.cs b/src/Plugins/Tax.CountryStateZip/Services/TaxRateService.csindex 8311011a5..7bcab898c 100644--- a/src/Plugins/Tax.CountryStateZip/Services/TaxRateService.cs+++ b/src/Plugins/Tax.CountryStateZip/Services/TaxRateService.cs@@ -52,8 +52,7 @@ namespace Tax.CountryStateZip.Services/// <param name="taxRate">Tax rate</param>public virtual async Task DeleteTaxRate(TaxRate taxRate){- if (taxRate == null)- throw new ArgumentNullException(nameof(taxRate));+ ArgumentNullException.ThrowIfNull(taxRate);await _taxRateRepository.DeleteAsync(taxRate);@@ -95,8 +94,7 @@ namespace Tax.CountryStateZip.Services/// <param name="taxRate">Tax rate</param>public virtual async Task InsertTaxRate(TaxRate taxRate){- if (taxRate == null)- throw new ArgumentNullException(nameof(taxRate));+ ArgumentNullException.ThrowIfNull(taxRate);await _taxRateRepository.InsertAsync(taxRate);@@ -112,8 +110,7 @@ namespace Tax.CountryStateZip.Services/// <param name="taxRate">Tax rate</param>public virtual async Task UpdateTaxRate(TaxRate taxRate){- if (taxRate == null)- throw new ArgumentNullException(nameof(taxRate));+ ArgumentNullException.ThrowIfNull(taxRate);await _taxRateRepository.UpdateAsync(taxRate);diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/AddressAdd.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/AddressAdd.cshtmlindex 28e65128e..b5e1cf3a1 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/AddressAdd.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/AddressAdd.cshtml@@ -1,5 +1,4 @@@model CustomerAddressEditModel-@using Grand.Web.Models.Customer;@inject IPageHeadBuilder pagebuilder@{Layout = "_TwoColumns";diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/AddressEdit.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/AddressEdit.cshtmlindex 700e04bad..d926e202f 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/AddressEdit.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/AddressEdit.cshtml@@ -1,5 +1,4 @@@model CustomerAddressEditModel-@using Grand.Web.Models.Customer;@inject IPageHeadBuilder pagebuilder@{Layout = "_TwoColumns";diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/Addresses.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/Addresses.cshtmlindex c177c962b..6ad92a4bb 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/Addresses.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/Addresses.cshtml@@ -1,5 +1,4 @@@model CustomerAddressListModel-@using Grand.Web.Models.Customer;@inject IPageHeadBuilder pagebuilder@{Layout = "_TwoColumns";diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/Auctions.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/Auctions.cshtmlindex 02d186294..fd5d3c7e3 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/Auctions.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/Auctions.cshtml@@ -1,5 +1,4 @@@model CustomerAuctionsModel-@using Grand.Web.Models.Customer;@inject IPageHeadBuilder pagebuilder@{Layout = "_TwoColumns";diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/ChangePassword.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/ChangePassword.cshtmlindex bcbfb0a10..87248a7d2 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/ChangePassword.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/ChangePassword.cshtml@@ -1,5 +1,4 @@@model ChangePasswordModel-@using Grand.Web.Models.Customer;@inject IPageHeadBuilder pagebuilder@{Layout = "_TwoColumns";diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/Courses.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/Courses.cshtmlindex cb21246da..9ea461fd6 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/Courses.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/Courses.cshtml@@ -1,5 +1,4 @@@model CoursesModel-@using Grand.Web.Models.Customer;@inject IPageHeadBuilder pagebuilder@{Layout = "_TwoColumns";diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/DeleteAccount.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/DeleteAccount.cshtmlindex c273944fb..c80546d43 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/DeleteAccount.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/DeleteAccount.cshtml@@ -1,5 +1,4 @@@model DeleteAccountModel-@using Grand.Web.Models.Customer;@inject IPageHeadBuilder pagebuilder@{Layout = "_TwoColumns";diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/Documents.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/Documents.cshtmlindex 5743175e6..70afa183f 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/Documents.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/Documents.cshtml@@ -1,5 +1,4 @@@model DocumentsModel-@using Grand.Web.Models.Customer;@inject IPageHeadBuilder pagebuilder@{Layout = "_TwoColumns";diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/DownloadableProducts.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/DownloadableProducts.cshtmlindex 6bdad2c96..9dc54690a 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/DownloadableProducts.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/DownloadableProducts.cshtml@@ -1,5 +1,4 @@@model CustomerDownloadableProductsModel-@using Grand.Web.Models.Customer;@inject IPageHeadBuilder pagebuilder@{Layout = "_TwoColumns";diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/Notes.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/Notes.cshtmlindex 19c61a16f..f416b1cbf 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/Notes.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/Notes.cshtml@@ -1,5 +1,4 @@@model CustomerNotesModel-@using Grand.Web.Models.Customer;@inject IPageHeadBuilder pagebuilder@{Layout = "_TwoColumns";diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/PasswordRecovery.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/PasswordRecovery.cshtmlindex 82ffbd213..0719ea65a 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/PasswordRecovery.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/PasswordRecovery.cshtml@@ -1,5 +1,4 @@@model PasswordRecoveryModel-@using Grand.Web.Models.Customer;@inject IPageHeadBuilder pagebuilder@{Layout = "_SingleColumn";diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/Reviews.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/Reviews.cshtmlindex 0274bc81e..687b11b4d 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/Reviews.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/Reviews.cshtml@@ -1,5 +1,4 @@@model CustomerProductReviewsModel-@using Grand.Web.Models.Customer;@inject IPageHeadBuilder pagebuilder@{Layout = "_TwoColumns";diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccountAdd.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccountAdd.cshtmlindex f88c3934b..635148af5 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccountAdd.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccountAdd.cshtml@@ -1,5 +1,4 @@@model SubAccountCreateModel-@using Grand.Web.Models.Customer;@inject IPageHeadBuilder pagebuilder@{Layout = "_TwoColumns";diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccountEdit.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccountEdit.cshtmlindex c3cc10bf9..cb464f99c 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccountEdit.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccountEdit.cshtml@@ -1,5 +1,4 @@@model SubAccountEditModel-@using Grand.Web.Models.Customer;@inject IPageHeadBuilder pagebuilder@{Layout = "_TwoColumns";diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccounts.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccounts.cshtmlindex 2d201fbc9..080d13137 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccounts.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccounts.cshtml@@ -1,6 +1,5 @@@model IList<SubAccountSimpleModel>- @using Grand.Web.Models.Customer;- @inject IPageHeadBuilder pagebuilder+@inject IPageHeadBuilder pagebuilder@{Layout = "_TwoColumns";diff --git a/src/Plugins/Theme.Modern/Views/Modern/Blog/BlogPost.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Blog/BlogPost.cshtmlindex 68cc34273..91d183f5a 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Blog/BlogPost.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Blog/BlogPost.cshtml@@ -1,5 +1,4 @@@model BlogPostModel-@using Grand.Web.Models.Blogs;@inject IWorkContext workContext@inject IPageHeadBuilder pagebuilder@{diff --git a/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogCategories/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogCategories/Default.cshtmlindex 8158a8f35..7147f1af0 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogCategories/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogCategories/Default.cshtml@@ -1,5 +1,4 @@@model IList<BlogPostCategoryModel>-@using Grand.Web.Models.Blogs@if (Model.Any()){<section id="block-blog-archive" class="block block-blog-archive">diff --git a/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogMonths/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogMonths/Default.cshtmlindex 8c1f23956..418ec2849 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogMonths/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogMonths/Default.cshtml@@ -1,5 +1,4 @@@model IList<BlogPostYearModel>-@using Grand.Web.Models.Blogs;@if (Model.Any()){<section id="block-blog-archive" class="block block-blog-archive">diff --git a/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogTags/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogTags/Default.cshtmlindex a8b33a2ce..3d950f231 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogTags/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogTags/Default.cshtml@@ -1,5 +1,4 @@@model BlogPostTagListModel-@using Grand.Web.Models.Blogs@if (Model.Tags.Any()){<div id="block-popular-blogtags" class="block block-popular-blogtags">diff --git a/src/Plugins/Theme.Modern/Views/Modern/Blog/List.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Blog/List.cshtmlindex 692b76da7..55926ae08 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Blog/List.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Blog/List.cshtml@@ -1,5 +1,4 @@@model BlogPostListModel-@using Grand.Web.Models.Blogs;@inject IWorkContext workContext@inject IPageHeadBuilder pagebuilder@{diff --git a/src/Plugins/Theme.Modern/Views/Modern/MerchandiseReturn/CustomerMerchandiseReturns.cshtml b/src/Plugins/Theme.Modern/Views/Modern/MerchandiseReturn/CustomerMerchandiseReturns.cshtmlindex 6b2bfcaea..3e0ca4357 100644--- a/src/Plugins/Theme.Modern/Views/Modern/MerchandiseReturn/CustomerMerchandiseReturns.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/MerchandiseReturn/CustomerMerchandiseReturns.cshtml@@ -1,6 +1,4 @@@model CustomerMerchandiseReturnsModel-@using Grand.Web.Models.Customer-@using Grand.Web.Models.Orders@using System.Globalization@inject IPageHeadBuilder pagebuilder@{diff --git a/src/Plugins/Theme.Modern/Views/Modern/Product/CompareProducts.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Product/CompareProducts.cshtmlindex 7c34811e8..c7ff6a3ad 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Product/CompareProducts.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Product/CompareProducts.cshtml@@ -6,7 +6,6 @@//titlepagebuilder.AddTitleParts(Loc["Title.CompareProducts"]);}-@using Grand.Web.Models.Catalog;@{var specificationAttributes = new List<ProductSpecificationModel>();foreach (var product in Model.Products)diff --git a/src/Plugins/Theme.Modern/Views/Modern/Product/NewProducts.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Product/NewProducts.cshtmlindex 593b76121..a2ced5ba1 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Product/NewProducts.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Product/NewProducts.cshtml@@ -6,7 +6,6 @@//titlepagebuilder.AddTitleParts(Loc["Title.NewProducts"]);}-@using Grand.Web.Models.Catalog;<div class="page recently-added-products-page col-12 px-0"><h1 class="h2 generalTitle text-center"><div>@Loc["Products.NewProducts"]</div></h1>@if (Model.Any())diff --git a/src/Plugins/Theme.Modern/Views/Modern/Product/ProductLayout.Simple.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Product/ProductLayout.Simple.cshtmlindex 941253522..e994cf788 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Product/ProductLayout.Simple.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Product/ProductLayout.Simple.cshtml@@ -1,5 +1,4 @@@model ProductDetailsModel-@using Microsoft.AspNetCore.Http.Extensions@inject SeoSettings seoSettings@inject IWorkContext workContext@inject IPageHeadBuilder pagebuilderdiff --git a/src/Plugins/Widgets.Slider/Services/SliderService.cs b/src/Plugins/Widgets.Slider/Services/SliderService.csindex da50ddc15..9d1d46ce5 100644--- a/src/Plugins/Widgets.Slider/Services/SliderService.cs+++ b/src/Plugins/Widgets.Slider/Services/SliderService.cs@@ -44,8 +44,7 @@ namespace Widgets.Slider.Services/// <param name="slider">Slider</param>public virtual async Task DeleteSlider(PictureSlider slider){- if (slider == null)- throw new ArgumentNullException(nameof(slider));+ ArgumentNullException.ThrowIfNull(slider);//clear cacheawait _cacheBase.RemoveByPrefix(SLIDERS_PATTERN_KEY);@@ -100,8 +99,7 @@ namespace Widgets.Slider.Services/// <param name="slide">Picture Slider</param>public virtual async Task InsertPictureSlider(PictureSlider slide){- if (slide == null)- throw new ArgumentNullException(nameof(slide));+ ArgumentNullException.ThrowIfNull(slide);//clear cacheawait _cacheBase.RemoveByPrefix(SLIDERS_PATTERN_KEY);@@ -115,8 +113,7 @@ namespace Widgets.Slider.Services/// <param name="slide">Picture Slider</param>public virtual async Task UpdatePictureSlider(PictureSlider slide){- if (slide == null)- throw new ArgumentNullException(nameof(slide));+ ArgumentNullException.ThrowIfNull(slide);//clear cacheawait _cacheBase.RemoveByPrefix(SLIDERS_PATTERN_KEY);@@ -130,8 +127,7 @@ namespace Widgets.Slider.Services/// <param name="slide">Picture Slider</param>public virtual async Task DeletePictureSlider(PictureSlider slide){- if (slide == null)- throw new ArgumentNullException(nameof(slide));+ ArgumentNullException.ThrowIfNull(slide);//clear cacheawait _cacheBase.RemoveByPrefix(SLIDERS_PATTERN_KEY);diff --git a/src/Tests/Grand.Business.System.Tests/Services/BackgroundService/QueuedMessagesSendScheduleTaskTests.cs b/src/Tests/Grand.Business.System.Tests/Services/BackgroundService/QueuedMessagesSendScheduleTaskTests.csindex b8627f668..d16116a17 100644--- a/src/Tests/Grand.Business.System.Tests/Services/BackgroundService/QueuedMessagesSendScheduleTaskTests.cs+++ b/src/Tests/Grand.Business.System.Tests/Services/BackgroundService/QueuedMessagesSendScheduleTaskTests.cs@@ -1,7 +1,6 @@using Grand.Business.Core.Interfaces.Messages;using Grand.Business.System.Services.BackgroundServices.ScheduleTasks;using Grand.Domain;-using Grand.Domain.Customers;using Grand.Domain.Messages;using Microsoft.Extensions.Logging;using Microsoft.VisualStudio.TestTools.UnitTesting;diff --git a/src/Tests/Grand.Data.Tests/AuditInfoProvider.cs b/src/Tests/Grand.Data.Tests/AuditInfoProvider.csindex a108eb808..0e8b2f15d 100644--- a/src/Tests/Grand.Data.Tests/AuditInfoProvider.cs+++ b/src/Tests/Grand.Data.Tests/AuditInfoProvider.cs@@ -1,6 +1,4 @@-using Grand.Data;--namespace Grand.Data.Tests;+namespace Grand.Data.Tests;public class AuditInfoProvider : IAuditInfoProvider{diff --git a/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryMock.cs b/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryMock.csindex ef058628a..539f3bee4 100644--- a/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryMock.cs+++ b/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryMock.cs@@ -1,5 +1,4 @@using Grand.Domain;-using Grand.Data;using Grand.Data.LiteDb;using LiteDB;diff --git a/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryTests.cs b/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryTests.csindex deabbf0b9..626077b6e 100644--- a/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryTests.cs+++ b/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryTests.cs@@ -1,5 +1,4 @@-using Grand.Data;-using Grand.SharedKernel.Extensions;+using Grand.SharedKernel.Extensions;using Microsoft.VisualStudio.TestTools.UnitTesting;namespace Grand.Data.Tests.LiteDb@@ -65,6 +64,17 @@ namespace Grand.Data.Tests.LiteDbAssert.IsNotNull(p);}+ [TestMethod()]+ public async Task GetOneAsyncAsync_LiteRepository_Success()+ {+ var product = new SampleCollection { Id = "1" };+ await _myRepository.InsertAsync(product);++ var p = await _myRepository.GetOneAsync(x=>x.Id == "1");++ Assert.IsNotNull(p);+ }+[TestMethod()]public async Task ClearAsync_LiteRepository_Success(){diff --git a/src/Tests/Grand.Data.Tests/MongoDb/MongoDBRepositoryTest.cs b/src/Tests/Grand.Data.Tests/MongoDb/MongoDBRepositoryTest.csindex 82a296c27..0e8f1a18e 100644--- a/src/Tests/Grand.Data.Tests/MongoDb/MongoDBRepositoryTest.cs+++ b/src/Tests/Grand.Data.Tests/MongoDb/MongoDBRepositoryTest.cs@@ -1,5 +1,4 @@using Grand.Domain;-using Grand.Data;using Grand.Data.Mongo;using MongoDB.Bson.Serialization.Conventions;diff --git a/src/Tests/Grand.Data.Tests/MongoDb/MongoRepositoryTests.cs b/src/Tests/Grand.Data.Tests/MongoDb/MongoRepositoryTests.csindex a6ad35a46..ad5778314 100644--- a/src/Tests/Grand.Data.Tests/MongoDb/MongoRepositoryTests.cs+++ b/src/Tests/Grand.Data.Tests/MongoDb/MongoRepositoryTests.cs@@ -1,5 +1,4 @@-using Grand.Data;-using Grand.SharedKernel.Extensions;+using Grand.SharedKernel.Extensions;using Microsoft.VisualStudio.TestTools.UnitTesting;namespace Grand.Data.Tests.MongoDb@@ -32,17 +31,17 @@ namespace Grand.Data.Tests.MongoDbAssert.IsTrue(_myRepository.Table.FirstOrDefault()!.CreatedOnUtc.Day == DateTime.UtcNow.Day);}-+[TestMethod()]public async Task GetById_MongoRepository_Success(){//Arrangevar product = new SampleCollection { Id = "1" };await _myRepository.InsertAsync(product);-+//Actvar p = _myRepository.GetById("1");-+//AssertAssert.IsNotNull(p);}@@ -61,6 +60,20 @@ namespace Grand.Data.Tests.MongoDbAssert.IsTrue(p!.CreatedOnUtc.Year == DateTime.UtcNow.Year);}+ [TestMethod()]+ public async Task GetOneAsync_MongoRepository_Success()+ {+ //Arrange+ var product = new SampleCollection { Id = "1" };+ await _myRepository.InsertAsync(product);+ //Act+ var p = await _myRepository.GetOneAsync(x => x.Id == "1");+ //Assert+ Assert.IsNotNull(p);+ Assert.IsTrue(p!.CreatedBy == "user");+ Assert.IsTrue(p!.CreatedOnUtc.Year == DateTime.UtcNow.Year);+ }+[TestMethod()]public async Task ClearAsync_MongoRepository_Success(){@@ -84,7 +97,7 @@ namespace Grand.Data.Tests.MongoDb//Actawait _myRepository.AddToSet("1", x => x.UserFields,- new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" });+ new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" });var p = _myRepository.GetById("1");@@ -125,17 +138,17 @@ namespace Grand.Data.Tests.MongoDb//AssertAssert.IsNull(p);}+[TestMethod()]public async Task DeleteManyAsync_MongoRepository_Success(){//Arrangevar products = new List<SampleCollection> {- new SampleCollection { Id = "1", Name = "Test" },- new SampleCollection { Id = "2", Name = "Test" },- new SampleCollection { Id = "3", Name = "Test2" }-+ new SampleCollection { Id = "1", Name = "Test" },+ new SampleCollection { Id = "2", Name = "Test" },+ new SampleCollection { Id = "3", Name = "Test2" }};- products.ForEach(x=>_myRepository.Insert(x));+ products.ForEach(x => _myRepository.Insert(x));//Actawait _myRepository.DeleteManyAsync(x => x.Name == "Test");@@ -149,16 +162,17 @@ namespace Grand.Data.Tests.MongoDb{//Arrangevar products = new List<SampleCollection> {- new SampleCollection { Id = "1", Name = "Test",- Phones = new [] { "Phone1", "Phone2", "Phone3" }+ new SampleCollection {+ Id = "1", Name = "Test",+ Phones = new[] { "Phone1", "Phone2", "Phone3" }},- new SampleCollection { Id = "2", Name = "Test2",- Phones = new [] { "Phone1", "Phone2", "Phone3" }+ new SampleCollection {+ Id = "2", Name = "Test2",+ Phones = new[] { "Phone1", "Phone2", "Phone3" }},- new SampleCollection { Id = "3", Name = "Test3" }-+ new SampleCollection { Id = "3", Name = "Test3" }};- products.ForEach(x=>_myRepository.Insert(x));+ products.ForEach(x => _myRepository.Insert(x));//Actawait _myRepository.Pull("1", x => x.Phones, "Phone2");@@ -172,21 +186,23 @@ namespace Grand.Data.Tests.MongoDbAssert.IsTrue(p!.UpdatedBy == "user");Assert.IsTrue(p!.UpdatedOnUtc.HasValue);}+[TestMethod()]public async Task Pull_Many_MongoRepository_Success(){//Arrangevar products = new List<SampleCollection> {- new SampleCollection { Id = "1", Name = "Test",- Phones = new [] { "Phone1", "Phone2", "Phone3" }+ new SampleCollection {+ Id = "1", Name = "Test",+ Phones = new[] { "Phone1", "Phone2", "Phone3" }},- new SampleCollection { Id = "2", Name = "Test2",- Phones = new [] { "Phone1", "Phone2", "Phone3" }+ new SampleCollection {+ Id = "2", Name = "Test2",+ Phones = new[] { "Phone1", "Phone2", "Phone3" }},- new SampleCollection { Id = "3", Name = "Test3" }-+ new SampleCollection { Id = "3", Name = "Test3" }};- products.ForEach(x=>_myRepository.Insert(x));+ products.ForEach(x => _myRepository.Insert(x));//Actawait _myRepository.Pull(String.Empty, x => x.Phones, "Phone2");@@ -208,17 +224,18 @@ namespace Grand.Data.Tests.MongoDb{//Arrangevar products = new List<SampleCollection> {- new SampleCollection { Id = "1", Name = "Test",- UserFields = new List<Domain.Common.UserField> {- new Domain.Common.UserField { Key = "key", Value = "value", StoreId = "" },- new Domain.Common.UserField { Key = "key1", Value = "value", StoreId = "" },- new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" }- } },- new SampleCollection { Id = "2", Name = "Test2" },- new SampleCollection { Id = "3", Name = "Test3" }-+ new SampleCollection {+ Id = "1", Name = "Test",+ UserFields = new List<Domain.Common.UserField> {+ new Domain.Common.UserField { Key = "key", Value = "value", StoreId = "" },+ new Domain.Common.UserField { Key = "key1", Value = "value", StoreId = "" },+ new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" }+ }+ },+ new SampleCollection { Id = "2", Name = "Test2" },+ new SampleCollection { Id = "3", Name = "Test3" }};- products.ForEach(x=>_myRepository.Insert(x));+ products.ForEach(x => _myRepository.Insert(x));//Actawait _myRepository.PullFilter("1", x => x.UserFields, x => x.Value == "value");@@ -231,7 +248,6 @@ namespace Grand.Data.Tests.MongoDbAssert.IsTrue(p1!.CreatedOnUtc.Year == DateTime.UtcNow.Year);Assert.IsTrue(p1!.UpdatedBy == "user");Assert.IsTrue(p1!.UpdatedOnUtc.HasValue);-}[TestMethod()]@@ -239,17 +255,18 @@ namespace Grand.Data.Tests.MongoDb{//Arrangevar products = new List<SampleCollection> {- new SampleCollection { Id = "1", Name = "Test",- UserFields = new List<Domain.Common.UserField> {- new Domain.Common.UserField { Key = "key", Value = "value", StoreId = "" },- new Domain.Common.UserField { Key = "key1", Value = "value", StoreId = "" },- new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" }- } },- new SampleCollection { Id = "2", Name = "Test2" },- new SampleCollection { Id = "3", Name = "Test3" }-+ new SampleCollection {+ Id = "1", Name = "Test",+ UserFields = new List<Domain.Common.UserField> {+ new Domain.Common.UserField { Key = "key", Value = "value", StoreId = "" },+ new Domain.Common.UserField { Key = "key1", Value = "value", StoreId = "" },+ new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" }+ }+ },+ new SampleCollection { Id = "2", Name = "Test2" },+ new SampleCollection { Id = "3", Name = "Test3" }};- products.ForEach(x=>_myRepository.Insert(x));+ products.ForEach(x => _myRepository.Insert(x));//Actawait _myRepository.PullFilter("1", x => x.UserFields, x => x.Value, "value");@@ -262,30 +279,32 @@ namespace Grand.Data.Tests.MongoDbAssert.IsTrue(p1!.CreatedOnUtc.Year == DateTime.UtcNow.Year);Assert.IsTrue(p1!.UpdatedBy == "user");Assert.IsTrue(p1!.UpdatedOnUtc.HasValue);-}+[TestMethod()]public async Task PullFilter_2_Many_MongoRepository_Success(){//Arrangevar products = new List<SampleCollection> {- new SampleCollection { Id = "1", Name = "Test",- UserFields = new List<Domain.Common.UserField> {- new Domain.Common.UserField { Key = "key", Value = "value", StoreId = "" },- new Domain.Common.UserField { Key = "key1", Value = "value", StoreId = "" },- new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" }- } },- new SampleCollection { Id = "2", Name = "Test2",- UserFields = new List<Domain.Common.UserField> {- new Domain.Common.UserField { Key = "key", Value = "value", StoreId = "" },- new Domain.Common.UserField { Key = "key1", Value = "value1", StoreId = "" },- new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" }- }- },- new SampleCollection { Id = "3", Name = "Test3" }-+ new SampleCollection {+ Id = "1", Name = "Test",+ UserFields = new List<Domain.Common.UserField> {+ new Domain.Common.UserField { Key = "key", Value = "value", StoreId = "" },+ new Domain.Common.UserField { Key = "key1", Value = "value", StoreId = "" },+ new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" }+ }+ },+ new SampleCollection {+ Id = "2", Name = "Test2",+ UserFields = new List<Domain.Common.UserField> {+ new Domain.Common.UserField { Key = "key", Value = "value", StoreId = "" },+ new Domain.Common.UserField { Key = "key1", Value = "value1", StoreId = "" },+ new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" }+ }+ },+ new SampleCollection { Id = "3", Name = "Test3" }};- products.ForEach(x=>_myRepository.Insert(x));+ products.ForEach(x => _myRepository.Insert(x));//Actawait _myRepository.PullFilter(String.Empty, x => x.UserFields, x => x.Value, "value");@@ -299,7 +318,6 @@ namespace Grand.Data.Tests.MongoDbAssert.IsTrue(p1!.CreatedOnUtc.Year == DateTime.UtcNow.Year);Assert.IsTrue(p1!.UpdatedBy == "user");Assert.IsTrue(p1!.UpdatedOnUtc.HasValue);-}@@ -308,17 +326,18 @@ namespace Grand.Data.Tests.MongoDb{//Arrangevar products = new List<SampleCollection> {- new SampleCollection { Id = "1", Name = "Test",- UserFields = new List<Domain.Common.UserField> {- new Domain.Common.UserField { Key = "key", Value = "value", StoreId = "" },- new Domain.Common.UserField { Key = "key1", Value = "value", StoreId = "" },- new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" }- } },- new SampleCollection { Id = "2", Name = "Test2" },- new SampleCollection { Id = "3", Name = "Test3" }-+ new SampleCollection {+ Id = "1", Name = "Test",+ UserFields = new List<Domain.Common.UserField> {+ new Domain.Common.UserField { Key = "key", Value = "value", StoreId = "" },+ new Domain.Common.UserField { Key = "key1", Value = "value", StoreId = "" },+ new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" }+ }+ },+ new SampleCollection { Id = "2", Name = "Test2" },+ new SampleCollection { Id = "3", Name = "Test3" }};- products.ForEach(x=>_myRepository.Insert(x));+ products.ForEach(x => _myRepository.Insert(x));var p1_update = products.FirstOrDefault();p1_update.Name = "update";@@ -326,29 +345,30 @@ namespace Grand.Data.Tests.MongoDb//Act_myRepository.Update(p1_update);var p1 = _myRepository.GetById("1");-+//AssertAssert.IsTrue(p1.Name == "update");Assert.IsTrue(p1!.UpdatedBy == "user");Assert.IsTrue(p1!.UpdatedOnUtc.HasValue);-}+[TestMethod()]public async Task UpdateAsync_MongoRepository_Success(){//Arrangevar products = new List<SampleCollection> {- new SampleCollection { Id = "1", Name = "Test",- UserFields = new List<Domain.Common.UserField> {- new Domain.Common.UserField { Key = "key", Value = "value", StoreId = "" },- new Domain.Common.UserField { Key = "key1", Value = "value", StoreId = "" },- new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" }- } },- new SampleCollection { Id = "2", Name = "Test2" },- new SampleCollection { Id = "3", Name = "Test3" }-+ new SampleCollection {+ Id = "1", Name = "Test",+ UserFields = new List<Domain.Common.UserField> {+ new Domain.Common.UserField { Key = "key", Value = "value", StoreId = "" },+ new Domain.Common.UserField { Key = "key1", Value = "value", StoreId = "" },+ new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" }+ }+ },+ new SampleCollection { Id = "2", Name = "Test2" },+ new SampleCollection { Id = "3", Name = "Test3" }};- products.ForEach(x=>_myRepository.Insert(x));+ products.ForEach(x => _myRepository.Insert(x));var p1_update = products.FirstOrDefault();p1_update.Name = "update";@@ -367,18 +387,19 @@ namespace Grand.Data.Tests.MongoDb{//Arrangevar products = new List<SampleCollection> {- new SampleCollection { Id = "1", Name = "Test",- UserFields = new List<Domain.Common.UserField> {- new Domain.Common.UserField { Key = "key", Value = "value", StoreId = "" },- new Domain.Common.UserField { Key = "key1", Value = "value", StoreId = "" },- new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" }- } },- new SampleCollection { Id = "2", Name = "Test2" },- new SampleCollection { Id = "3", Name = "Test3" }-+ new SampleCollection {+ Id = "1", Name = "Test",+ UserFields = new List<Domain.Common.UserField> {+ new Domain.Common.UserField { Key = "key", Value = "value", StoreId = "" },+ new Domain.Common.UserField { Key = "key1", Value = "value", StoreId = "" },+ new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" }+ }+ },+ new SampleCollection { Id = "2", Name = "Test2" },+ new SampleCollection { Id = "3", Name = "Test3" }};- products.ForEach(x=>_myRepository.Insert(x));-+ products.ForEach(x => _myRepository.Insert(x));+//Actawait _myRepository.UpdateField("1", x => x.Name, "update");var p1 = _myRepository.GetById("1");@@ -409,27 +430,27 @@ namespace Grand.Data.Tests.MongoDb{//Arrangevar products = new List<SampleCollection> {- new SampleCollection { Id = "1", Name = "Test",- UserFields = new List<Domain.Common.UserField> {- new Domain.Common.UserField { Key = "key", Value = "value", StoreId = "" },- new Domain.Common.UserField { Key = "key1", Value = "value", StoreId = "" },- new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" }- } },- new SampleCollection { Id = "2", Name = "Test" },- new SampleCollection { Id = "3", Name = "Test3" }-+ new SampleCollection {+ Id = "1", Name = "Test",+ UserFields = new List<Domain.Common.UserField> {+ new Domain.Common.UserField { Key = "key", Value = "value", StoreId = "" },+ new Domain.Common.UserField { Key = "key1", Value = "value", StoreId = "" },+ new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" }+ }+ },+ new SampleCollection { Id = "2", Name = "Test" },+ new SampleCollection { Id = "3", Name = "Test3" }};- products.ForEach(x=>_myRepository.Insert(x));+ products.ForEach(x => _myRepository.Insert(x));//Actawait _myRepository.UpdateManyAsync(x => x.Name == "Test",UpdateBuilder<SampleCollection>.Create().Set(x => x.Name, "UpdateTest"));- var pUpdated = _myRepository.Table.Where(x=>x.Name == "UpdateTest");+ var pUpdated = _myRepository.Table.Where(x => x.Name == "UpdateTest");var p1 = pUpdated.FirstOrDefault();//AssertAssert.IsTrue(pUpdated.Count() == 2);Assert.IsTrue(p1!.UpdatedBy == "user");Assert.IsTrue(p1!.UpdatedOnUtc.HasValue);-}[TestMethod()]@@ -437,18 +458,19 @@ namespace Grand.Data.Tests.MongoDb{//Arrangevar products = new List<SampleCollection> {- new SampleCollection { Id = "1", Name = "Test",- UserFields = new List<Domain.Common.UserField> {- new Domain.Common.UserField { Key = "key", Value = "value", StoreId = "" },- new Domain.Common.UserField { Key = "key1", Value = "value", StoreId = "" },- new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" }- } },- new SampleCollection { Id = "2", Name = "Test" },- new SampleCollection { Id = "3", Name = "Test3" }-+ new SampleCollection {+ Id = "1", Name = "Test",+ UserFields = new List<Domain.Common.UserField> {+ new Domain.Common.UserField { Key = "key", Value = "value", StoreId = "" },+ new Domain.Common.UserField { Key = "key1", Value = "value", StoreId = "" },+ new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" }+ }+ },+ new SampleCollection { Id = "2", Name = "Test" },+ new SampleCollection { Id = "3", Name = "Test3" }};- products.ForEach(x=>_myRepository.Insert(x));-+ products.ForEach(x => _myRepository.Insert(x));+//Actawait _myRepository.UpdateOneAsync(x => x.Name == "Test",UpdateBuilder<SampleCollection>.Create().Set(x => x.Name, "UpdateTest"));@@ -459,33 +481,34 @@ namespace Grand.Data.Tests.MongoDbAssert.IsTrue(pUpdated.Count() == 1);Assert.IsTrue(p1!.UpdatedBy == "user");Assert.IsTrue(p1!.UpdatedOnUtc.HasValue);-}+[TestMethod()]public async Task UpdateToSet_MongoRepository_Success(){//Arrangevar products = new List<SampleCollection> {- new SampleCollection { Id = "1", Name = "Test",- UserFields = new List<Domain.Common.UserField> {- new Domain.Common.UserField { Key = "key", Value = "value", StoreId = "" },- new Domain.Common.UserField { Key = "key1", Value = "value", StoreId = "" },- new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" }- } },- new SampleCollection { Id = "2", Name = "Test" },- new SampleCollection { Id = "3", Name = "Test3" }-+ new SampleCollection {+ Id = "1", Name = "Test",+ UserFields = new List<Domain.Common.UserField> {+ new Domain.Common.UserField { Key = "key", Value = "value", StoreId = "" },+ new Domain.Common.UserField { Key = "key1", Value = "value", StoreId = "" },+ new Domain.Common.UserField { Key = "key2", Value = "value2", StoreId = "" }+ }+ },+ new SampleCollection { Id = "2", Name = "Test" },+ new SampleCollection { Id = "3", Name = "Test3" }};- products.ForEach(x=>_myRepository.Insert(x));+ products.ForEach(x => _myRepository.Insert(x));//Act- await _myRepository.UpdateToSet("1", x => x.UserFields, z => z.Key, "key", new Domain.Common.UserField { Key = "key", Value = "update", StoreId = "1" });+ await _myRepository.UpdateToSet("1", x => x.UserFields, z => z.Key, "key",+ new Domain.Common.UserField { Key = "key", Value = "update", StoreId = "1" });var p = _myRepository.GetById("1");//Assert- Assert.IsTrue(p.UserFields.FirstOrDefault(x=>x.Key=="key")!.Value == "update");+ Assert.IsTrue(p.UserFields.FirstOrDefault(x => x.Key == "key")!.Value == "update");Assert.IsTrue(p!.UpdatedBy == "user");Assert.IsTrue(p!.UpdatedOnUtc.HasValue);-}}-}+}\ No newline at end of filediff --git a/src/Web/Grand.Web.Admin/Controllers/CustomerController.cs b/src/Web/Grand.Web.Admin/Controllers/CustomerController.csindex 3288f2c0b..0ef7ab14f 100644--- a/src/Web/Grand.Web.Admin/Controllers/CustomerController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/CustomerController.cs@@ -99,8 +99,7 @@ namespace Grand.Web.Admin.Controllersprotected virtual async Task<IList<CustomAttribute>> ParseCustomCustomerAttributes(IList<CustomAttributeModel> model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);var customAttributes = new List<CustomAttribute>();var customerAttributes = await _customerAttributeService.GetAllCustomerAttributes();diff --git a/src/Web/Grand.Web.Admin/Controllers/HomeController.cs b/src/Web/Grand.Web.Admin/Controllers/HomeController.csindex 5596eed34..b96672b27 100644--- a/src/Web/Grand.Web.Admin/Controllers/HomeController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/HomeController.cs@@ -6,7 +6,6 @@ using Grand.Business.Core.Interfaces.Common.Stores;using Grand.Business.Core.Queries.Customers;using Grand.Business.Core.Interfaces.System.Reports;using Grand.Domain.Customers;-using Grand.Domain.Directory;using Grand.Domain.Orders;using Grand.Infrastructure;using Grand.Web.Admin.Extensions;diff --git a/src/Web/Grand.Web.Admin/Controllers/SalesEmployeeController.cs b/src/Web/Grand.Web.Admin/Controllers/SalesEmployeeController.csindex 192766398..3f1bcbc9d 100644--- a/src/Web/Grand.Web.Admin/Controllers/SalesEmployeeController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/SalesEmployeeController.cs@@ -1,5 +1,4 @@using Grand.Business.Core.Interfaces.Checkout.Orders;-using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Business.Core.Utilities.Common.Security;using Grand.Business.Core.Interfaces.Customers;using Grand.Business.Core.Interfaces.Marketing.Documents;@@ -9,7 +8,6 @@ using Grand.Web.Common.Security.Authorization;using Grand.Domain.Customers;using Grand.Web.Admin.Models.Customers;using Microsoft.AspNetCore.Mvc;-using Grand.Infrastructure;using Grand.Web.Admin.Extensions.Mapping;namespace Grand.Web.Admin.Controllersdiff --git a/src/Web/Grand.Web.Admin/Extensions/AttributeParserHelper.cs b/src/Web/Grand.Web.Admin/Extensions/AttributeParserHelper.csindex bce3f0fa5..cf6e8fff4 100644--- a/src/Web/Grand.Web.Admin/Extensions/AttributeParserHelper.cs+++ b/src/Web/Grand.Web.Admin/Extensions/AttributeParserHelper.cs@@ -14,8 +14,7 @@ namespace Grand.Web.Admin.ExtensionsIAddressAttributeParser addressAttributeParser,IAddressAttributeService addressAttributeService){- if (address == null)- throw new ArgumentNullException(nameof(address));+ ArgumentNullException.ThrowIfNull(address);var customAttributes = new List<CustomAttribute>();var attributes = await addressAttributeService.GetAllAddressAttributes();diff --git a/src/Web/Grand.Web.Admin/Extensions/KnowledgebaseExtensions.cs b/src/Web/Grand.Web.Admin/Extensions/KnowledgebaseExtensions.csindex bcbfdd7e2..b3ca093dd 100644--- a/src/Web/Grand.Web.Admin/Extensions/KnowledgebaseExtensions.cs+++ b/src/Web/Grand.Web.Admin/Extensions/KnowledgebaseExtensions.cs@@ -43,8 +43,7 @@ namespace Grand.Web.Admin.Extensions/// <returns>Category breadcrumb </returns>public static IList<KnowledgebaseCategory> GetCategoryBreadCrumb(this KnowledgebaseCategory category, IList<KnowledgebaseCategory> allCategories){- if (category == null)- throw new ArgumentNullException(nameof(category));+ ArgumentNullException.ThrowIfNull(category);var result = new List<KnowledgebaseCategory>();@@ -68,8 +67,7 @@ namespace Grand.Web.Admin.Extensionspublic static List<KnowledgebaseCategory> SortCategoriesForTree(this IList<KnowledgebaseCategory> source, string parentId = null,bool ignoreCategoriesWithoutExistingParent = false){- if (source == null)- throw new ArgumentNullException(nameof(source));+ ArgumentNullException.ThrowIfNull(source);var result = new List<KnowledgebaseCategory>();diff --git a/src/Web/Grand.Web.Admin/Extensions/Mapping/AddressMappingExtensions.cs b/src/Web/Grand.Web.Admin/Extensions/Mapping/AddressMappingExtensions.csindex ffc6897f7..3ac47eca7 100644--- a/src/Web/Grand.Web.Admin/Extensions/Mapping/AddressMappingExtensions.cs+++ b/src/Web/Grand.Web.Admin/Extensions/Mapping/AddressMappingExtensions.cs@@ -40,12 +40,9 @@ namespace Grand.Web.Admin.Extensions.MappingIAddressAttributeService addressAttributeService,IAddressAttributeParser addressAttributeParser){- //this method is very similar to the same one in Grand.Web project- if (addressAttributeService == null)- throw new ArgumentNullException(nameof(addressAttributeService));-- if (addressAttributeParser == null)- throw new ArgumentNullException(nameof(addressAttributeParser));++ ArgumentNullException.ThrowIfNull(addressAttributeService);+ ArgumentNullException.ThrowIfNull(addressAttributeParser);var attributes = await addressAttributeService.GetAllAddressAttributes();foreach (var attribute in attributes)diff --git a/src/Web/Grand.Web.Admin/Extensions/PluginExtensions.cs b/src/Web/Grand.Web.Admin/Extensions/PluginExtensions.csindex 573f6c57d..9865b9cd9 100644--- a/src/Web/Grand.Web.Admin/Extensions/PluginExtensions.cs+++ b/src/Web/Grand.Web.Admin/Extensions/PluginExtensions.cs@@ -7,11 +7,8 @@ namespace Grand.Web.Admin.Extensions{public static string GetLogoUrl(this PluginInfo pluginDescriptor, IWorkContext workContext){- if (pluginDescriptor == null)- throw new ArgumentNullException(nameof(pluginDescriptor));-- if (workContext == null)- throw new ArgumentNullException(nameof(workContext));+ ArgumentNullException.ThrowIfNull(pluginDescriptor);+ ArgumentNullException.ThrowIfNull(workContext);if (pluginDescriptor.OriginalAssemblyFile?.Directory == null){diff --git a/src/Web/Grand.Web.Admin/Extensions/ProductExtensions.cs b/src/Web/Grand.Web.Admin/Extensions/ProductExtensions.csindex 5ec68e4d7..a6965581c 100644--- a/src/Web/Grand.Web.Admin/Extensions/ProductExtensions.cs+++ b/src/Web/Grand.Web.Admin/Extensions/ProductExtensions.cs@@ -19,10 +19,8 @@ namespace Grand.Web.Admin.Extensionspublic static async Task<Picture> GetProductPicture(this Product product, IList<CustomAttribute> attributes,IProductService productService, IPictureService pictureService){- if (product == null)- throw new ArgumentNullException(nameof(product));- if (pictureService == null)- throw new ArgumentNullException(nameof(pictureService));+ ArgumentNullException.ThrowIfNull(product);+ ArgumentNullException.ThrowIfNull(pictureService);Picture picture = null;diff --git a/src/Web/Grand.Web.Admin/Extensions/WidgetExtensions.cs b/src/Web/Grand.Web.Admin/Extensions/WidgetExtensions.csindex c22959203..f4612c7b9 100644--- a/src/Web/Grand.Web.Admin/Extensions/WidgetExtensions.cs+++ b/src/Web/Grand.Web.Admin/Extensions/WidgetExtensions.cs@@ -8,11 +8,8 @@ namespace Grand.Web.Admin.Extensionspublic static bool IsWidgetActive(this IWidgetProvider widget,WidgetSettings widgetSettings){- if (widget == null)- throw new ArgumentNullException(nameof(widget));-- if (widgetSettings == null)- throw new ArgumentNullException(nameof(widgetSettings));+ ArgumentNullException.ThrowIfNull(widget);+ ArgumentNullException.ThrowIfNull(widgetSettings);if (widgetSettings.ActiveWidgetSystemNames == null)return false;diff --git a/src/Web/Grand.Web.Admin/Services/AffiliateViewModelService.cs b/src/Web/Grand.Web.Admin/Services/AffiliateViewModelService.csindex e438f1587..888050e9c 100644--- a/src/Web/Grand.Web.Admin/Services/AffiliateViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/AffiliateViewModelService.cs@@ -53,8 +53,7 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task PrepareAffiliateModel(AffiliateModel model, Affiliate affiliate, bool excludeProperties,bool prepareEntireAddressModel = true){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);if (affiliate != null){diff --git a/src/Web/Grand.Web.Admin/Services/BrandViewModelService.cs b/src/Web/Grand.Web.Admin/Services/BrandViewModelService.csindex de2b22a9a..e12957e43 100644--- a/src/Web/Grand.Web.Admin/Services/BrandViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/BrandViewModelService.cs@@ -14,7 +14,6 @@ using Grand.Web.Admin.Extensions.Mapping;using Grand.Web.Admin.Interfaces;using Grand.Web.Admin.Models.Catalog;using Grand.Web.Common.Extensions;-using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.Mvc.Rendering;namespace Grand.Web.Admin.Services@@ -63,8 +62,7 @@ namespace Grand.Web.Admin.Servicespublic virtual void PrepareSortOptionsModel(BrandModel model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);model.AvailableSortOptions = ProductSortingEnum.Position.ToSelectList().ToList();model.AvailableSortOptions.Insert(0, new SelectListItem { Text = "None", Value = "-1" });@@ -72,8 +70,7 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task PrepareLayoutsModel(BrandModel model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);var layouts = await _brandLayoutService.GetAllBrandLayouts();foreach (var layout in layouts)@@ -88,8 +85,7 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task PrepareDiscountModel(BrandModel model, Brand brand, bool excludeProperties){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);model.AvailableDiscounts = (await _discountService.GetAllDiscounts(DiscountType.AssignedToBrands, storeId: _workContext.CurrentCustomer.Id, showHidden: true))diff --git a/src/Web/Grand.Web.Admin/Services/CampaignViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CampaignViewModelService.csindex 55832f2a6..2aa1505dc 100644--- a/src/Web/Grand.Web.Admin/Services/CampaignViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/CampaignViewModelService.cs@@ -49,8 +49,7 @@ namespace Grand.Web.Admin.Servicesprotected virtual async Task PrepareStoresModel(CampaignModel model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);var stores = await _storeService.GetAllStores();foreach (var store in stores)@@ -65,8 +64,7 @@ namespace Grand.Web.Admin.Servicesprotected virtual async Task PrepareLanguagesModel(CampaignModel model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);var languages = await _languageService.GetAllLanguages();foreach (var lang in languages)@@ -81,24 +79,21 @@ namespace Grand.Web.Admin.Servicesprotected virtual async Task PrepareCustomerTagsModel(CampaignModel model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);model.AvailableCustomerTags = (await _customerTagService.GetAllCustomerTags()).Select(ct => new SelectListItem { Text = ct.Name, Value = ct.Id, Selected = model.CustomerTags.Contains(ct.Id) }).ToList();model.CustomerTags ??= new List<string>();}protected virtual async Task PrepareCustomerGroupsModel(CampaignModel model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);model.AvailableCustomerGroups = (await _groupService.GetAllCustomerGroups()).Select(ct => new SelectListItem { Text = ct.Name, Value = ct.Id, Selected = model.CustomerGroups.Contains(ct.Id) }).ToList();model.CustomerGroups ??= new List<string>();}protected virtual async Task PrepareNewsletterCategoriesModel(CampaignModel model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);model.AvailableNewsletterCategories = (await _newsletterCategoryService.GetAllNewsletterCategory()).Select(ct => new SelectListItem { Text = ct.Name, Value = ct.Id, Selected = model.NewsletterCategories.Contains(ct.Id) }).ToList();model.NewsletterCategories ??= new List<string>();}diff --git a/src/Web/Grand.Web.Admin/Services/CategoryViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CategoryViewModelService.csindex 154eb241c..158eb007d 100644--- a/src/Web/Grand.Web.Admin/Services/CategoryViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/CategoryViewModelService.cs@@ -67,8 +67,7 @@ namespace Grand.Web.Admin.Servicesprotected virtual async Task PrepareLayoutsModel(CategoryModel model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);var layouts = await _categoryLayoutService.GetAllCategoryLayouts();foreach (var layout in layouts)@@ -82,8 +81,7 @@ namespace Grand.Web.Admin.Servicesprotected virtual async Task PrepareDiscountModel(CategoryModel model, Category category, bool excludeProperties, string storeId){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);model.AvailableDiscounts = (await _discountService.GetAllDiscounts(DiscountType.AssignedToCategories, storeId: storeId, showHidden: true))@@ -97,8 +95,7 @@ namespace Grand.Web.Admin.Services}protected virtual void PrepareSortOptionsModel(CategoryModel model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);model.AvailableSortOptions = ProductSortingEnum.Position.ToSelectList().ToList();model.AvailableSortOptions.Insert(0, new SelectListItem { Text = "None", Value = "-1" });diff --git a/src/Web/Grand.Web.Admin/Services/CheckoutAttributeViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CheckoutAttributeViewModelService.csindex a8186b96e..90e79c4b4 100644--- a/src/Web/Grand.Web.Admin/Services/CheckoutAttributeViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/CheckoutAttributeViewModelService.cs@@ -32,8 +32,7 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task PrepareTaxCategories(CheckoutAttributeModel model, CheckoutAttribute checkoutAttribute, bool excludeProperties){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);//tax categoriesvar taxCategories = await taxCategoryService.GetAllTaxCategories();@@ -44,8 +43,7 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task PrepareConditionAttributes(CheckoutAttributeModel model, CheckoutAttribute checkoutAttribute){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);//currenty any checkout attribute can have condition.model.ConditionAllowed = true;diff --git a/src/Web/Grand.Web.Admin/Services/CollectionViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CollectionViewModelService.csindex 1b31571ff..7153bbcc6 100644--- a/src/Web/Grand.Web.Admin/Services/CollectionViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/CollectionViewModelService.cs@@ -76,8 +76,7 @@ namespace Grand.Web.Admin.Servicespublic virtual void PrepareSortOptionsModel(CollectionModel model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);model.AvailableSortOptions = ProductSortingEnum.Position.ToSelectList().ToList();model.AvailableSortOptions.Insert(0, new SelectListItem { Text = "None", Value = "-1" });@@ -85,8 +84,7 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task PrepareLayoutsModel(CollectionModel model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);var layouts = await _collectionLayoutService.GetAllCollectionLayouts();foreach (var layout in layouts)@@ -101,8 +99,7 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task PrepareDiscountModel(CollectionModel model, Collection collection, bool excludeProperties){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);model.AvailableDiscounts = (await _discountService.GetAllDiscounts(DiscountType.AssignedToCollections, storeId: _workContext.CurrentCustomer.Id, showHidden: true))diff --git a/src/Web/Grand.Web.Admin/Services/ContactAttributeViewModelService.cs b/src/Web/Grand.Web.Admin/Services/ContactAttributeViewModelService.csindex def86fd12..ced34d0de 100644--- a/src/Web/Grand.Web.Admin/Services/ContactAttributeViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/ContactAttributeViewModelService.cs@@ -82,8 +82,7 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task PrepareConditionAttributes(ContactAttributeModel model, ContactAttribute contactAttribute){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);//currenty any contact attribute can have condition.model.ConditionAllowed = true;diff --git a/src/Web/Grand.Web.Admin/Services/CustomerViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CustomerViewModelService.csindex 59b552e1e..54e68e639 100644--- a/src/Web/Grand.Web.Admin/Services/CustomerViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/CustomerViewModelService.cs@@ -148,8 +148,7 @@ namespace Grand.Web.Admin.Servicesprotected virtual async Task SaveCustomerTags(Customer customer, string[] customerTags){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);//product tagsvar existingCustomerTags = customer.CustomerTags.ToList();@@ -212,8 +211,7 @@ namespace Grand.Web.Admin.Servicesprotected virtual async Task<IList<CustomerModel.AssociatedExternalAuthModel>> GetAssociatedExternalAuthRecords(Customer customer){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);var openAuthenticationService = _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<IExternalAuthenticationService>();var result = new List<CustomerModel.AssociatedExternalAuthModel>();foreach (var record in await openAuthenticationService.GetExternalIdentifiers(customer))@@ -252,8 +250,7 @@ namespace Grand.Web.Admin.Servicesprotected virtual async Task PrepareSalesEmployeeModel(CustomerModel model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);model.AvailableSalesEmployees.Add(new SelectListItem {Text = _translationService.GetResource("Admin.Customers.Customers.Fields.SalesEmployee.None"),@@ -272,8 +269,7 @@ namespace Grand.Web.Admin.Servicesprotected virtual async Task PrepareStoresModel(CustomerModel model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);model.AvailableStores.Add(new SelectListItem {Text = _translationService.GetResource("Admin.Customers.Customers.Fields.StaffStore.None"),@@ -988,8 +984,7 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task PrepareAddressModel(CustomerAddressModel model, Address address, Customer customer, bool excludeProperties){- if (customer == null)- throw new ArgumentNullException(nameof(customer));+ ArgumentNullException.ThrowIfNull(customer);model.CustomerId = customer.Id;if (address != null)diff --git a/src/Web/Grand.Web.Admin/Services/DiscountViewModelService.cs b/src/Web/Grand.Web.Admin/Services/DiscountViewModelService.csindex 4f4c6cdc3..6bddefb1d 100644--- a/src/Web/Grand.Web.Admin/Services/DiscountViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/DiscountViewModelService.cs@@ -114,8 +114,7 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task PrepareDiscountModel(DiscountModel model, Discount discount){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);model.AvailableDiscountRequirementRules.Add(new SelectListItem {Text = _translationService.GetResource(@@ -243,11 +242,8 @@ namespace Grand.Web.Admin.Servicespublic virtual string GetRequirementUrlInternal(IDiscountRule discountRequirementRule, Discount discount,string discountRequirementId){- if (discountRequirementRule == null)- throw new ArgumentNullException(nameof(discountRequirementRule));-- if (discount == null)- throw new ArgumentNullException(nameof(discount));+ ArgumentNullException.ThrowIfNull(discountRequirementRule);+ ArgumentNullException.ThrowIfNull(discount);var storeLocation = _workContext.CurrentHost.Url.TrimEnd('/');diff --git a/src/Web/Grand.Web.Admin/Services/LanguageViewModelService.cs b/src/Web/Grand.Web.Admin/Services/LanguageViewModelService.csindex ac359ea9c..bda16eb1b 100644--- a/src/Web/Grand.Web.Admin/Services/LanguageViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/LanguageViewModelService.cs@@ -34,8 +34,7 @@ namespace Grand.Web.Admin.Servicespublic virtual void PrepareFlagsModel(LanguageModel model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);model.FlagFileNames = Directory.EnumerateFiles(CommonPath.WebHostMapPath("/assets/images/flags/"), "*.png", SearchOption.TopDirectoryOnly)@@ -45,8 +44,7 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task PrepareCurrenciesModel(LanguageModel model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);model.AvailableCurrencies.Add(new SelectListItem{diff --git a/src/Web/Grand.Web.Admin/Services/MenuViewModelService.cs b/src/Web/Grand.Web.Admin/Services/MenuViewModelService.csindex a840a1604..839d220d8 100644--- a/src/Web/Grand.Web.Admin/Services/MenuViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/MenuViewModelService.cs@@ -44,8 +44,7 @@ public class MenuViewModelService : IMenuViewModelServicepublic virtual async Task<AdminSiteMap> InsertMenuModel(MenuModel model, string parentId){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);if (!string.IsNullOrEmpty(parentId)){@@ -70,8 +69,7 @@ public class MenuViewModelService : IMenuViewModelServicepublic virtual async Task<AdminSiteMap> UpdateMenuModel(MenuModel model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);var sitemap = await _adminSiteMapService.GetSiteMap();var parentEntity = FindTopLevelNodeById(sitemap, model.Id);diff --git a/src/Web/Grand.Web.Admin/Services/MerchandiseReturnViewModelService.cs b/src/Web/Grand.Web.Admin/Services/MerchandiseReturnViewModelService.csindex 2aeb9c374..a7c1e5b92 100644--- a/src/Web/Grand.Web.Admin/Services/MerchandiseReturnViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/MerchandiseReturnViewModelService.cs@@ -51,11 +51,8 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task<MerchandiseReturnModel> PrepareMerchandiseReturnModel(MerchandiseReturnModel model,MerchandiseReturn merchandiseReturn, bool excludeProperties){- if (model == null)- throw new ArgumentNullException(nameof(model));-- if (merchandiseReturn == null)- throw new ArgumentNullException(nameof(merchandiseReturn));+ ArgumentNullException.ThrowIfNull(model);+ ArgumentNullException.ThrowIfNull(merchandiseReturn);var order = await orderService.GetOrderById(merchandiseReturn.OrderId);double unitPriceInclTaxInCustomerCurrency = 0;diff --git a/src/Web/Grand.Web.Admin/Services/NewsViewModelService.cs b/src/Web/Grand.Web.Admin/Services/NewsViewModelService.csindex 37a94300d..6eda935e8 100644--- a/src/Web/Grand.Web.Admin/Services/NewsViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/NewsViewModelService.cs@@ -13,8 +13,6 @@ using Grand.Web.Admin.Extensions;using Grand.Web.Admin.Extensions.Mapping;using Grand.Web.Admin.Interfaces;using Grand.Web.Admin.Models.News;-using Microsoft.AspNetCore.Http;-using Microsoft.Extensions.DependencyInjection;namespace Grand.Web.Admin.Services{diff --git a/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs b/src/Web/Grand.Web.Admin/Services/OrderViewModelService.csindex a05e99d74..bcd19f41f 100644--- a/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs@@ -357,11 +357,8 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task PrepareOrderDetailsModel(OrderModel model, Order order){- if (order == null)- throw new ArgumentNullException(nameof(order));-- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(order);+ ArgumentNullException.ThrowIfNull(model);model.Id = order.Id;model.OrderNumber = order.OrderNumber;@@ -1271,8 +1268,7 @@ namespace Grand.Web.Admin.Services/// <returns>Order's tag</returns>public virtual async Task SaveOrderTags(Order order, string orderTags){- if (order == null)- throw new ArgumentNullException(nameof(order));+ ArgumentNullException.ThrowIfNull(order);//order's tagsvar existingOrderTags = new List<string>();diff --git a/src/Web/Grand.Web.Admin/Services/PageViewModelService.cs b/src/Web/Grand.Web.Admin/Services/PageViewModelService.csindex fc9a6fc50..91c07ed50 100644--- a/src/Web/Grand.Web.Admin/Services/PageViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/PageViewModelService.cs@@ -9,7 +9,6 @@ using Grand.Domain.Pages;using Grand.Web.Admin.Interfaces;using Grand.Web.Admin.Models.Pages;using Microsoft.AspNetCore.Mvc.Rendering;-using Grand.Infrastructure;using Grand.Web.Admin.Extensions.Mapping;using Grand.Web.Common.Extensions;@@ -58,8 +57,7 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task PrepareLayoutsModel(PageModel model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);var layouts = await _pageLayoutService.GetAllPageLayouts();foreach (var layout in layouts)diff --git a/src/Web/Grand.Web.Admin/Services/ProductReviewViewModelService.cs b/src/Web/Grand.Web.Admin/Services/ProductReviewViewModelService.csindex ca8dd7fec..288db4d0d 100644--- a/src/Web/Grand.Web.Admin/Services/ProductReviewViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/ProductReviewViewModelService.cs@@ -47,11 +47,9 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task PrepareProductReviewModel(ProductReviewModel model,ProductReview productReview, bool excludeProperties, bool formatReviewText){- if (model == null)- throw new ArgumentNullException(nameof(model));-- if (productReview == null)- throw new ArgumentNullException(nameof(productReview));+ ArgumentNullException.ThrowIfNull(model);+ ArgumentNullException.ThrowIfNull(productReview);+var product = await _productService.GetProductById(productReview.ProductId);var customer = await _customerService.GetCustomerById(productReview.CustomerId);var store = await _storeService.GetStoreById(productReview.StoreId);diff --git a/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs b/src/Web/Grand.Web.Admin/Services/ProductViewModelService.csindex d68d8de7b..0d13971e2 100644--- a/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs@@ -106,8 +106,7 @@ namespace Grand.Web.Admin.Services}protected virtual async Task SaveProductTags(Product product, string[] productTags){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);//product tagsvar existingProductTags = product.ProductTags.ToList();@@ -187,10 +186,9 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task PrepareAddProductAttributeCombinationModel(ProductAttributeCombinationModel model, Product product){- if (model == null)- throw new ArgumentNullException(nameof(model));- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(model);+ ArgumentNullException.ThrowIfNull(product);+if (product.UseMultipleWarehouses){model.UseMultipleWarehouses = product.UseMultipleWarehouses;@@ -368,8 +366,7 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task PrepareProductModel(ProductModel model, Product product,bool setPredefinedValues, bool excludeProperties){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);model.PrimaryStoreCurrencyCode = (await currencyService.GetCurrencyById(currencySettings.PrimaryStoreCurrencyId))?.CurrencyCode;model.BaseWeightIn = (await measureService.GetMeasureWeightById(measureSettings.BaseWeightId))?.Name;@@ -543,8 +540,7 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task SaveProductWarehouseInventory(Product product, IList<ProductModel.ProductWarehouseInventoryModel> model){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);if (product.ManageInventoryMethodId != ManageInventoryMethod.ManageStock)return;@@ -597,11 +593,9 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task PrepareProductReviewModel(ProductReviewModel model,ProductReview productReview, bool excludeProperties, bool formatReviewText){- if (model == null)- throw new ArgumentNullException(nameof(model));-- if (productReview == null)- throw new ArgumentNullException(nameof(productReview));+ ArgumentNullException.ThrowIfNull(model);+ ArgumentNullException.ThrowIfNull(productReview);+var product = await productService.GetProductById(productReview.ProductId);var customer = await customerService.GetCustomerById(productReview.CustomerId);var store = await storeService.GetStoreById(productReview.StoreId);diff --git a/src/Web/Grand.Web.Admin/Services/StoreViewModelService.cs b/src/Web/Grand.Web.Admin/Services/StoreViewModelService.csindex 2e57233d3..ba45da83b 100644--- a/src/Web/Grand.Web.Admin/Services/StoreViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/StoreViewModelService.cs@@ -33,8 +33,7 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task PrepareLanguagesModel(StoreModel model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);model.AvailableLanguages.Add(new SelectListItem {Text = "---",@@ -52,8 +51,7 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task PrepareWarehouseModel(StoreModel model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);//warehousemodel.AvailableWarehouses.Add(new SelectListItem {@@ -71,8 +69,7 @@ namespace Grand.Web.Admin.Services}public virtual async Task PrepareCountryModel(StoreModel model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);//countriesmodel.AvailableCountries.Add(new SelectListItem {@@ -91,8 +88,7 @@ namespace Grand.Web.Admin.Services}public virtual async Task PrepareCurrencyModel(StoreModel model){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);//countriesmodel.AvailableCurrencies.Add(new SelectListItem {@@ -193,10 +189,8 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task InsertDomainHostModel(Store store, DomainHostModel model){- if (store == null)- throw new ArgumentNullException(nameof(store));- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(store);+ ArgumentNullException.ThrowIfNull(model);if (!model.Url.EndsWith("/"))model.Url += "/";@@ -213,11 +207,9 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task UpdateDomainHostModel(Store store, DomainHostModel model){- if (store == null)- throw new ArgumentNullException(nameof(store));- if (model == null)- throw new ArgumentNullException(nameof(model));-+ ArgumentNullException.ThrowIfNull(store);+ ArgumentNullException.ThrowIfNull(model);+if (!model.Url.EndsWith("/"))model.Url += "/";diff --git a/src/Web/Grand.Web.Admin/Services/VendorViewModelService.cs b/src/Web/Grand.Web.Admin/Services/VendorViewModelService.csindex 1b01ec664..14173d9b5 100644--- a/src/Web/Grand.Web.Admin/Services/VendorViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/VendorViewModelService.cs@@ -41,8 +41,7 @@ namespace Grand.Web.Admin.Services{public virtual async Task PrepareDiscountModel(VendorModel model, Vendor vendor, bool excludeProperties){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);model.AvailableDiscounts = (await discountService.GetAllDiscounts(DiscountType.AssignedToVendors, showHidden: true))@@ -58,11 +57,8 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task PrepareVendorReviewModel(VendorReviewModel model,VendorReview vendorReview, bool excludeProperties, bool formatReviewText){- if (model == null)- throw new ArgumentNullException(nameof(model));-- if (vendorReview == null)- throw new ArgumentNullException(nameof(vendorReview));+ ArgumentNullException.ThrowIfNull(model);+ ArgumentNullException.ThrowIfNull(vendorReview);var vendor = await vendorService.GetVendorById(vendorReview.VendorId);var customer = await customerService.GetCustomerById(vendorReview.CustomerId);diff --git a/src/Web/Grand.Web.Admin/Startup/StartupApplication.cs b/src/Web/Grand.Web.Admin/Startup/StartupApplication.csindex e1fb09f72..8ec91b826 100644--- a/src/Web/Grand.Web.Admin/Startup/StartupApplication.cs+++ b/src/Web/Grand.Web.Admin/Startup/StartupApplication.cs@@ -7,7 +7,6 @@ using Grand.Web.Admin.Services;using Grand.Web.Common.View;using Microsoft.AspNetCore.Builder;using Microsoft.AspNetCore.Hosting;-using Microsoft.AspNetCore.Mvc.Razor;using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;diff --git a/src/Web/Grand.Web.Admin/Validators/Customers/CustomerValidator.cs b/src/Web/Grand.Web.Admin/Validators/Customers/CustomerValidator.csindex f72f19f2b..6f7cfad3a 100644--- a/src/Web/Grand.Web.Admin/Validators/Customers/CustomerValidator.cs+++ b/src/Web/Grand.Web.Admin/Validators/Customers/CustomerValidator.cs@@ -101,8 +101,7 @@ namespace Grand.Web.Admin.Validators.Customersasync Task<string> ValidateCustomerGroups(IList<CustomerGroup> customerGroups, CustomerModel customerModel){- if (customerGroups == null)- throw new ArgumentNullException(nameof(customerGroups));+ ArgumentNullException.ThrowIfNull(customerGroups);//ensure a customer is not added to both 'Guests' and 'Registered' customer groups//ensure that a customer is in at least one required role ('Guests' and 'Registered')diff --git a/src/Web/Grand.Web.Common/Binders/CustomAttributesBinderProvider.cs b/src/Web/Grand.Web.Common/Binders/CustomAttributesBinderProvider.csindex 1101b7d77..203d8ffe3 100644--- a/src/Web/Grand.Web.Common/Binders/CustomAttributesBinderProvider.cs+++ b/src/Web/Grand.Web.Common/Binders/CustomAttributesBinderProvider.cs@@ -8,16 +8,7 @@ public class CustomAttributesBinderProvider : IModelBinderProvider{public IModelBinder GetBinder(ModelBinderProviderContext context){- if (context == null)- {- throw new ArgumentNullException(nameof(context));- }-- if (context.Metadata.ModelType == typeof(IList<CustomAttributeModel>))- {- return new BinderTypeModelBinder(typeof(CustomAttributesBinder));- }-- return null;+ ArgumentNullException.ThrowIfNull(context);+ return context.Metadata.ModelType == typeof(IList<CustomAttributeModel>) ? new BinderTypeModelBinder(typeof(CustomAttributesBinder)) : null;}}diff --git a/src/Web/Grand.Web.Common/Filters/AuthorizeAdminAttribute.cs b/src/Web/Grand.Web.Common/Filters/AuthorizeAdminAttribute.csindex eb4fcfa50..6e9c65c6f 100644--- a/src/Web/Grand.Web.Common/Filters/AuthorizeAdminAttribute.cs+++ b/src/Web/Grand.Web.Common/Filters/AuthorizeAdminAttribute.cs@@ -68,9 +68,7 @@ namespace Grand.Web.Common.Filters/// <param name="filterContext">Authorization filter context</param>public async Task OnAuthorizationAsync(AuthorizationFilterContext filterContext){-- if (filterContext == null)- throw new ArgumentNullException(nameof(filterContext));+ ArgumentNullException.ThrowIfNull(filterContext);//check whether this filter has been overridden for the actionvar actionFilter = filterContext.ActionDescriptor.FilterDescriptorsdiff --git a/src/Web/Grand.Web.Common/Filters/AuthorizeMenuAttribute.cs b/src/Web/Grand.Web.Common/Filters/AuthorizeMenuAttribute.csindex 7b93e752a..c6a9750dc 100644--- a/src/Web/Grand.Web.Common/Filters/AuthorizeMenuAttribute.cs+++ b/src/Web/Grand.Web.Common/Filters/AuthorizeMenuAttribute.cs@@ -72,8 +72,7 @@ namespace Grand.Web.Common.Filters/// <param name="filterContext">Authorization filter context</param>public async Task OnAuthorizationAsync(AuthorizationFilterContext filterContext){- if (filterContext == null)- throw new ArgumentNullException(nameof(filterContext));+ ArgumentNullException.ThrowIfNull(filterContext);//check whether this filter has been overridden for the actionvar actionFilter = filterContext.ActionDescriptor.FilterDescriptorsdiff --git a/src/Web/Grand.Web.Common/Filters/AuthorizeVendorAttribute.cs b/src/Web/Grand.Web.Common/Filters/AuthorizeVendorAttribute.csindex 7a4a4d6e2..3c50aa4f0 100644--- a/src/Web/Grand.Web.Common/Filters/AuthorizeVendorAttribute.cs+++ b/src/Web/Grand.Web.Common/Filters/AuthorizeVendorAttribute.cs@@ -64,8 +64,7 @@ namespace Grand.Web.Common.Filterspublic async Task OnAuthorizationAsync(AuthorizationFilterContext context){//ignore filter actions- if (context == null)- throw new ArgumentNullException(nameof(context));+ ArgumentNullException.ThrowIfNull(context);//check whether this filter has been overridden for the Actionvar actionFilter = context.ActionDescriptor.FilterDescriptorsdiff --git a/src/Web/Grand.Web.Common/Filters/DenySystemAccountAttribute.cs b/src/Web/Grand.Web.Common/Filters/DenySystemAccountAttribute.csindex 04e19b529..7299eea91 100644--- a/src/Web/Grand.Web.Common/Filters/DenySystemAccountAttribute.cs+++ b/src/Web/Grand.Web.Common/Filters/DenySystemAccountAttribute.cs@@ -59,8 +59,7 @@ namespace Grand.Web.Common.Filterspublic Task OnAuthorizationAsync(AuthorizationFilterContext context){//ignore filter (the action available even when navigation is not allowed)- if (context == null)- throw new ArgumentNullException(nameof(context));+ ArgumentNullException.ThrowIfNull(context);var actionFilter = context.ActionDescriptor.FilterDescriptors.Where(f => f.Scope == FilterScope.Action)diff --git a/src/Web/Grand.Web.Common/Filters/LanguageAttribute.cs b/src/Web/Grand.Web.Common/Filters/LanguageAttribute.csindex 78e793033..b9357162f 100644--- a/src/Web/Grand.Web.Common/Filters/LanguageAttribute.cs+++ b/src/Web/Grand.Web.Common/Filters/LanguageAttribute.cs@@ -117,8 +117,7 @@ namespace Grand.Web.Common.Filtersprivate static string AddLanguageSeo(string url, Language language){- if (language == null)- throw new ArgumentNullException(nameof(language));+ ArgumentNullException.ThrowIfNull(language);//remove application path from raw URLif (!string.IsNullOrEmpty(url))diff --git a/src/Web/Grand.Web.Common/Filters/PublicStoreAttribute.cs b/src/Web/Grand.Web.Common/Filters/PublicStoreAttribute.csindex 24e88869b..7a440bec2 100644--- a/src/Web/Grand.Web.Common/Filters/PublicStoreAttribute.cs+++ b/src/Web/Grand.Web.Common/Filters/PublicStoreAttribute.cs@@ -61,8 +61,7 @@ namespace Grand.Web.Common.Filterspublic async Task OnAuthorizationAsync(AuthorizationFilterContext filterContext){//ignore filter (the action available even when navigation is not allowed)- if (filterContext == null)- throw new ArgumentNullException(nameof(filterContext));+ ArgumentNullException.ThrowIfNull(filterContext);//check whether this filter has been overridden for the Actionvar actionFilter = filterContext.ActionDescriptor.FilterDescriptorsdiff --git a/src/Web/Grand.Web.Common/Infrastructure/BackgroundServiceTask.cs b/src/Web/Grand.Web.Common/Infrastructure/BackgroundServiceTask.csindex cdbb16097..38f4d1bf2 100644--- a/src/Web/Grand.Web.Common/Infrastructure/BackgroundServiceTask.cs+++ b/src/Web/Grand.Web.Common/Infrastructure/BackgroundServiceTask.cs@@ -102,7 +102,7 @@ namespace Grand.Web.Common.Infrastructurebreak;}- catch (Exception ex)+ catch (Exception){await Task.Delay(TimeSpan.FromMinutes(1), stoppingToken);}diff --git a/src/Web/Grand.Web.Common/Security/Authorization/CustomerGroupAuthorizeAttribute.cs b/src/Web/Grand.Web.Common/Security/Authorization/CustomerGroupAuthorizeAttribute.csindex f7a884c19..8b294304e 100644--- a/src/Web/Grand.Web.Common/Security/Authorization/CustomerGroupAuthorizeAttribute.cs+++ b/src/Web/Grand.Web.Common/Security/Authorization/CustomerGroupAuthorizeAttribute.cs@@ -18,8 +18,7 @@ namespace Grand.Web.Common.Security.Authorizationpublic async Task OnAuthorizationAsync(AuthorizationFilterContext context){- if (context == null)- throw new ArgumentNullException(nameof(context));+ ArgumentNullException.ThrowIfNull(context);if (string.IsNullOrEmpty(GroupName))return;diff --git a/src/Web/Grand.Web.Common/Security/Authorization/PermissionAuthorizeActionAttribute.cs b/src/Web/Grand.Web.Common/Security/Authorization/PermissionAuthorizeActionAttribute.csindex a21133a62..c65f0e663 100644--- a/src/Web/Grand.Web.Common/Security/Authorization/PermissionAuthorizeActionAttribute.cs+++ b/src/Web/Grand.Web.Common/Security/Authorization/PermissionAuthorizeActionAttribute.cs@@ -22,8 +22,7 @@ namespace Grand.Web.Common.Security.Authorizationpublic async Task OnAuthorizationAsync(AuthorizationFilterContext context){//ignore filter (the action available even when navigation is not allowed)- if (context == null)- throw new ArgumentNullException(nameof(context));+ ArgumentNullException.ThrowIfNull(context);if (string.IsNullOrEmpty(PermissionAction))return;diff --git a/src/Web/Grand.Web.Common/Security/Authorization/PermissionAuthorizeAttribute.cs b/src/Web/Grand.Web.Common/Security/Authorization/PermissionAuthorizeAttribute.csindex 249b106c8..30c46dc09 100644--- a/src/Web/Grand.Web.Common/Security/Authorization/PermissionAuthorizeAttribute.cs+++ b/src/Web/Grand.Web.Common/Security/Authorization/PermissionAuthorizeAttribute.cs@@ -21,8 +21,7 @@ namespace Grand.Web.Common.Security.Authorizationpublic async Task OnAuthorizationAsync(AuthorizationFilterContext context){//ignore filter (the action available even when navigation is not allowed)- if (context == null)- throw new ArgumentNullException(nameof(context));+ ArgumentNullException.ThrowIfNull(context);if (string.IsNullOrEmpty(Permission))return;diff --git a/src/Web/Grand.Web.Common/TagHelpers/Admin/AdminInputTagHelper.cs b/src/Web/Grand.Web.Common/TagHelpers/Admin/AdminInputTagHelper.csindex 106d84dad..33feb76eb 100644--- a/src/Web/Grand.Web.Common/TagHelpers/Admin/AdminInputTagHelper.cs+++ b/src/Web/Grand.Web.Common/TagHelpers/Admin/AdminInputTagHelper.cs@@ -88,15 +88,9 @@ namespace Grand.Web.Common.TagHelpers.Admin/// <param name="output">Output</param>public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output){- if (context == null)- {- throw new ArgumentNullException(nameof(context));- }+ ArgumentNullException.ThrowIfNull(context);- if (output == null)- {- throw new ArgumentNullException(nameof(output));- }+ ArgumentNullException.ThrowIfNull(output);//clear the outputoutput.SuppressOutput();diff --git a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/DefaultEditorTemplates.cs b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/DefaultEditorTemplates.csindex 6652e37d7..08a316e3f 100644--- a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/DefaultEditorTemplates.cs+++ b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/DefaultEditorTemplates.cs@@ -394,20 +394,14 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendpublic static async Task<IHtmlContent> FileInputTemplate(IHtmlHelper htmlHelper){- if (htmlHelper == null)- {- throw new ArgumentNullException(nameof(htmlHelper));- }+ ArgumentNullException.ThrowIfNull(htmlHelper);return await Task.FromResult(GenerateTextBox(htmlHelper, inputType: "file"));}public static async Task<IHtmlContent> FileCollectionInputTemplate(IHtmlHelper htmlHelper){- if (htmlHelper == null)- {- throw new ArgumentNullException(nameof(htmlHelper));- }+ ArgumentNullException.ThrowIfNull(htmlHelper);var htmlAttributes =CreateHtmlAttributes(htmlHelper, className: "text-box single-line", inputType: "file");diff --git a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/DefaultHtmlGenerator.cs b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/DefaultHtmlGenerator.csindex 02d1e6b7e..883138822 100644--- a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/DefaultHtmlGenerator.cs+++ b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/DefaultHtmlGenerator.cs@@ -56,35 +56,12 @@ namespace Grand.Web.Common.TagHelpers.Admin.ExtendHtmlEncoder htmlEncoder,ValidationHtmlAttributeProvider validationAttributeProvider){- if (antiforgery == null)- {- throw new ArgumentNullException(nameof(antiforgery));- }-- if (optionsAccessor == null)- {- throw new ArgumentNullException(nameof(optionsAccessor));- }-- if (metadataProvider == null)- {- throw new ArgumentNullException(nameof(metadataProvider));- }-- if (urlHelperFactory == null)- {- throw new ArgumentNullException(nameof(urlHelperFactory));- }-- if (htmlEncoder == null)- {- throw new ArgumentNullException(nameof(htmlEncoder));- }-- if (validationAttributeProvider == null)- {- throw new ArgumentNullException(nameof(validationAttributeProvider));- }+ ArgumentNullException.ThrowIfNull(antiforgery);+ ArgumentNullException.ThrowIfNull(optionsAccessor);+ ArgumentNullException.ThrowIfNull(metadataProvider);+ ArgumentNullException.ThrowIfNull(urlHelperFactory);+ ArgumentNullException.ThrowIfNull(htmlEncoder);+ ArgumentNullException.ThrowIfNull(validationAttributeProvider);_antiforgery = antiforgery;_metadataProvider = metadataProvider;@@ -146,15 +123,8 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendobject routeValues,object htmlAttributes){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }-- if (linkText == null)- {- throw new ArgumentNullException(nameof(linkText));- }+ ArgumentNullException.ThrowIfNull(viewContext);+ ArgumentNullException.ThrowIfNull(linkText);var urlHelper = _urlHelperFactory.GetUrlHelper(viewContext);var url = urlHelper.Action(actionName, controllerName, routeValues, protocol, hostname, fragment);@@ -173,15 +143,8 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendobject routeValues,object htmlAttributes){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }-- if (linkText == null)- {- throw new ArgumentNullException(nameof(linkText));- }+ ArgumentNullException.ThrowIfNull(viewContext);+ ArgumentNullException.ThrowIfNull(linkText);var urlHelper = _urlHelperFactory.GetUrlHelper(viewContext);var url = urlHelper.Page(pageName, pageHandler, routeValues, protocol, hostname, fragment);@@ -191,10 +154,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extend/// <inheritdoc />public virtual IHtmlContent GenerateAntiforgery(ViewContext viewContext){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }+ ArgumentNullException.ThrowIfNull(viewContext);var formContext = viewContext.FormContext;if (formContext.CanRenderAtEndOfForm)@@ -221,10 +181,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendbool? isChecked,object htmlAttributes){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }+ ArgumentNullException.ThrowIfNull(viewContext);if (modelExplorer != null){@@ -268,10 +225,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.ExtendModelExplorer modelExplorer,string expression){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }+ ArgumentNullException.ThrowIfNull(viewContext);var tagBuilder = new TagBuilder("input");tagBuilder.MergeAttribute("type", GetInputTypeString(InputType.Hidden));@@ -296,10 +250,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendstring method,object htmlAttributes){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }+ ArgumentNullException.ThrowIfNull(viewContext);var defaultMethod = false;if (string.IsNullOrEmpty(method))@@ -339,10 +290,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendstring method,object htmlAttributes){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }+ ArgumentNullException.ThrowIfNull(viewContext);var urlHelper = _urlHelperFactory.GetUrlHelper(viewContext);var action = urlHelper.Page(pageName, pageHandler, routeValues, protocol: null, host: null, fragment: fragment);@@ -358,10 +306,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendstring method,object htmlAttributes){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }+ ArgumentNullException.ThrowIfNull(viewContext);var urlHelper = _urlHelperFactory.GetUrlHelper(viewContext);var action = urlHelper.RouteUrl(routeName, routeValues);@@ -378,10 +323,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendbool useViewData,object htmlAttributes){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }+ ArgumentNullException.ThrowIfNull(viewContext);// Special-case opaque values and arbitrary binary data.if (value is byte[] byteArrayValue)@@ -412,15 +354,8 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendstring labelText,object htmlAttributes){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }-- if (modelExplorer == null)- {- throw new ArgumentNullException(nameof(modelExplorer));- }+ ArgumentNullException.ThrowIfNull(viewContext);+ ArgumentNullException.ThrowIfNull(modelExplorer);var resolvedLabelText = labelText ??modelExplorer.Metadata.DisplayName ??@@ -450,10 +385,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendobject value,object htmlAttributes){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }+ ArgumentNullException.ThrowIfNull(viewContext);var htmlAttributeDictionary = GetHtmlAttributeDictionaryOrNull(htmlAttributes);return GenerateInput(@@ -479,10 +411,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendbool? isChecked,object htmlAttributes){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }+ ArgumentNullException.ThrowIfNull(viewContext);var htmlAttributeDictionary = GetHtmlAttributeDictionaryOrNull(htmlAttributes);if (modelExplorer == null)@@ -550,15 +479,8 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendobject routeValues,object htmlAttributes){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }-- if (linkText == null)- {- throw new ArgumentNullException(nameof(linkText));- }+ ArgumentNullException.ThrowIfNull(viewContext);+ ArgumentNullException.ThrowIfNull(linkText);var urlHelper = _urlHelperFactory.GetUrlHelper(viewContext);var url = urlHelper.RouteUrl(routeName, routeValues, protocol, hostName, fragment);@@ -575,10 +497,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendbool allowMultiple,object htmlAttributes){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }+ ArgumentNullException.ThrowIfNull(viewContext);var currentValues = GetCurrentValues(viewContext, modelExplorer, expression, allowMultiple);return GenerateSelect(@@ -603,10 +522,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendbool allowMultiple,object htmlAttributes){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }+ ArgumentNullException.ThrowIfNull(viewContext);var fullName = NameAndIdProvider.GetFullHtmlFieldName(viewContext, expression);var htmlAttributeDictionary = GetHtmlAttributeDictionaryOrNull(htmlAttributes);@@ -661,10 +577,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendint columns,object htmlAttributes){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }+ ArgumentNullException.ThrowIfNull(viewContext);if (rows < 0){@@ -743,10 +656,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendstring format,object htmlAttributes){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }+ ArgumentNullException.ThrowIfNull(viewContext);var htmlAttributeDictionary = GetHtmlAttributeDictionaryOrNull(htmlAttributes);return GenerateInput(@@ -772,10 +682,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendstring tag,object htmlAttributes){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }+ ArgumentNullException.ThrowIfNull(viewContext);var fullName = NameAndIdProvider.GetFullHtmlFieldName(viewContext, expression);var htmlAttributeDictionary = GetHtmlAttributeDictionaryOrNull(htmlAttributes);@@ -858,10 +765,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendstring headerTag,object htmlAttributes){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }+ ArgumentNullException.ThrowIfNull(viewContext);var viewData = viewContext.ViewData;if (!viewContext.ClientValidationEnabled && viewData.ModelState.IsValid)@@ -954,10 +858,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendstring expression,bool allowMultiple){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }+ ArgumentNullException.ThrowIfNull(viewContext);var fullName = NameAndIdProvider.GetFullHtmlFieldName(viewContext, expression);var type = allowMultiple ? typeof(string[]) : typeof(string);@@ -1143,10 +1044,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendstring method,object htmlAttributes){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }+ ArgumentNullException.ThrowIfNull(viewContext);var tagBuilder = new TagBuilder("form");tagBuilder.MergeAttributes(GetHtmlAttributeDictionaryOrNull(htmlAttributes));@@ -1180,10 +1078,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendstring format,IDictionary<string, object> htmlAttributes){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }+ ArgumentNullException.ThrowIfNull(viewContext);// Not valid to use TextBoxForModel() and so on in a top-level view; would end up with an unnamed input// elements. But we support the *ForModel() methods in any lower-level template, once HtmlFieldPrefix is@@ -1308,10 +1203,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendstring url,object htmlAttributes){- if (linkText == null)- {- throw new ArgumentNullException(nameof(linkText));- }+ ArgumentNullException.ThrowIfNull(linkText);var tagBuilder = new TagBuilder("a");tagBuilder.InnerHtml.SetContent(linkText);@@ -1480,10 +1372,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.ExtendViewContext viewContext,string expression){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }+ ArgumentNullException.ThrowIfNull(viewContext);// Method is called only if user did not pass a select list in. They must provide select list items in the// ViewData dictionary and definitely not as the Model. (Even if the Model datatype were correct, adiff --git a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/ExpressionMetadataProvider.cs b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/ExpressionMetadataProvider.csindex 175f521f0..a6ef536a5 100644--- a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/ExpressionMetadataProvider.cs+++ b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/ExpressionMetadataProvider.cs@@ -3,121 +3,12 @@using Microsoft.AspNetCore.Mvc.ModelBinding;using Microsoft.AspNetCore.Mvc.ViewFeatures;-using System.Diagnostics;using System.Globalization;-using System.Linq.Expressions;-using System.Reflection;namespace Grand.Web.Common.TagHelpers.Admin.Extend{internal static class ExpressionMetadataProvider{- public static ModelExplorer FromLambdaExpression<TModel, TResult>(- Expression<Func<TModel, TResult>> expression,- ViewDataDictionary<TModel> viewData,- IModelMetadataProvider metadataProvider)- {- if (expression == null)- {- throw new ArgumentNullException(nameof(expression));- }-- if (viewData == null)- {- throw new ArgumentNullException(nameof(viewData));- }-- string propertyName = null;- Type containerType = null;- var legalExpression = false;-- // Need to verify the expression is valid; it needs to at least end in something- // that we can convert to a meaningful string for model binding purposes-- switch (expression.Body.NodeType)- {- case ExpressionType.ArrayIndex:- // ArrayIndex always means a single-dimensional indexer;- // multi-dimensional indexer is a method call to Get().- legalExpression = true;- break;-- case ExpressionType.MemberAccess:- // Property/field access is always legal- var memberExpression = (MemberExpression)expression.Body;- propertyName = memberExpression.Member is PropertyInfo ? memberExpression.Member.Name : null;- if (string.Equals(propertyName, "Model", StringComparison.Ordinal) &&- memberExpression.Type == typeof(TModel) &&- memberExpression.Expression.NodeType == ExpressionType.Constant)- {- // Special case the Model property in RazorPage<TModel>. (m => Model) should behave identically- // to (m => m). But do the more complicated thing for (m => m.Model) since that is a slightly- // different beast.)- return FromModel(viewData, metadataProvider);- }-- // memberExpression.Expression can be null when this is a static field or property.- //- // This can be the case if the expression is like (m => Person.Name) where Name is a static field- // or property on the Person type.- containerType = memberExpression.Expression?.Type;-- legalExpression = true;- break;-- case ExpressionType.Parameter:- // Parameter expression means "model => model", so we delegate to FromModel- return FromModel(viewData, metadataProvider);- }-- if (!legalExpression)- {- throw new InvalidOperationException("TemplateLimitations");- }-- object modelAccessor(object container)- {- var model = (TModel)container;- var func = expression.Compile();- try- {- return func(model);- }- catch (NullReferenceException)- {- return null;- }- }-- ModelMetadata metadata = null;- if (containerType != null && propertyName != null)- {- // Ex:- // m => m.Color (simple property access)- // m => m.Color.Red (nested property access)- // m => m.Widgets[0].Size (expression ending with property-access)- metadata = metadataProvider.GetMetadataForType(containerType).Properties[propertyName];- }-- if (metadata == null)- {- // Ex:- // m => 5 (arbitrary expression)- // m => foo (arbitrary expression)- // m => m.Widgets[0] (expression ending with non-property-access)- //- // This can also happen for any case where we cannot retrieve a model metadata.- // This will happen for:- // - fields- // - statics- // - non-visibility (internal/private)- metadata = metadataProvider.GetMetadataForType(typeof(TResult));- Debug.Assert(metadata != null);- }-- return viewData.ModelExplorer.GetExplorerForExpression(metadata, modelAccessor);- }-/// <summary>/// Gets <see cref="ModelExplorer"/> for named <paramref name="expression"/> in given/// <paramref name="viewData"/>.@@ -135,10 +26,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.ExtendViewDataDictionary viewData,IModelMetadataProvider metadataProvider){- if (viewData == null)- {- throw new ArgumentNullException(nameof(viewData));- }+ ArgumentNullException.ThrowIfNull(viewData);var viewDataInfo = ViewDataEvaluator.Eval(viewData, expression);if (viewDataInfo == null)@@ -197,10 +85,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.ExtendViewDataDictionary viewData,IModelMetadataProvider metadataProvider){- if (viewData == null)- {- throw new ArgumentNullException(nameof(viewData));- }+ ArgumentNullException.ThrowIfNull(viewData);if (viewData.ModelMetadata.ModelType == typeof(object)){diff --git a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/NameAndIdProvider.cs b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/NameAndIdProvider.csindex 26573e6a4..fec08f4c3 100644--- a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/NameAndIdProvider.cs+++ b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/NameAndIdProvider.cs@@ -28,15 +28,8 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extend/// </remarks>public static string CreateSanitizedId(ViewContext viewContext, string fullName, string invalidCharReplacement){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }-- if (invalidCharReplacement == null)- {- throw new ArgumentNullException(nameof(invalidCharReplacement));- }+ ArgumentNullException.ThrowIfNull(viewContext);+ ArgumentNullException.ThrowIfNull(invalidCharReplacement);if (string.IsNullOrEmpty(fullName)){@@ -98,20 +91,9 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendstring fullName,string invalidCharReplacement){- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }-- if (tagBuilder == null)- {- throw new ArgumentNullException(nameof(tagBuilder));- }-- if (invalidCharReplacement == null)- {- throw new ArgumentNullException(nameof(invalidCharReplacement));- }+ ArgumentNullException.ThrowIfNull(viewContext);+ ArgumentNullException.ThrowIfNull(tagBuilder);+ ArgumentNullException.ThrowIfNull(invalidCharReplacement);if (string.IsNullOrEmpty(fullName)){diff --git a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/TemplateBuilder.cs b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/TemplateBuilder.csindex 6f81e2c5e..9c2463efc 100644--- a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/TemplateBuilder.cs+++ b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/TemplateBuilder.cs@@ -37,30 +37,11 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendbool readOnly,object additionalViewData){- if (viewEngine == null)- {- throw new ArgumentNullException(nameof(viewEngine));- }-- if (bufferScope == null)- {- throw new ArgumentNullException(nameof(bufferScope));- }-- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }-- if (viewData == null)- {- throw new ArgumentNullException(nameof(viewData));- }-- if (modelExplorer == null)- {- throw new ArgumentNullException(nameof(modelExplorer));- }+ ArgumentNullException.ThrowIfNull(viewEngine);+ ArgumentNullException.ThrowIfNull(bufferScope);+ ArgumentNullException.ThrowIfNull(viewContext);+ ArgumentNullException.ThrowIfNull(viewData);+ ArgumentNullException.ThrowIfNull(modelExplorer);_viewEngine = viewEngine;_bufferScope = bufferScope;diff --git a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/TemplateRenderer.cs b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/TemplateRenderer.csindex 5be57f015..334315ff2 100644--- a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/TemplateRenderer.cs+++ b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/TemplateRenderer.cs@@ -84,25 +84,10 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendstring templateName,bool readOnly){- if (viewEngine == null)- {- throw new ArgumentNullException(nameof(viewEngine));- }-- if (bufferScope == null)- {- throw new ArgumentNullException(nameof(bufferScope));- }-- if (viewContext == null)- {- throw new ArgumentNullException(nameof(viewContext));- }-- if (viewData == null)- {- throw new ArgumentNullException(nameof(viewData));- }+ ArgumentNullException.ThrowIfNull(viewEngine);+ ArgumentNullException.ThrowIfNull(bufferScope);+ ArgumentNullException.ThrowIfNull(viewContext);+ ArgumentNullException.ThrowIfNull(viewData);_viewEngine = viewEngine;_bufferScope = bufferScope;diff --git a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/ViewBuffer.cs b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/ViewBuffer.csindex f5847ec86..48c6c5fd3 100644--- a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/ViewBuffer.cs+++ b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/ViewBuffer.cs@@ -29,15 +29,8 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extend/// <param name="pageSize">The size of buffer pages.</param>public ViewBuffer(IViewBufferScope bufferScope, string name, int pageSize){- if (bufferScope == null)- {- throw new ArgumentNullException(nameof(bufferScope));- }-- if (pageSize <= 0)- {- throw new ArgumentOutOfRangeException(nameof(pageSize));- }+ ArgumentNullException.ThrowIfNull(bufferScope);+ ArgumentOutOfRangeException.ThrowIfNegativeOrZero(pageSize);_bufferScope = bufferScope;_name = name;@@ -177,15 +170,8 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extend/// <inheritdoc />public void WriteTo(TextWriter writer, HtmlEncoder encoder){- if (writer == null)- {- throw new ArgumentNullException(nameof(writer));- }-- if (encoder == null)- {- throw new ArgumentNullException(nameof(encoder));- }+ ArgumentNullException.ThrowIfNull(writer);+ ArgumentNullException.ThrowIfNull(encoder);for (var i = 0; i < Count; i++){@@ -217,15 +203,8 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extend/// <returns>A <see cref="Task"/> which will complete once content has been written.</returns>public async Task WriteToAsync(TextWriter writer, HtmlEncoder encoder){- if (writer == null)- {- throw new ArgumentNullException(nameof(writer));- }-- if (encoder == null)- {- throw new ArgumentNullException(nameof(encoder));- }+ ArgumentNullException.ThrowIfNull(writer);+ ArgumentNullException.ThrowIfNull(encoder);for (var i = 0; i < Count; i++){@@ -263,10 +242,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendpublic void CopyTo(IHtmlContentBuilder destination){- if (destination == null)- {- throw new ArgumentNullException(nameof(destination));- }+ ArgumentNullException.ThrowIfNull(destination);for (var i = 0; i < Count; i++){@@ -295,10 +271,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extendpublic void MoveTo(IHtmlContentBuilder destination){- if (destination == null)- {- throw new ArgumentNullException(nameof(destination));- }+ ArgumentNullException.ThrowIfNull(destination);// Perf: We have an efficient implementation when the destination is another view buffer,// we can just insert our pages as-is.diff --git a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/ViewBufferTextWriter.cs b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/ViewBufferTextWriter.csindex 78f2fa844..a0209e532 100644--- a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/ViewBufferTextWriter.cs+++ b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/ViewBufferTextWriter.cs@@ -18,15 +18,8 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extend/// <param name="encoding">The <see cref="System.Text.Encoding"/>.</param>public ViewBufferTextWriter(ViewBuffer buffer, Encoding encoding){- if (buffer == null)- {- throw new ArgumentNullException(nameof(buffer));- }-- if (encoding == null)- {- throw new ArgumentNullException(nameof(encoding));- }+ ArgumentNullException.ThrowIfNull(buffer);+ ArgumentNullException.ThrowIfNull(encoding);Buffer = buffer;Encoding = encoding;@@ -43,25 +36,10 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extend/// </param>public ViewBufferTextWriter(ViewBuffer buffer, Encoding encoding, HtmlEncoder htmlEncoder, TextWriter inner){- if (buffer == null)- {- throw new ArgumentNullException(nameof(buffer));- }-- if (encoding == null)- {- throw new ArgumentNullException(nameof(encoding));- }-- if (htmlEncoder == null)- {- throw new ArgumentNullException(nameof(htmlEncoder));- }-- if (inner == null)- {- throw new ArgumentNullException(nameof(inner));- }+ ArgumentNullException.ThrowIfNull(buffer);+ ArgumentNullException.ThrowIfNull(encoding);+ ArgumentNullException.ThrowIfNull(htmlEncoder);+ ArgumentNullException.ThrowIfNull(inner);Buffer = buffer;Encoding = encoding;@@ -96,10 +74,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extend/// <inheritdoc />public override void Write(char[] buffer, int index, int count){- if (buffer == null)- {- throw new ArgumentNullException(nameof(buffer));- }+ ArgumentNullException.ThrowIfNull(buffer);if (index < 0 || index >= buffer.Length){@@ -243,15 +218,9 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extend/// <inheritdoc />public override Task WriteAsync(char[] buffer, int index, int count){- if (buffer == null)- {- throw new ArgumentNullException(nameof(buffer));- }-- if (index < 0)- {- throw new ArgumentOutOfRangeException(nameof(index));- }+ ArgumentNullException.ThrowIfNull(buffer);+ ArgumentOutOfRangeException.ThrowIfNegative(index);+if (count < 0 || buffer.Length - index < count){throw new ArgumentOutOfRangeException(nameof(count));diff --git a/src/Web/Grand.Web.Common/TagHelpers/GenerateCaptchaTagHelper.cs b/src/Web/Grand.Web.Common/TagHelpers/GenerateCaptchaTagHelper.csindex e7aedd399..a7765a5e7 100644--- a/src/Web/Grand.Web.Common/TagHelpers/GenerateCaptchaTagHelper.cs+++ b/src/Web/Grand.Web.Common/TagHelpers/GenerateCaptchaTagHelper.cs@@ -26,15 +26,8 @@ namespace Grand.Web.Common.TagHelperspublic override void Process(TagHelperContext context, TagHelperOutput output){- if (context == null)- {- throw new ArgumentNullException(nameof(context));- }-- if (output == null)- {- throw new ArgumentNullException(nameof(output));- }+ ArgumentNullException.ThrowIfNull(context);+ ArgumentNullException.ThrowIfNull(output);//contextualize IHtmlHelpervar viewContextAware = _htmlHelper as IViewContextAware;diff --git a/src/Web/Grand.Web.Vendor/Extensions/AddressMappingExtensions.cs b/src/Web/Grand.Web.Vendor/Extensions/AddressMappingExtensions.csindex 7bca1b446..9e7afaacc 100644--- a/src/Web/Grand.Web.Vendor/Extensions/AddressMappingExtensions.cs+++ b/src/Web/Grand.Web.Vendor/Extensions/AddressMappingExtensions.cs@@ -37,12 +37,8 @@ namespace Grand.Web.Vendor.ExtensionsIAddressAttributeService addressAttributeService,IAddressAttributeParser addressAttributeParser){- //this method is very similar to the same one in Grand.Web project- if (addressAttributeService == null)- throw new ArgumentNullException(nameof(addressAttributeService));-- if (addressAttributeParser == null)- throw new ArgumentNullException(nameof(addressAttributeParser));+ ArgumentNullException.ThrowIfNull(addressAttributeService);+ ArgumentNullException.ThrowIfNull(addressAttributeParser);var attributes = await addressAttributeService.GetAllAddressAttributes();foreach (var attribute in attributes)@@ -129,8 +125,7 @@ namespace Grand.Web.Vendor.ExtensionsIAddressAttributeParser addressAttributeParser,IAddressAttributeService addressAttributeService){- if (address == null)- throw new ArgumentNullException(nameof(address));+ ArgumentNullException.ThrowIfNull(address);var customAttributes = new List<CustomAttribute>();var attributes = await addressAttributeService.GetAllAddressAttributes();diff --git a/src/Web/Grand.Web.Vendor/Extensions/HasAccess.cs b/src/Web/Grand.Web.Vendor/Extensions/HasAccess.csindex c22d0b33e..52dad6735 100644--- a/src/Web/Grand.Web.Vendor/Extensions/HasAccess.cs+++ b/src/Web/Grand.Web.Vendor/Extensions/HasAccess.cs@@ -9,16 +9,14 @@ namespace Grand.Web.Vendor.Extensions{public static bool HasAccessToProduct(this IWorkContext workContext, Product product){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);return product.VendorId == workContext.CurrentVendor.Id;}public static bool HasAccessToOrder(this IWorkContext workContext, Order order){- if (order == null)- throw new ArgumentNullException(nameof(order));+ ArgumentNullException.ThrowIfNull(order);var hasVendorProducts = order.OrderItems.Any(orderItem => orderItem.VendorId == workContext.CurrentVendor.Id);return hasVendorProducts;@@ -26,16 +24,14 @@ namespace Grand.Web.Vendor.Extensionspublic static bool HasAccessToOrderItem(this IWorkContext workContext, OrderItem orderItem){- if (orderItem == null)- throw new ArgumentNullException(nameof(orderItem));+ ArgumentNullException.ThrowIfNull(orderItem);return orderItem.VendorId == workContext.CurrentVendor.Id;}public static bool HasAccessToShipment(this IWorkContext workContext, Shipment shipment){- if (shipment == null)- throw new ArgumentNullException(nameof(shipment));-+ ArgumentNullException.ThrowIfNull(shipment);+return shipment.VendorId == workContext.CurrentVendor.Id;}}diff --git a/src/Web/Grand.Web.Vendor/Extensions/ProductExtensions.cs b/src/Web/Grand.Web.Vendor/Extensions/ProductExtensions.csindex ac9facdbe..6f430afcc 100644--- a/src/Web/Grand.Web.Vendor/Extensions/ProductExtensions.cs+++ b/src/Web/Grand.Web.Vendor/Extensions/ProductExtensions.cs@@ -19,10 +19,8 @@ namespace Grand.Web.Vendor.Extensionspublic static async Task<Picture> GetProductPicture(this Product product, IList<CustomAttribute> attributes,IProductService productService, IPictureService pictureService){- if (product == null)- throw new ArgumentNullException(nameof(product));- if (pictureService == null)- throw new ArgumentNullException(nameof(pictureService));+ ArgumentNullException.ThrowIfNull(product);+ ArgumentNullException.ThrowIfNull(pictureService);Picture picture = null;diff --git a/src/Web/Grand.Web.Vendor/Services/MerchandiseReturnViewModelService.cs b/src/Web/Grand.Web.Vendor/Services/MerchandiseReturnViewModelService.csindex 72b286050..4f440787e 100644--- a/src/Web/Grand.Web.Vendor/Services/MerchandiseReturnViewModelService.cs+++ b/src/Web/Grand.Web.Vendor/Services/MerchandiseReturnViewModelService.cs@@ -83,11 +83,8 @@ namespace Grand.Web.Vendor.Servicespublic virtual async Task<MerchandiseReturnModel> PrepareMerchandiseReturnModel(MerchandiseReturnModel model,MerchandiseReturn merchandiseReturn, bool excludeProperties){- if (model == null)- throw new ArgumentNullException(nameof(model));-- if (merchandiseReturn == null)- throw new ArgumentNullException(nameof(merchandiseReturn));+ ArgumentNullException.ThrowIfNull(model);+ ArgumentNullException.ThrowIfNull(merchandiseReturn);var order = await _orderService.GetOrderById(merchandiseReturn.OrderId);double unitPriceInclTaxInCustomerCurrency = 0;diff --git a/src/Web/Grand.Web.Vendor/Services/OrderViewModelService.cs b/src/Web/Grand.Web.Vendor/Services/OrderViewModelService.csindex 129ebf954..a7ccb64e4 100644--- a/src/Web/Grand.Web.Vendor/Services/OrderViewModelService.cs+++ b/src/Web/Grand.Web.Vendor/Services/OrderViewModelService.cs@@ -264,11 +264,8 @@ namespace Grand.Web.Vendor.Services}public virtual async Task PrepareOrderDetailsModel(OrderModel model, Order order){- if (order == null)- throw new ArgumentNullException(nameof(order));-- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(order);+ ArgumentNullException.ThrowIfNull(model);model.Id = order.Id;model.OrderNumber = order.OrderNumber;diff --git a/src/Web/Grand.Web.Vendor/Services/ProductViewModelService.cs b/src/Web/Grand.Web.Vendor/Services/ProductViewModelService.csindex e55eb6a04..d19379645 100644--- a/src/Web/Grand.Web.Vendor/Services/ProductViewModelService.cs+++ b/src/Web/Grand.Web.Vendor/Services/ProductViewModelService.cs@@ -169,10 +169,9 @@ namespace Grand.Web.Vendor.Servicespublic virtual async Task PrepareAddProductAttributeCombinationModel(ProductAttributeCombinationModel model,Product product){- if (model == null)- throw new ArgumentNullException(nameof(model));- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(model);+ ArgumentNullException.ThrowIfNull(product);+if (product.UseMultipleWarehouses){model.UseMultipleWarehouses = product.UseMultipleWarehouses;@@ -359,8 +358,7 @@ namespace Grand.Web.Vendor.Servicespublic virtual async Task PrepareProductModel(ProductModel model, Product product,bool setPredefinedValues){- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(model);model.PrimaryStoreCurrencyCode =(await _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId))?.CurrencyCode;@@ -523,8 +521,7 @@ namespace Grand.Web.Vendor.Servicespublic virtual async Task SaveProductWarehouseInventory(Product product,IList<ProductModel.ProductWarehouseInventoryModel> model){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);if (product.ManageInventoryMethodId != ManageInventoryMethod.ManageStock)return;@@ -577,11 +574,10 @@ namespace Grand.Web.Vendor.Servicespublic virtual async Task PrepareProductReviewModel(ProductReviewModel model,ProductReview productReview, bool excludeProperties, bool formatReviewText){- if (model == null)- throw new ArgumentNullException(nameof(model));-- if (productReview == null)- throw new ArgumentNullException(nameof(productReview));+ ArgumentNullException.ThrowIfNull(model);+ ArgumentNullException.ThrowIfNull(model);+ ArgumentNullException.ThrowIfNull(productReview);+var product = await _productService.GetProductById(productReview.ProductId);var customer = await _customerService.GetCustomerById(productReview.CustomerId);var store = await _storeService.GetStoreById(productReview.StoreId);diff --git a/src/Web/Grand.Web.Vendor/Services/VendorReviewViewModelService.cs b/src/Web/Grand.Web.Vendor/Services/VendorReviewViewModelService.csindex 2dbddc0f8..fbd162ae4 100644--- a/src/Web/Grand.Web.Vendor/Services/VendorReviewViewModelService.cs+++ b/src/Web/Grand.Web.Vendor/Services/VendorReviewViewModelService.cs@@ -40,11 +40,8 @@ namespace Grand.Web.Vendor.Servicespublic virtual async Task PrepareVendorReviewModel(VendorReviewModel model,VendorReview vendorReview, bool excludeProperties, bool formatReviewText){- if (model == null)- throw new ArgumentNullException(nameof(model));-- if (vendorReview == null)- throw new ArgumentNullException(nameof(vendorReview));+ ArgumentNullException.ThrowIfNull(model);+ ArgumentNullException.ThrowIfNull(vendorReview);var customer = await _customerService.GetCustomerById(vendorReview.CustomerId);diff --git a/src/Web/Grand.Web/Commands/Handler/Customers/CustomerRegisteredCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Customers/CustomerRegisteredCommandHandler.csindex 7096aa5a7..88f139ab3 100644--- a/src/Web/Grand.Web/Commands/Handler/Customers/CustomerRegisteredCommandHandler.cs+++ b/src/Web/Grand.Web/Commands/Handler/Customers/CustomerRegisteredCommandHandler.cs@@ -203,8 +203,7 @@ namespace Grand.Web.Commands.Handler.Customers/// <returns>Result</returns>private async Task<bool> IsAddressValid(Address address){- if (address == null)- throw new ArgumentNullException(nameof(address));+ ArgumentNullException.ThrowIfNull(address);if (string.IsNullOrWhiteSpace(address.FirstName))return false;diff --git a/src/Web/Grand.Web/Controllers/CommonController.cs b/src/Web/Grand.Web/Controllers/CommonController.csindex 365ad5bed..a0d733e23 100644--- a/src/Web/Grand.Web/Controllers/CommonController.cs+++ b/src/Web/Grand.Web/Controllers/CommonController.cs@@ -84,8 +84,7 @@ namespace Grand.Web.Controllersprivate static string AddLanguageSeo(string url, Language language){- if (language == null)- throw new ArgumentNullException(nameof(language));+ ArgumentNullException.ThrowIfNull(language);if (!string.IsNullOrEmpty(url)){diff --git a/src/Web/Grand.Web/Extensions/KnowledgebaseExtensions.cs b/src/Web/Grand.Web/Extensions/KnowledgebaseExtensions.csindex f8b26de46..e3aa8ed9c 100644--- a/src/Web/Grand.Web/Extensions/KnowledgebaseExtensions.cs+++ b/src/Web/Grand.Web/Extensions/KnowledgebaseExtensions.cs@@ -23,8 +23,7 @@ namespace Grand.Web.ExtensionsIWorkContext workContext,bool showHidden = false){- if (category == null)- throw new ArgumentNullException(nameof(category));+ ArgumentNullException.ThrowIfNull(category);var result = new List<KnowledgebaseCategory>();@@ -76,8 +75,7 @@ namespace Grand.Web.Extensions}public static IList<KnowledgebaseCategory> GetCategoryBreadCrumb(this KnowledgebaseCategory category, IList<KnowledgebaseCategory> allCategories){- if (category == null)- throw new ArgumentNullException(nameof(category));+ ArgumentNullException.ThrowIfNull(category);var result = new List<KnowledgebaseCategory>();diff --git a/src/Web/Grand.Web/Extensions/ProductExtensions.cs b/src/Web/Grand.Web/Extensions/ProductExtensions.csindex 28a412053..84f06b8c6 100644--- a/src/Web/Grand.Web/Extensions/ProductExtensions.cs+++ b/src/Web/Grand.Web/Extensions/ProductExtensions.cs@@ -20,10 +20,8 @@ namespace Grand.Web.Extensionspublic static async Task<Picture> GetProductPicture(this Product product, IList<CustomAttribute> attributes,IProductService productService, IPictureService pictureService){- if (product == null)- throw new ArgumentNullException(nameof(product));- if (pictureService == null)- throw new ArgumentNullException(nameof(pictureService));+ ArgumentNullException.ThrowIfNull(product);+ ArgumentNullException.ThrowIfNull(pictureService);Picture picture = null;diff --git a/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostListHandler.cs b/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostListHandler.csindex c5d34af52..df889cefa 100644--- a/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostListHandler.cs+++ b/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostListHandler.cs@@ -96,11 +96,8 @@ namespace Grand.Web.Features.Handlers.Blogsprivate async Task PrepareBlogPostModel(BlogPostModel model, BlogPost blogPost){- if (blogPost == null)- throw new ArgumentNullException(nameof(blogPost));-- if (model == null)- throw new ArgumentNullException(nameof(model));+ ArgumentNullException.ThrowIfNull(blogPost);+ ArgumentNullException.ThrowIfNull(model);model.Id = blogPost.Id;model.MetaTitle = blogPost.GetTranslation(x => x.MetaTitle, _workContext.WorkingLanguage.Id);diff --git a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.csindex eaa5d5c4c..2913f9906 100644--- a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs+++ b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs@@ -149,8 +149,7 @@ namespace Grand.Web.Features.Handlers.Productsprivate async Task<ProductDetailsModel> PrepareProductDetailsModel(Store store, Product product,ShoppingCartItem updateCartItem, bool isAssociatedProduct){- if (product == null)- throw new ArgumentNullException(nameof(product));+ ArgumentNullException.ThrowIfNull(product);var model = await PrepareStandardProperties(product, updateCartItem);