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
Remove RepositoryExtensions
KrzysztofPajak10d6db8f459f
diff --git a/src/Business/Grand.Business.Authentication/Services/ExternalAuthenticationService.cs b/src/Business/Grand.Business.Authentication/Services/ExternalAuthenticationService.csindex fadd9bc70..bc3329c27 100644--- a/src/Business/Grand.Business.Authentication/Services/ExternalAuthenticationService.cs+++ b/src/Business/Grand.Business.Authentication/Services/ExternalAuthenticationService.cs@@ -336,7 +336,7 @@ namespace Grand.Business.Authentication.Servicesvar query = from p in _externalAuthenticationRecordRepository.Tablewhere p.CustomerId == customer.Idselect p;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}/// <summary>diff --git a/src/Business/Grand.Business.Catalog/Events/Handlers/UpdateProductOnCartEventHandler.cs b/src/Business/Grand.Business.Catalog/Events/Handlers/UpdateProductOnCartEventHandler.csindex 58aca5c8b..c36e1bf44 100644--- a/src/Business/Grand.Business.Catalog/Events/Handlers/UpdateProductOnCartEventHandler.cs+++ b/src/Business/Grand.Business.Catalog/Events/Handlers/UpdateProductOnCartEventHandler.cs@@ -19,7 +19,7 @@ namespace Grand.Business.Catalog.Events.Handlerspublic async Task Handle(UpdateProductOnCartEvent notification, CancellationToken cancellationToken){- var customers = await _customerRepository.Table.Where(x => x.ShoppingCartItems.Any(y => y.ProductId == notification.Product.Id)).ToListAsync2();+ var customers = _customerRepository.Table.Where(x => x.ShoppingCartItems.Any(y => y.ProductId == notification.Product.Id)).ToList();foreach (var cs in customers){foreach (var item in cs.ShoppingCartItems.Where(x => x.ProductId == notification.Product.Id))diff --git a/src/Business/Grand.Business.Catalog/Queries/Handlers/GetPersonalizedProductsQueryHandler.cs b/src/Business/Grand.Business.Catalog/Queries/Handlers/GetPersonalizedProductsQueryHandler.csindex 5b67503b2..36ee53d8c 100644--- a/src/Business/Grand.Business.Catalog/Queries/Handlers/GetPersonalizedProductsQueryHandler.cs+++ b/src/Business/Grand.Business.Catalog/Queries/Handlers/GetPersonalizedProductsQueryHandler.cs@@ -39,7 +39,7 @@ namespace Grand.Business.Catalog.Queries.Handlersorderby cr.DisplayOrderselect cr.ProductId;- var productIds = await query.Take(request.ProductsNumber).ToListAsync2();+ var productIds = query.Take(request.ProductsNumber).ToList();var products = new List<Product>();var ids = await _productService.GetProductsByIds(productIds.Distinct().ToArray());diff --git a/src/Business/Grand.Business.Catalog/Queries/Handlers/GetRecommendedProductsQueryHandler.cs b/src/Business/Grand.Business.Catalog/Queries/Handlers/GetRecommendedProductsQueryHandler.csindex 8976e4b67..364b30ebc 100644--- a/src/Business/Grand.Business.Catalog/Queries/Handlers/GetRecommendedProductsQueryHandler.cs+++ b/src/Business/Grand.Business.Catalog/Queries/Handlers/GetRecommendedProductsQueryHandler.cs@@ -39,7 +39,7 @@ namespace Grand.Business.Catalog.Queries.Handlersorderby cr.DisplayOrderselect cr.ProductId;- var productIds = await query.ToListAsync2();+ var productIds = query.ToList();var products = new List<Product>();var ids = await _productService.GetProductsByIds(productIds.Distinct().ToArray());diff --git a/src/Business/Grand.Business.Catalog/Queries/Handlers/GetSearchProductsQueryHandler.cs b/src/Business/Grand.Business.Catalog/Queries/Handlers/GetSearchProductsQueryHandler.csindex 44fbb907a..500f6b84f 100644--- a/src/Business/Grand.Business.Catalog/Queries/Handlers/GetSearchProductsQueryHandler.cs+++ b/src/Business/Grand.Business.Catalog/Queries/Handlers/GetSearchProductsQueryHandler.cs@@ -334,7 +334,7 @@ namespace Grand.Business.Catalog.Queries.Handlersfrom item in p.ProductSpecificationAttributesselect item;- var groupQuerySpec = await qspec.Where(x=>x.AllowFiltering).GroupBy(x => new { SpecificationAttributeOptionId = x.SpecificationAttributeOptionId }).ToListAsync2();+ var groupQuerySpec = qspec.Where(x=>x.AllowFiltering).GroupBy(x => new { SpecificationAttributeOptionId = x.SpecificationAttributeOptionId }).ToList();foreach (var item in groupQuerySpec){specyfication.Add(item.Key.SpecificationAttributeOptionId);diff --git a/src/Business/Grand.Business.Catalog/Queries/Handlers/GetSuggestedProductsQueryHandler.cs b/src/Business/Grand.Business.Catalog/Queries/Handlers/GetSuggestedProductsQueryHandler.csindex 787d81445..ca3cc0a08 100644--- a/src/Business/Grand.Business.Catalog/Queries/Handlers/GetSuggestedProductsQueryHandler.cs+++ b/src/Business/Grand.Business.Catalog/Queries/Handlers/GetSuggestedProductsQueryHandler.cs@@ -42,7 +42,7 @@ namespace Grand.Business.Catalog.Queries.Handlersorderby cr.DisplayOrderselect cr.ProductId;- var productIds = await query.Take(request.ProductsNumber).ToListAsync2();+ var productIds = query.Take(request.ProductsNumber).ToList();var products = new List<Product>();var ids = await _productService.GetProductsByIds(productIds.Distinct().ToArray());diff --git a/src/Business/Grand.Business.Catalog/Services/Brands/BrandLayoutService.cs b/src/Business/Grand.Business.Catalog/Services/Brands/BrandLayoutService.csindex 96ddd2fb7..151d46692 100644--- a/src/Business/Grand.Business.Catalog/Services/Brands/BrandLayoutService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Brands/BrandLayoutService.cs@@ -52,12 +52,12 @@ namespace Grand.Business.Catalog.Services.Brands/// <returns>Brand layouts</returns>public virtual async Task<IList<BrandLayout>> GetAllBrandLayouts(){- return await _cacheBase.GetAsync(CacheKey.BRAND_LAYOUT_ALL, () =>+ return await _cacheBase.GetAsync(CacheKey.BRAND_LAYOUT_ALL, async () =>{var query = from pt in _brandLayoutRepository.Tableorderby pt.DisplayOrderselect pt;- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}diff --git a/src/Business/Grand.Business.Catalog/Services/Brands/BrandService.cs b/src/Business/Grand.Business.Catalog/Services/Brands/BrandService.csindex 9aa25dc21..56e08e58c 100644--- a/src/Business/Grand.Business.Catalog/Services/Brands/BrandService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Brands/BrandService.cs@@ -170,7 +170,7 @@ namespace Grand.Business.Catalog.Services.Brandswhere c.AppliedDiscounts.Any(x => x == discountId)select c;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}#endregiondiff --git a/src/Business/Grand.Business.Catalog/Services/Categories/CategoryLayoutService.cs b/src/Business/Grand.Business.Catalog/Services/Categories/CategoryLayoutService.csindex 973e93026..79ab20e7f 100644--- a/src/Business/Grand.Business.Catalog/Services/Categories/CategoryLayoutService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Categories/CategoryLayoutService.cs@@ -52,12 +52,12 @@ namespace Grand.Business.Catalog.Services.Categories/// <returns>Category layouts</returns>public virtual async Task<IList<CategoryLayout>> GetAllCategoryLayouts(){- return await _cacheBase.GetAsync(CacheKey.CATEGORY_LAYOUT_ALL, () =>+ return await _cacheBase.GetAsync(CacheKey.CATEGORY_LAYOUT_ALL, async () =>{var query = from pt in _categoryLayoutRepository.Tableorderby pt.DisplayOrderselect pt;- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}diff --git a/src/Business/Grand.Business.Catalog/Services/Categories/CategoryService.cs b/src/Business/Grand.Business.Catalog/Services/Categories/CategoryService.csindex e09807a8b..01e4597d9 100644--- a/src/Business/Grand.Business.Catalog/Services/Categories/CategoryService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Categories/CategoryService.cs@@ -137,7 +137,7 @@ namespace Grand.Business.Catalog.Services.Categoriesselect p;}}- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}/// <summary>@@ -203,7 +203,7 @@ namespace Grand.Business.Catalog.Services.Categoriesvar query = _categoryRepository.Table.Where(x => x.Published && x.ShowOnHomePage).OrderBy(x => x.DisplayOrder);- var categories = await query.ToListAsync2();+ var categories = await Task.FromResult(query.ToList());if (!showHidden){categories = categories@@ -225,7 +225,7 @@ namespace Grand.Business.Catalog.Services.Categories.Where(x => x.Published && x.FeaturedProductsOnHomePage).OrderBy(x => x.DisplayOrder);- var categories = await query.ToListAsync2();+ var categories = await Task.FromResult(query.ToList());if (!showHidden){categories = categories@@ -246,7 +246,7 @@ namespace Grand.Business.Catalog.Services.Categories.Where(x => x.Published && x.ShowOnSearchBox).OrderBy(x => x.SearchBoxDisplayOrder);- var categories = (await query.ToListAsync2())+ var categories = (await Task.FromResult(query.ToList())).Where(c => _aclService.Authorize(c, _workContext.CurrentCustomer) && _aclService.Authorize(c, _workContext.CurrentStore.Id)).ToList();@@ -376,7 +376,7 @@ namespace Grand.Business.Catalog.Services.Categorieswhere c.AppliedDiscounts.Any(x => x == discountId)select c;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}/// <summary>diff --git a/src/Business/Grand.Business.Catalog/Services/Collections/CollectionLayoutService.cs b/src/Business/Grand.Business.Catalog/Services/Collections/CollectionLayoutService.csindex 21878010e..c66792be5 100644--- a/src/Business/Grand.Business.Catalog/Services/Collections/CollectionLayoutService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Collections/CollectionLayoutService.cs@@ -52,12 +52,12 @@ namespace Grand.Business.Catalog.Services.Collections/// <returns>Collection layouts</returns>public virtual async Task<IList<CollectionLayout>> GetAllCollectionLayouts(){- return await _cacheBase.GetAsync(CacheKey.COLLECTION_LAYOUT_ALL, () =>+ return await _cacheBase.GetAsync(CacheKey.COLLECTION_LAYOUT_ALL, async () =>{var query = from pt in _collectionLayoutRepository.Tableorderby pt.DisplayOrderselect pt;- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}diff --git a/src/Business/Grand.Business.Catalog/Services/Collections/CollectionService.cs b/src/Business/Grand.Business.Catalog/Services/Collections/CollectionService.csindex 1d6f234c1..32e99a995 100644--- a/src/Business/Grand.Business.Catalog/Services/Collections/CollectionService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Collections/CollectionService.cs@@ -110,7 +110,7 @@ namespace Grand.Business.Catalog.Services.Collections{var query = _collectionRepository.Table.Where(x=>x.Published && x.FeaturedProductsOnHomePage).OrderBy(x => x.DisplayOrder);- var collections = await query.ToListAsync2();+ var collections = await Task.FromResult(query.ToList());if (!showHidden){collections = collections@@ -198,7 +198,7 @@ namespace Grand.Business.Catalog.Services.Collectionswhere c.AppliedDiscounts.Any(x => x == discountId)select c;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}#endregiondiff --git a/src/Business/Grand.Business.Catalog/Services/Discounts/DiscountService.cs b/src/Business/Grand.Business.Catalog/Services/Discounts/DiscountService.csindex 9020a7aa2..87168e1da 100644--- a/src/Business/Grand.Business.Catalog/Services/Discounts/DiscountService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Discounts/DiscountService.cs@@ -90,7 +90,7 @@ namespace Grand.Business.Catalog.Services.Discountsstring storeId = "", string currencyCode = "", string couponCode = "", string discountName = "", bool showHidden = false){string key = string.Format(CacheKey.DISCOUNTS_ALL_KEY, showHidden, storeId, currencyCode, couponCode, discountName);- var result = await _cacheBase.GetAsync(key, () =>+ var result = await _cacheBase.GetAsync(key, async () =>{var query = from m in _discountRepository.Tableselect m;@@ -125,7 +125,7 @@ namespace Grand.Business.Catalog.Services.Discounts}query = query.OrderBy(d => d.Name);- var discounts = query.ToListAsync2();+ var discounts = await Task.FromResult(query.ToList());return discounts;});if (discountType.HasValue)@@ -260,7 +260,7 @@ namespace Grand.Business.Catalog.Services.Discountsif (String.IsNullOrWhiteSpace(couponCode))return null;- var query = await _discountCouponRepository.Table.Where(x => x.CouponCode == couponCode).ToListAsync2();+ var query = _discountCouponRepository.Table.Where(x => x.CouponCode == couponCode).ToList();var coupon = query.FirstOrDefault();if (coupon == null)@@ -287,7 +287,7 @@ namespace Grand.Business.Catalog.Services.Discountsif (used.HasValue)query = query.Where(x => x.Used == used.Value);- var result = await query.ToListAsync2();+ var result = await Task.FromResult(query.ToList());if (result.Any())return true;@@ -332,7 +332,7 @@ namespace Grand.Business.Catalog.Services.Discounts/// <returns></returns>public async Task<DiscountCoupon> GetDiscountCodeByCode(string couponCode){- var query = await _discountCouponRepository.Table.Where(x => x.CouponCode == couponCode).ToListAsync2();+ var query = await Task.FromResult(_discountCouponRepository.Table.Where(x => x.CouponCode == couponCode).ToList());return query.FirstOrDefault();}@@ -387,7 +387,7 @@ namespace Grand.Business.Catalog.Services.Discounts/// <param name="orderId"></param>public virtual async Task CancelDiscount(string orderId){- var discountUsage = await _discountUsageHistoryRepository.Table.Where(x => x.OrderId == orderId).ToListAsync2();+ var discountUsage = _discountUsageHistoryRepository.Table.Where(x => x.OrderId == orderId).ToList();foreach (var item in discountUsage){await DiscountCouponSetAsUsed(item.CouponCode, false);diff --git a/src/Business/Grand.Business.Catalog/Services/Products/AuctionService.cs b/src/Business/Grand.Business.Catalog/Services/Products/AuctionService.csindex b70720832..549f43e4d 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/AuctionService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/AuctionService.cs@@ -45,12 +45,12 @@ namespace Grand.Business.Catalog.Services.Productspublic virtual async Task<Bid> GetLatestBid(string productId){- var bid = await _bidRepository.Table+ var bid = _bidRepository.Table.Where(x=>x.ProductId == productId).OrderByDescending(x => x.Date)- .ToListAsync2();+ .ToList();- return bid.FirstOrDefault();+ return await Task.FromResult(bid.FirstOrDefault());}public virtual async Task<IPagedList<Bid>> GetBidsByProductId(string productId, int pageIndex = 0, int pageSize = int.MaxValue)@@ -113,10 +113,9 @@ namespace Grand.Business.Catalog.Services.Productspublic virtual async Task<IList<Product>> GetAuctionsToEnd(){- return await _productRepository.Table+ return await Task.FromResult(_productRepository.Table.Where(x => x.ProductTypeId == ProductType.Auction &&- !x.AuctionEnded && x.AvailableEndDateTimeUtc < DateTime.UtcNow)- .ToListAsync2();+ !x.AuctionEnded && x.AvailableEndDateTimeUtc < DateTime.UtcNow).ToList());}public virtual async Task UpdateAuctionEnded(Product product, bool ended, bool enddate = false)diff --git a/src/Business/Grand.Business.Catalog/Services/Products/CustomerGroupProductService.cs b/src/Business/Grand.Business.Catalog/Services/Products/CustomerGroupProductService.csindex a6c5b883c..fa524fd66 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/CustomerGroupProductService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/CustomerGroupProductService.cs@@ -97,9 +97,12 @@ namespace Grand.Business.Catalog.Services.Productspublic virtual async Task<IList<CustomerGroupProduct>> GetCustomerGroupProducts(string customerGroupId){string key = string.Format(CacheKey.CUSTOMERGROUPSPRODUCTS_ROLE_KEY, customerGroupId);- return await _cacheBase.GetAsync(key, () =>+ return await _cacheBase.GetAsync(key, async () =>{- return _customerGroupProductRepository.Table.Where(x => x.CustomerGroupId == customerGroupId).OrderBy(x => x.DisplayOrder).ToListAsync2();+ return await Task.FromResult(_customerGroupProductRepository+ .Table.Where(x => x.CustomerGroupId == customerGroupId)+ .OrderBy(x => x.DisplayOrder)+ .ToList());});}diff --git a/src/Business/Grand.Business.Catalog/Services/Products/OutOfStockSubscriptionService.cs b/src/Business/Grand.Business.Catalog/Services/Products/OutOfStockSubscriptionService.csindex 45d3a90fe..be4bccc18 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/OutOfStockSubscriptionService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/OutOfStockSubscriptionService.cs@@ -91,7 +91,7 @@ namespace Grand.Business.Catalog.Services.Productsbiss.WarehouseId == warehouseIdselect biss;- var outOfStockSubscriptionlist = await query.ToListAsync2();+ var outOfStockSubscriptionlist = await Task.FromResult(query.ToList());if (attributes != null && attributes.Any())outOfStockSubscriptionlist = outOfStockSubscriptionlist.Where(x => x.Attributes.All(y => attributes.Any(z => z.Key == y.Key && z.Value == y.Value))).ToList();diff --git a/src/Business/Grand.Business.Catalog/Services/Products/ProductAttributeService.cs b/src/Business/Grand.Business.Catalog/Services/Products/ProductAttributeService.csindex e3da9c9ba..4f1ecd83c 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/ProductAttributeService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/ProductAttributeService.cs@@ -337,9 +337,7 @@ namespace Grand.Business.Catalog.Services.Products/// <returns>Product attribute mapping collection</returns>public virtual async Task<IList<PredefinedProductAttributeValue>> GetPredefinedProductAttributeValues(string productAttributeId){- var pa = await _productAttributeRepository.Table.Where(x => x.Id == productAttributeId)- .FirstOrDefaultAsync2();-+ var pa = await Task.FromResult(_productAttributeRepository.Table.Where(x => x.Id == productAttributeId).FirstOrDefault());return pa.PredefinedProductAttributeValues.OrderBy(x => x.DisplayOrder).ToList();}diff --git a/src/Business/Grand.Business.Catalog/Services/Products/ProductCourseService.cs b/src/Business/Grand.Business.Catalog/Services/Products/ProductCourseService.csindex 832e961c1..4269016a3 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/ProductCourseService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/ProductCourseService.cs@@ -21,12 +21,12 @@ namespace Grand.Business.Catalog.Services.Productspublic virtual async Task<Course> GetCourseByProductId(string productId){- return await _courseRepository.Table.Where(p => p.ProductId == productId).FirstOrDefaultAsync2();+ return await Task.FromResult(_courseRepository.Table.Where(p => p.ProductId == productId).FirstOrDefault());}public virtual async Task<Product> GetProductByCourseId(string courseId){- return await _productRepository.Table.Where(p => p.CourseId == courseId).FirstOrDefaultAsync2();+ return await Task.FromResult(_productRepository.Table.Where(p => p.CourseId == courseId).FirstOrDefault());}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 c505ddaf6..b4652ac9e 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/ProductLayoutService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/ProductLayoutService.cs@@ -53,12 +53,12 @@ namespace Grand.Business.Catalog.Services.Products/// <returns>Product layouts</returns>public virtual async Task<IList<ProductLayout>> GetAllProductLayouts(){- return await _cacheBase.GetAsync(CacheKey.PRODUCT_LAYOUT_ALL, () =>+ return await _cacheBase.GetAsync(CacheKey.PRODUCT_LAYOUT_ALL, async () =>{var query = from pt in _productLayoutRepository.Tableorderby pt.DisplayOrderselect pt;- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}diff --git a/src/Business/Grand.Business.Catalog/Services/Products/ProductReservationService.cs b/src/Business/Grand.Business.Catalog/Services/Products/ProductReservationService.csindex 2413b1911..3b3df58ac 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/ProductReservationService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/ProductReservationService.cs@@ -180,7 +180,7 @@ namespace Grand.Business.Catalog.Services.Products/// <returns>List<CustomerReservationsHelper></returns>public virtual async Task<IList<CustomerReservationsHelper>> GetCustomerReservationsHelpers(string customerId){- return await _customerReservationsHelperRepository.Table.Where(x => x.CustomerId == customerId).ToListAsync2();+ return await Task.FromResult(_customerReservationsHelperRepository.Table.Where(x => x.CustomerId == customerId).ToList());}/// <summary>@@ -190,7 +190,7 @@ namespace Grand.Business.Catalog.Services.Products/// <returns>List<CustomerReservationsHelper></returns>public virtual async Task<IList<CustomerReservationsHelper>> GetCustomerReservationsHelperBySciId(string sciId){- return await _customerReservationsHelperRepository.Table.Where(x => x.ShoppingCartItemId == sciId).ToListAsync2();+ return await Task.FromResult(_customerReservationsHelperRepository.Table.Where(x => x.ShoppingCartItemId == sciId).ToList());}}}diff --git a/src/Business/Grand.Business.Catalog/Services/Products/ProductService.cs b/src/Business/Grand.Business.Catalog/Services/Products/ProductService.csindex bac4c81dc..b0fd79d3e 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/ProductService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/ProductService.cs@@ -69,9 +69,7 @@ namespace Grand.Business.Catalog.Services.Productsvar query = _productRepository.Table.Where(x => x.Published && x.ShowOnHomePage && x.VisibleIndividually).OrderBy(x => x.DisplayOrder).ThenBy(x => x.Name).Select(x => x.Id);- var products = await query.ToListAsync2();-- return products;+ return await Task.FromResult(query.ToList());}/// <summary>@@ -84,7 +82,7 @@ namespace Grand.Business.Catalog.Services.Products.OrderBy(x => x.DisplayOrder).ThenBy(x => x.Name).Select(x => x.Id);- var products = await query.ToListAsync2();+ var products = await Task.FromResult(query.ToList());return products;}@@ -575,7 +573,7 @@ namespace Grand.Business.Catalog.Services.Productsquery = query.Where(p => p.VendorId == vendorId);}- var products = await query.OrderBy(x => x.DisplayOrder).ToListAsync2();+ var products = query.OrderBy(x => x.DisplayOrder).ToList();//ACL mappingif (!showHidden)@@ -588,7 +586,7 @@ namespace Grand.Business.Catalog.Services.Productsproducts = products.Where(x => _aclService.Authorize(x, storeId)).ToList();}- return products;+ return await Task.FromResult(products);}/// <summary>@@ -602,7 +600,7 @@ namespace Grand.Business.Catalog.Services.Productsreturn null;sku = sku.Trim();- return await _productRepository.Table.Where(x => x.Sku == sku).FirstOrDefaultAsync2();+ return await Task.FromResult(_productRepository.Table.Where(x => x.Sku == sku).FirstOrDefault());}public virtual async Task UpdateAssociatedProduct(Product product)diff --git a/src/Business/Grand.Business.Catalog/Services/Products/ProductTagService.cs b/src/Business/Grand.Business.Catalog/Services/Products/ProductTagService.csindex 50cece10f..a4912ab14 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/ProductTagService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/ProductTagService.cs@@ -74,9 +74,9 @@ namespace Grand.Business.Catalog.Services.Productsselect pt;var dictionary = new Dictionary<string, int>();- foreach (var item in await query.ToListAsync2())+ foreach (var item in query.ToList())dictionary.Add(item.Id, item.Count);- return dictionary;+ return await Task.FromResult(dictionary);});}@@ -118,7 +118,7 @@ namespace Grand.Business.Catalog.Services.Productswhere pt.Name == nameselect pt;- return query.FirstOrDefaultAsync2();+ return Task.FromResult(query.FirstOrDefault());}/// <summary>@@ -131,7 +131,7 @@ namespace Grand.Business.Catalog.Services.Productsvar query = from pt in _productTagRepository.Tablewhere pt.SeName == senameselect pt;- return query.FirstOrDefaultAsync2();+ return Task.FromResult(query.FirstOrDefault());}/// <summary>diff --git a/src/Business/Grand.Business.Catalog/Services/Products/RecentlyViewedProductsService.cs b/src/Business/Grand.Business.Catalog/Services/Products/RecentlyViewedProductsService.csindex 6f9e61525..9c2d7d577 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/RecentlyViewedProductsService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/RecentlyViewedProductsService.cs@@ -73,7 +73,7 @@ namespace Grand.Business.Catalog.Services.Productswhere p.CustomerId == customerIdorderby p.CreatedOnUtc descendingselect p.ProductId;- return await query.Take(number).ToListAsync2();+ return await Task.FromResult(query.Take(number).ToList());});}diff --git a/src/Business/Grand.Business.Catalog/Services/Products/SpecificationAttributeService.cs b/src/Business/Grand.Business.Catalog/Services/Products/SpecificationAttributeService.csindex 94fccaab5..6e7a19eca 100644--- a/src/Business/Grand.Business.Catalog/Services/Products/SpecificationAttributeService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Products/SpecificationAttributeService.cs@@ -72,7 +72,9 @@ namespace Grand.Business.Catalog.Services.Productssename = sename.ToLowerInvariant();var key = string.Format(CacheKey.SPECIFICATION_BY_SENAME, sename);- return await _cacheBase.GetAsync(key, async () => await _specificationAttributeRepository.Table.Where(x => x.SeName == sename).FirstOrDefaultAsync2());+ return await _cacheBase.GetAsync(key, async () =>+ await Task.FromResult(_specificationAttributeRepository.Table.Where(x => x.SeName == sename)+ .FirstOrDefault()));}@@ -168,7 +170,7 @@ namespace Grand.Business.Catalog.Services.Productsvar query = from p in _specificationAttributeRepository.Tablewhere p.SpecificationAttributeOptions.Any(x => x.Id == specificationAttributeOptionId)select p;- return await query.FirstOrDefaultAsync2();+ return await Task.FromResult(query.FirstOrDefault());});}diff --git a/src/Business/Grand.Business.Catalog/Services/Tax/TaxCategoryService.cs b/src/Business/Grand.Business.Catalog/Services/Tax/TaxCategoryService.csindex f86066c6e..55315b3fb 100644--- a/src/Business/Grand.Business.Catalog/Services/Tax/TaxCategoryService.cs+++ b/src/Business/Grand.Business.Catalog/Services/Tax/TaxCategoryService.cs@@ -53,12 +53,12 @@ namespace Grand.Business.Catalog.Services.Taxpublic virtual async Task<IList<TaxCategory>> GetAllTaxCategories(){string key = string.Format(CacheKey.TAXCATEGORIES_ALL_KEY);- return await _cacheBase.GetAsync(key, () =>+ return await _cacheBase.GetAsync(key, async () =>{var query = from tc in _taxCategoryRepository.Tableorderby tc.DisplayOrderselect tc;- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}diff --git a/src/Business/Grand.Business.Checkout/Services/CheckoutAttributes/CheckoutAttributeService.cs b/src/Business/Grand.Business.Checkout/Services/CheckoutAttributes/CheckoutAttributeService.csindex 933e7db02..f63386b66 100644--- a/src/Business/Grand.Business.Checkout/Services/CheckoutAttributes/CheckoutAttributeService.cs+++ b/src/Business/Grand.Business.Checkout/Services/CheckoutAttributes/CheckoutAttributeService.cs@@ -60,7 +60,7 @@ namespace Grand.Business.Checkout.Services.CheckoutAttributespublic virtual async Task<IList<CheckoutAttribute>> GetAllCheckoutAttributes(string storeId = "", bool excludeShippableAttributes = false, bool ignorAcl = false){string key = string.Format(CacheKey.CHECKOUTATTRIBUTES_ALL_KEY, storeId, excludeShippableAttributes, ignorAcl);- return await _cacheBase.GetAsync(key, () =>+ return await _cacheBase.GetAsync(key, async () =>{var query = from p in _checkoutAttributeRepository.Tableselect p;@@ -89,7 +89,7 @@ namespace Grand.Business.Checkout.Services.CheckoutAttributes{query = query.Where(x => !x.ShippableProductRequired);}- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}diff --git a/src/Business/Grand.Business.Checkout/Services/GiftVouchers/GiftVoucherService.cs b/src/Business/Grand.Business.Checkout/Services/GiftVouchers/GiftVoucherService.csindex 177b96cff..454d3288e 100644--- a/src/Business/Grand.Business.Checkout/Services/GiftVouchers/GiftVoucherService.cs+++ b/src/Business/Grand.Business.Checkout/Services/GiftVouchers/GiftVoucherService.cs@@ -93,7 +93,7 @@ namespace Grand.Business.Checkout.Services.GiftVouchersselect h;query = query.Where(x => x.UsedWithOrderId == orderId);- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}/// <summary>@@ -157,7 +157,7 @@ namespace Grand.Business.Checkout.Services.GiftVouchersquery = query.Where(gc => gc.PurchasedWithOrderItem.Id == purchasedWithOrderItemId);query = query.OrderBy(gc => gc.Id);- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}/// <summary>diff --git a/src/Business/Grand.Business.Checkout/Services/Orders/LoyaltyPointsService.cs b/src/Business/Grand.Business.Checkout/Services/Orders/LoyaltyPointsService.csindex 16bb79745..780c659db 100644--- a/src/Business/Grand.Business.Checkout/Services/Orders/LoyaltyPointsService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Orders/LoyaltyPointsService.cs@@ -60,7 +60,7 @@ namespace Grand.Business.Checkout.Services.Ordersquery = query.Where(rph => rph.StoreId == storeId);query = query.OrderByDescending(rph => rph.CreatedOnUtc).ThenByDescending(rph => rph.Id);- var lastRph = await query.FirstOrDefaultAsync2();+ var lastRph = await Task.FromResult(query.FirstOrDefault());return lastRph != null ? lastRph.PointsBalance : 0;}@@ -113,7 +113,7 @@ namespace Grand.Business.Checkout.Services.Orders}query = query.OrderByDescending(rph => rph.CreatedOnUtc).ThenByDescending(rph => rph.Id);- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}#endregiondiff --git a/src/Business/Grand.Business.Checkout/Services/Orders/MerchandiseReturnService.cs b/src/Business/Grand.Business.Checkout/Services/Orders/MerchandiseReturnService.csindex 5ed7571f1..a07a1ea88 100644--- a/src/Business/Grand.Business.Checkout/Services/Orders/MerchandiseReturnService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Orders/MerchandiseReturnService.cs@@ -79,7 +79,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <returns>Merchandise return</returns>public virtual Task<MerchandiseReturn> GetMerchandiseReturnById(int id){- return _merchandiseReturnRepository.Table.Where(x => x.ReturnNumber == id).FirstOrDefaultAsync2();+ return Task.FromResult(_merchandiseReturnRepository.Table.Where(x => x.ReturnNumber == id).FirstOrDefault());}/// <summary>@@ -129,7 +129,7 @@ namespace Grand.Business.Checkout.Services.Ordersvar query = from rra in _merchandiseReturnActionRepository.Tableorderby rra.DisplayOrder, rra.Idselect rra;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}@@ -272,7 +272,7 @@ namespace Grand.Business.Checkout.Services.Ordersvar query = from rra in _merchandiseReturnReasonRepository.Tableorderby rra.DisplayOrder, rra.Idselect rra;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}@@ -367,7 +367,7 @@ namespace Grand.Business.Checkout.Services.Ordersorderby merchandiseReturnNote.CreatedOnUtc descendingselect merchandiseReturnNote;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}/// <summary>@@ -377,7 +377,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <returns>MerchandiseReturnNote</returns>public virtual Task<MerchandiseReturnNote> GetMerchandiseReturnNote(string merchandiseReturnNoteId){- return _merchandiseReturnNoteRepository.Table.Where(x => x.Id == merchandiseReturnNoteId).FirstOrDefaultAsync2();+ return Task.FromResult(_merchandiseReturnNoteRepository.Table.Where(x => x.Id == merchandiseReturnNoteId).FirstOrDefault());}#endregiondiff --git a/src/Business/Grand.Business.Checkout/Services/Orders/OrderService.cs b/src/Business/Grand.Business.Checkout/Services/Orders/OrderService.csindex 9d52e9ee2..41e126423 100644--- a/src/Business/Grand.Business.Checkout/Services/Orders/OrderService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Orders/OrderService.cs@@ -75,7 +75,7 @@ namespace Grand.Business.Checkout.Services.Orderswhere o.OrderItems.Any(x => x.Id == orderItemId)select o;- return query.FirstOrDefaultAsync2();+ return Task.FromResult(query.FirstOrDefault());}/// <summary>/// Gets an order@@ -84,7 +84,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <returns>Order</returns>public virtual Task<Order> GetOrderByNumber(int orderNumber){- return _orderRepository.Table.Where(x => x.OrderNumber == orderNumber).FirstOrDefaultAsync2();+ return Task.FromResult(_orderRepository.Table.Where(x => x.OrderNumber == orderNumber).FirstOrDefault());}/// <summary>@@ -97,7 +97,7 @@ namespace Grand.Business.Checkout.Services.Ordersif (string.IsNullOrEmpty(code))return new List<Order>();- return await _orderRepository.Table.Where(x => x.Code == code.ToUpperInvariant()).ToListAsync2();+ return await Task.FromResult(_orderRepository.Table.Where(x => x.Code == code.ToUpperInvariant()).ToList());}@@ -114,7 +114,7 @@ namespace Grand.Business.Checkout.Services.Ordersvar query = from o in _orderRepository.Tablewhere orderIds.Contains(o.Id)select o;- var orders = await query.ToListAsync2();+ var orders = await Task.FromResult(query.ToList());//sort by passed identifiersvar sortedOrders = new List<Order>();foreach (string id in orderIds)@@ -136,7 +136,7 @@ namespace Grand.Business.Checkout.Services.Ordersvar query = from o in _orderRepository.Tablewhere o.OrderGuid == orderGuidselect o;- return query.FirstOrDefaultAsync2();+ return Task.FromResult(query.FirstOrDefault());}/// <summary>@@ -241,13 +241,11 @@ namespace Grand.Business.Checkout.Services.Orders/// <param name="expirationDateUTC">Date at which all unPaid orders and has pending status Would be Canceled</param>public async Task CancelExpiredOrders(DateTime expirationDateUTC){- var orders = await _orderRepository.Table- .Where(o =>- o.CreatedOnUtc < expirationDateUTC &&- o.PaymentStatusId == PaymentStatus.Pending &&- o.OrderStatusId == (int)OrderStatusSystem.Pending &&- (o.ShippingStatusId == ShippingStatus.Pending || o.ShippingStatusId == ShippingStatus.ShippingNotRequired))- .ToListAsync2();+ var orders = _orderRepository.Table+ .Where(o => o.CreatedOnUtc < expirationDateUTC && o.PaymentStatusId == PaymentStatus.Pending &&+ o.OrderStatusId == (int)OrderStatusSystem.Pending && (o.ShippingStatusId == ShippingStatus.Pending+ || o.ShippingStatusId == ShippingStatus.ShippingNotRequired))+ .ToList();foreach (var order in orders)await _mediator.Send(new CancelOrderCommand() { Order = order, NotifyCustomer = true });@@ -272,7 +270,7 @@ namespace Grand.Business.Checkout.Services.Orderswhere orderItem.OrderItemGuid == orderItemGuidselect orderItem;- return query.FirstOrDefaultAsync2();+ return Task.FromResult(query.FirstOrDefault());}/// <summary>@@ -333,7 +331,7 @@ namespace Grand.Business.Checkout.Services.Ordersorderby orderNote.CreatedOnUtc descendingselect orderNote;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}/// <summary>@@ -343,7 +341,7 @@ namespace Grand.Business.Checkout.Services.Orders/// <returns>OrderNote</returns>public virtual Task<OrderNote> GetOrderNote(string ordernoteId){- return _orderNoteRepository.Table.Where(x => x.Id == ordernoteId).FirstOrDefaultAsync2();+ return Task.FromResult(_orderNoteRepository.Table.Where(x => x.Id == ordernoteId).FirstOrDefault());}diff --git a/src/Business/Grand.Business.Checkout/Services/Orders/OrderStatusService.cs b/src/Business/Grand.Business.Checkout/Services/Orders/OrderStatusService.csindex 7af8a35da..b06a6c5e1 100644--- a/src/Business/Grand.Business.Checkout/Services/Orders/OrderStatusService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Orders/OrderStatusService.cs@@ -31,13 +31,13 @@ namespace Grand.Business.Checkout.Services.Orderspublic virtual async Task<IList<OrderStatus>> GetAll(){string key = string.Format(CacheKey.ORDER_STATUS_ALL);- var orderstatuses = await _cacheBase.GetAsync(CacheKey.ORDER_STATUS_ALL, () =>+ var orderstatuses = await _cacheBase.GetAsync(CacheKey.ORDER_STATUS_ALL, async () =>{var query = from p in _orderStatusRepository.Tableselect p;query = query.OrderBy(l => l.DisplayOrder);- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});return orderstatuses;diff --git a/src/Business/Grand.Business.Checkout/Services/Orders/OrderTagService.cs b/src/Business/Grand.Business.Checkout/Services/Orders/OrderTagService.csindex e02fc5fd1..629bdf76a 100644--- a/src/Business/Grand.Business.Checkout/Services/Orders/OrderTagService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Orders/OrderTagService.cs@@ -56,11 +56,11 @@ namespace Grand.Business.Checkout.Services.Ordersselect ot;var dictionary = new Dictionary<string, int>();- foreach (var tag in await query.ToListAsync2())+ foreach (var tag in query.ToList()){dictionary.Add(tag.Id, tag.Count);}- return dictionary;+ return await Task.FromResult(dictionary);});}@@ -99,7 +99,7 @@ namespace Grand.Business.Checkout.Services.Orderswhere pt.Name == nameselect pt;- return query.FirstOrDefaultAsync2();+ return Task.FromResult(query.FirstOrDefault());}/// <summary>diff --git a/src/Business/Grand.Business.Checkout/Services/Payments/PaymentTransactionService.cs b/src/Business/Grand.Business.Checkout/Services/Payments/PaymentTransactionService.csindex a809f9da8..f16fd9249 100644--- a/src/Business/Grand.Business.Checkout/Services/Payments/PaymentTransactionService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Payments/PaymentTransactionService.cs@@ -88,9 +88,9 @@ namespace Grand.Business.Checkout.Services.Payments/// <returns>PaymentTransaction</returns>public virtual async Task<IList<PaymentTransaction>> GetByOrderCode(string orderCode){- return await+ return await Task.FromResult(_repositoryPaymentTransaction.Table.Where(x => x.OrderCode == orderCode)- .ToListAsync2();+ .ToList());}/// <summary>@@ -100,9 +100,7 @@ namespace Grand.Business.Checkout.Services.Payments/// <returns>PaymentTransaction</returns>public virtual async Task<PaymentTransaction> GetByOrdeGuid(Guid orderguid){- return await- _repositoryPaymentTransaction.Table.Where(x => x.OrderGuid == orderguid)- .FirstOrDefaultAsync2();+ return await Task.FromResult(_repositoryPaymentTransaction.Table.Where(x => x.OrderGuid == orderguid).FirstOrDefault());}/// <summary>@@ -122,7 +120,7 @@ namespace Grand.Business.Checkout.Services.Paymentsif (!string.IsNullOrEmpty(paymentMethodSystemName))query = query.Where(c => c.PaymentMethodSystemName == paymentMethodSystemName);- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}/// <summary>diff --git a/src/Business/Grand.Business.Checkout/Services/Shipping/DeliveryDateService.cs b/src/Business/Grand.Business.Checkout/Services/Shipping/DeliveryDateService.csindex 29bcaca5a..4d084fa90 100644--- a/src/Business/Grand.Business.Checkout/Services/Shipping/DeliveryDateService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Shipping/DeliveryDateService.cs@@ -58,12 +58,12 @@ namespace Grand.Business.Checkout.Services.Shipping/// <returns>Delivery dates</returns>public virtual async Task<IList<DeliveryDate>> GetAllDeliveryDates(){- return await _cacheBase.GetAsync(CacheKey.DELIVERYDATE_ALL, () =>+ return await _cacheBase.GetAsync(CacheKey.DELIVERYDATE_ALL, async () =>{var query = from dd in _deliveryDateRepository.Tableorderby dd.DisplayOrderselect dd;- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}diff --git a/src/Business/Grand.Business.Checkout/Services/Shipping/PickupPointService.cs b/src/Business/Grand.Business.Checkout/Services/Shipping/PickupPointService.csindex 41d54391f..093a676e4 100644--- a/src/Business/Grand.Business.Checkout/Services/Shipping/PickupPointService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Shipping/PickupPointService.cs@@ -57,12 +57,12 @@ namespace Grand.Business.Checkout.Services.Shipping/// <returns>Warehouses</returns>public virtual async Task<IList<PickupPoint>> GetAllPickupPoints(){- return await _cacheBase.GetAsync(CacheKey.PICKUPPOINTS_ALL, () =>+ return await _cacheBase.GetAsync(CacheKey.PICKUPPOINTS_ALL, async () =>{var query = from pp in _pickupPointsRepository.Tableorderby pp.DisplayOrderselect pp;- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}diff --git a/src/Business/Grand.Business.Checkout/Services/Shipping/ShipmentService.cs b/src/Business/Grand.Business.Checkout/Services/Shipping/ShipmentService.csindex 4e45bf214..23331d1f2 100644--- a/src/Business/Grand.Business.Checkout/Services/Shipping/ShipmentService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Shipping/ShipmentService.cs@@ -109,7 +109,7 @@ namespace Grand.Business.Checkout.Services.Shippingvar query = from o in _shipmentRepository.Tablewhere shipmentIds.Contains(o.Id)select o;- var shipments = await query.ToListAsync2();+ var shipments = await Task.FromResult(query.ToList());//sort by passed identifiersvar sortedOrders = new List<Shipment>();@@ -125,7 +125,7 @@ namespace Grand.Business.Checkout.Services.Shippingpublic virtual async Task<IList<Shipment>> GetShipmentsByOrder(string orderId){- return await _shipmentRepository.Table.Where(x => x.OrderId == orderId).ToListAsync2();+ return await Task.FromResult(_shipmentRepository.Table.Where(x => x.OrderId == orderId).ToList());}/// <summary>@@ -223,7 +223,7 @@ namespace Grand.Business.Checkout.Services.Shippingorderby shipmentNote.CreatedOnUtc descendingselect shipmentNote;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}/// <summary>@@ -233,7 +233,7 @@ namespace Grand.Business.Checkout.Services.Shipping/// <returns>shipmentNote</returns>public virtual Task<ShipmentNote> GetShipmentNote(string shipmentnoteId){- return _shipmentNoteRepository.Table.Where(x => x.Id == shipmentnoteId).FirstOrDefaultAsync2();+ return Task.FromResult(_shipmentNoteRepository.Table.Where(x => x.Id == shipmentnoteId).FirstOrDefault());}diff --git a/src/Business/Grand.Business.Checkout/Services/Shipping/ShippingMethodService.cs b/src/Business/Grand.Business.Checkout/Services/Shipping/ShippingMethodService.csindex 2e98936a4..7ff8ad79b 100644--- a/src/Business/Grand.Business.Checkout/Services/Shipping/ShippingMethodService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Shipping/ShippingMethodService.cs@@ -82,12 +82,12 @@ namespace Grand.Business.Checkout.Services.Shipping{var shippingMethods = new List<ShippingMethod>();- shippingMethods = await _cacheBase.GetAsync(CacheKey.SHIPPINGMETHOD_ALL, () =>+ shippingMethods = await _cacheBase.GetAsync(CacheKey.SHIPPINGMETHOD_ALL, async () =>{var query = from sm in _shippingMethodRepository.Tableorderby sm.DisplayOrderselect sm;- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});if (!string.IsNullOrEmpty(filterByCountryId))diff --git a/src/Business/Grand.Business.Checkout/Services/Shipping/WarehouseService.cs b/src/Business/Grand.Business.Checkout/Services/Shipping/WarehouseService.csindex 21e7bcf52..c26e1eae3 100644--- a/src/Business/Grand.Business.Checkout/Services/Shipping/WarehouseService.cs+++ b/src/Business/Grand.Business.Checkout/Services/Shipping/WarehouseService.cs@@ -58,12 +58,12 @@ namespace Grand.Business.Checkout.Services.Shipping/// <returns>Warehouses</returns>public virtual async Task<IList<Warehouse>> GetAllWarehouses(){- return await _cacheBase.GetAsync(CacheKey.WAREHOUSES_ALL, () =>+ return await _cacheBase.GetAsync(CacheKey.WAREHOUSES_ALL, async () =>{var query = from wh in _warehouseRepository.Tableorderby wh.DisplayOrderselect wh;- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}diff --git a/src/Business/Grand.Business.Cms/Services/BlogService.cs b/src/Business/Grand.Business.Cms/Services/BlogService.csindex 7b79e639e..8349436df 100644--- a/src/Business/Grand.Business.Cms/Services/BlogService.cs+++ b/src/Business/Grand.Business.Cms/Services/BlogService.cs@@ -241,7 +241,7 @@ namespace Grand.Business.Cms.Serviceswhere (customerId == "" || c.CustomerId == customerId) && (storeId == "" || c.StoreId == storeId)select c;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}/// <summary>@@ -261,7 +261,7 @@ namespace Grand.Business.Cms.Servicesorderby c.CreatedOnUtcselect c;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}/// Get blog comments by identifiers@@ -276,7 +276,7 @@ namespace Grand.Business.Cms.Servicesvar query = from bc in _blogCommentRepository.Tablewhere commentIds.Contains(bc.Id)select bc;- var comments = await query.ToListAsync2();+ var comments = query.ToList();//sort by passed identifiersvar sortedComments = new List<BlogComment>();foreach (string id in commentIds)@@ -285,7 +285,7 @@ namespace Grand.Business.Cms.Servicesif (comment != null)sortedComments.Add(comment);}- return sortedComments;+ return await Task.FromResult(sortedComments);}/// <summary>@@ -330,7 +330,7 @@ namespace Grand.Business.Cms.Services/// <returns></returns>public virtual async Task<IList<BlogCategory>> GetBlogCategoryByPostId(string blogPostId){- return await _blogCategoryRepository.Table.Where(x => x.BlogPosts.Any(x => x.BlogPostId == blogPostId)).ToListAsync2();+ return await Task.FromResult(_blogCategoryRepository.Table.Where(x => x.BlogPosts.Any(x => x.BlogPostId == blogPostId)).ToList());}/// <summary>@@ -343,7 +343,7 @@ namespace Grand.Business.Cms.Servicesif (string.IsNullOrEmpty(blogCategorySeName))throw new ArgumentNullException(nameof(blogCategorySeName));- return await _blogCategoryRepository.Table.Where(x => x.SeName == blogCategorySeName.ToLowerInvariant()).FirstOrDefaultAsync2();+ return await Task.FromResult(_blogCategoryRepository.Table.Where(x => x.SeName == blogCategorySeName.ToLowerInvariant()).FirstOrDefault());}/// <summary>@@ -360,7 +360,7 @@ namespace Grand.Business.Cms.Servicesquery = query.Where(b => b.Stores.Contains(storeId) || !b.LimitedToStores);}- return await query.OrderBy(x => x.DisplayOrder).ToListAsync2();+ return await Task.FromResult(query.OrderBy(x => x.DisplayOrder).ToList());}/// <summary>@@ -488,7 +488,7 @@ namespace Grand.Business.Cms.Servicesorderby bp.DisplayOrderselect bp;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}#endregiondiff --git a/src/Business/Grand.Business.Cms/Services/NewsService.cs b/src/Business/Grand.Business.Cms/Services/NewsService.csindex 6dab6942a..09c378a73 100644--- a/src/Business/Grand.Business.Cms/Services/NewsService.cs+++ b/src/Business/Grand.Business.Cms/Services/NewsService.cs@@ -161,7 +161,7 @@ namespace Grand.Business.Cms.Serviceswhere (customerId == "" || c.CustomerId == customerId)select c;- return await query2.ToListAsync2();+ return await Task.FromResult(query2.ToList());}#endregiondiff --git a/src/Business/Grand.Business.Cms/Services/PageLayoutService.cs b/src/Business/Grand.Business.Cms/Services/PageLayoutService.csindex 1e1ce3b6e..4838b82be 100644--- a/src/Business/Grand.Business.Cms/Services/PageLayoutService.cs+++ b/src/Business/Grand.Business.Cms/Services/PageLayoutService.cs@@ -53,13 +53,13 @@ namespace Grand.Business.Cms.Services/// <returns>Page layouts</returns>public virtual async Task<IList<PageLayout>> GetAllPageLayouts(){- return await _cacheBase.GetAsync(CacheKey.PAGE_LAYOUT_ALL, () =>+ return await _cacheBase.GetAsync(CacheKey.PAGE_LAYOUT_ALL, async () =>{var query = from pt in _pageLayoutRepository.Tableorderby pt.DisplayOrderselect pt;- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}diff --git a/src/Business/Grand.Business.Cms/Services/PageService.cs b/src/Business/Grand.Business.Cms/Services/PageService.csindex 6dce630c4..60c46cdf5 100644--- a/src/Business/Grand.Business.Cms/Services/PageService.cs+++ b/src/Business/Grand.Business.Cms/Services/PageService.cs@@ -81,7 +81,7 @@ namespace Grand.Business.Cms.Servicesquery = query.Where(t => t.SystemName.ToLower() == systemName.ToLower());query = query.OrderBy(t => t.Id);- var pages = await query.ToListAsync2();+ var pages = await Task.FromResult(query.ToList());if (!String.IsNullOrEmpty(storeId)){pages = pages.Where(x => _aclService.Authorize(x, storeId)).ToList();@@ -98,7 +98,7 @@ namespace Grand.Business.Cms.Servicespublic virtual async Task<IList<Page>> GetAllPages(string storeId, bool ignorAcl = false){string key = string.Format(CacheKey.PAGES_ALL_KEY, storeId, ignorAcl);- return await _cacheBase.GetAsync(key, () =>+ return await _cacheBase.GetAsync(key, async () =>{var query = from p in _pageRepository.Tableselect p;@@ -125,7 +125,7 @@ namespace Grand.Business.Cms.Servicesquery = query.OrderBy(t => t.SystemName);}}- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}diff --git a/src/Business/Grand.Business.Common/Services/Addresses/AddressAttributeService.cs b/src/Business/Grand.Business.Common/Services/Addresses/AddressAttributeService.csindex d78f95f81..e5afb0ebc 100644--- a/src/Business/Grand.Business.Common/Services/Addresses/AddressAttributeService.cs+++ b/src/Business/Grand.Business.Common/Services/Addresses/AddressAttributeService.cs@@ -54,12 +54,12 @@ namespace Grand.Business.Common.Services.Addressespublic virtual async Task<IList<AddressAttribute>> GetAllAddressAttributes(){string key = CacheKey.ADDRESSATTRIBUTES_ALL_KEY;- return await _cacheBase.GetAsync(key, () =>+ return await _cacheBase.GetAsync(key, async () =>{var query = from aa in _addressAttributeRepository.Tableorderby aa.DisplayOrderselect aa;- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}diff --git a/src/Business/Grand.Business.Common/Services/Directory/CountryService.cs b/src/Business/Grand.Business.Common/Services/Directory/CountryService.csindex 3b817cf47..690c73f1c 100644--- a/src/Business/Grand.Business.Common/Services/Directory/CountryService.cs+++ b/src/Business/Grand.Business.Common/Services/Directory/CountryService.cs@@ -80,7 +80,7 @@ namespace Grand.Business.Common.Services.Directoryselect p;}- var countries = await query.OrderBy(x => x.DisplayOrder).ThenBy(x => x.Name).ToListAsync2();+ var countries = await Task.FromResult(query.OrderBy(x => x.DisplayOrder).ThenBy(x => x.Name).ToList());if (!string.IsNullOrEmpty(languageId)){countries = countries@@ -145,7 +145,7 @@ namespace Grand.Business.Common.Services.Directoryvar query = from c in _countryRepository.Tablewhere countryIds.Contains(c.Id)select c;- var countries = await query.ToListAsync2();+ var countries = await Task.FromResult(query.ToList());//sort by passed identifiersvar sortedCountries = new List<Country>();foreach (string id in countryIds)@@ -162,12 +162,12 @@ namespace Grand.Business.Common.Services.Directory/// </summary>/// <param name="twoLetterIsoCode">Country two letter ISO code</param>/// <returns>Country</returns>- public virtual Task<Country> GetCountryByTwoLetterIsoCode(string twoLetterIsoCode)+ public virtual async Task<Country> GetCountryByTwoLetterIsoCode(string twoLetterIsoCode){var key = string.Format(CacheKey.COUNTRIES_BY_TWOLETTER, twoLetterIsoCode);- return _cacheBase.GetAsync(key, () =>+ return await _cacheBase.GetAsync(key, async () =>{- return _countryRepository.Table.Where(x => x.TwoLetterIsoCode == twoLetterIsoCode).FirstOrDefaultAsync2();+ return await Task.FromResult(_countryRepository.Table.Where(x => x.TwoLetterIsoCode == twoLetterIsoCode).FirstOrDefault());});}@@ -176,12 +176,12 @@ namespace Grand.Business.Common.Services.Directory/// </summary>/// <param name="threeLetterIsoCode">Country three letter ISO code</param>/// <returns>Country</returns>- public virtual Task<Country> GetCountryByThreeLetterIsoCode(string threeLetterIsoCode)+ public virtual async Task<Country> GetCountryByThreeLetterIsoCode(string threeLetterIsoCode){var key = string.Format(CacheKey.COUNTRIES_BY_THREELETTER, threeLetterIsoCode);- return _cacheBase.GetAsync(key, () =>+ return await _cacheBase.GetAsync(key, async () =>{- return _countryRepository.Table.Where(x => x.ThreeLetterIsoCode == threeLetterIsoCode).FirstOrDefaultAsync2();+ return await Task.FromResult(_countryRepository.Table.Where(x => x.ThreeLetterIsoCode == threeLetterIsoCode).FirstOrDefault());});}diff --git a/src/Business/Grand.Business.Common/Services/Directory/CurrencyService.cs b/src/Business/Grand.Business.Common/Services/Directory/CurrencyService.csindex 4d60f6fca..a724a4412 100644--- a/src/Business/Grand.Business.Common/Services/Directory/CurrencyService.cs+++ b/src/Business/Grand.Business.Common/Services/Directory/CurrencyService.cs@@ -104,12 +104,12 @@ namespace Grand.Business.Common.Services.Directoryreturn null;var key = string.Format(CacheKey.CURRENCIES_BY_CODE, currencyCode);- return await _cacheBase.GetAsync(key, () =>+ return await _cacheBase.GetAsync(key, async () =>{var query = from q in _currencyRepository.Tablewhere q.CurrencyCode.ToLowerInvariant() == currencyCode.ToLower()select q;- return query.FirstOrDefaultAsync2();+ return await Task.FromResult(query.FirstOrDefault());});}@@ -122,7 +122,7 @@ namespace Grand.Business.Common.Services.Directorypublic virtual async Task<IList<Currency>> GetAllCurrencies(bool showHidden = false, string storeId = ""){string key = string.Format(CacheKey.CURRENCIES_ALL_KEY, showHidden);- var currencies = await _cacheBase.GetAsync(key, () =>+ var currencies = await _cacheBase.GetAsync(key, async () =>{var query = from p in _currencyRepository.Tableselect p;@@ -130,7 +130,7 @@ namespace Grand.Business.Common.Services.Directoryif (!showHidden)query = query.Where(c => c.Published);query = query.OrderBy(c => c.DisplayOrder);- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});//store acldiff --git a/src/Business/Grand.Business.Common/Services/Directory/GroupService.cs b/src/Business/Grand.Business.Common/Services/Directory/GroupService.csindex 9acc08a15..be5211c92 100644--- a/src/Business/Grand.Business.Common/Services/Directory/GroupService.cs+++ b/src/Business/Grand.Business.Common/Services/Directory/GroupService.cs@@ -89,12 +89,12 @@ namespace Grand.Business.Common.Services.Directory/// </summary>/// <param name="systemName">Customer group system name</param>/// <returns>Customer group</returns>- public virtual Task<CustomerGroup> GetCustomerGroupBySystemName(string systemName)+ public virtual async Task<CustomerGroup> GetCustomerGroupBySystemName(string systemName){string key = string.Format(CacheKey.CUSTOMERGROUPS_BY_SYSTEMNAME_KEY, systemName);- return _cacheBase.GetAsync(key, () =>+ return await _cacheBase.GetAsync(key, async () =>{- return _customerGroupRepository.Table.Where(x => x.SystemName == systemName).FirstOrDefaultAsync2();+ return await Task.FromResult(_customerGroupRepository.Table.Where(x => x.SystemName == systemName).FirstOrDefault());});}@@ -212,12 +212,12 @@ namespace Grand.Business.Common.Services.Directorypublic async Task<IList<CustomerGroup>> GetAllByIds(string[] ids){- var customerGroups = await _cacheBase.GetAsync(CacheKey.CUSTOMERGROUPS_ALL, () =>+ var customerGroups = await _cacheBase.GetAsync(CacheKey.CUSTOMERGROUPS_ALL, async () =>{var query = from cr in _customerGroupRepository.Tableorderby cr.Nameselect cr;- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});return customerGroups.Where(x => ids.Contains(x.Id)).ToList();}diff --git a/src/Business/Grand.Business.Common/Services/Directory/HistoryService.cs b/src/Business/Grand.Business.Common/Services/Directory/HistoryService.csindex 2b1ead6c6..e92d0addb 100644--- a/src/Business/Grand.Business.Common/Services/Directory/HistoryService.cs+++ b/src/Business/Grand.Business.Common/Services/Directory/HistoryService.cs@@ -38,7 +38,7 @@ namespace Grand.Business.Common.Services.Directoryif (entity == null)throw new ArgumentNullException(nameof(entity));- var history = await _historyRepository.Table.Where(x => x.Object.Id == entity.Id).Select(x => (T)x.Object).ToListAsync2();+ var history = await Task.FromResult(_historyRepository.Table.Where(x => x.Object.Id == entity.Id).Select(x => (T)x.Object).ToList());return history;}@@ -47,7 +47,7 @@ namespace Grand.Business.Common.Services.Directoryif (entity == null)throw new ArgumentNullException(nameof(entity));- var history = await _historyRepository.Table.Where(x => x.Object.Id == entity.Id).ToListAsync2();+ 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/MeasureService.cs b/src/Business/Grand.Business.Common/Services/Directory/MeasureService.csindex e203997e2..4ca7072ee 100644--- a/src/Business/Grand.Business.Common/Services/Directory/MeasureService.cs+++ b/src/Business/Grand.Business.Common/Services/Directory/MeasureService.cs@@ -96,12 +96,12 @@ namespace Grand.Business.Common.Services.Directorypublic virtual async Task<IList<MeasureDimension>> GetAllMeasureDimensions(){string key = CacheKey.MEASUREDIMENSIONS_ALL_KEY;- return await _cacheBase.GetAsync(key, () =>+ return await _cacheBase.GetAsync(key, async () =>{var query = from md in _measureDimensionRepository.Tableorderby md.DisplayOrderselect md;- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}@@ -271,12 +271,12 @@ namespace Grand.Business.Common.Services.Directorypublic virtual async Task<IList<MeasureWeight>> GetAllMeasureWeights(){string key = CacheKey.MEASUREWEIGHTS_ALL_KEY;- return await _cacheBase.GetAsync(key, () =>+ return await _cacheBase.GetAsync(key, async () =>{var query = from mw in _measureWeightRepository.Tableorderby mw.DisplayOrderselect mw;- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}@@ -430,12 +430,12 @@ namespace Grand.Business.Common.Services.Directorypublic virtual async Task<IList<MeasureUnit>> GetAllMeasureUnits(){string key = CacheKey.MEASUREUNITS_ALL_KEY;- return await _cacheBase.GetAsync(key, () =>+ return await _cacheBase.GetAsync(key, async () =>{var query = from md in _measureUnitRepository.Tableorderby md.DisplayOrderselect md;- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}diff --git a/src/Business/Grand.Business.Common/Services/Localization/LanguageService.cs b/src/Business/Grand.Business.Common/Services/Localization/LanguageService.csindex edd00b7b3..82cfb8cab 100644--- a/src/Business/Grand.Business.Common/Services/Localization/LanguageService.cs+++ b/src/Business/Grand.Business.Common/Services/Localization/LanguageService.cs@@ -56,7 +56,7 @@ namespace Grand.Business.Common.Services.Localizationpublic virtual async Task<IList<Language>> GetAllLanguages(bool showHidden = false, string storeId = ""){string key = string.Format(CacheKey.LANGUAGES_ALL_KEY, showHidden);- var languages = await _cacheBase.GetAsync(key, () =>+ var languages = await _cacheBase.GetAsync(key, async () =>{var query = from p in _languageRepository.Tableselect p;@@ -64,7 +64,7 @@ namespace Grand.Business.Common.Services.Localizationif (!showHidden)query = query.Where(l => l.Published);query = query.OrderBy(l => l.DisplayOrder);- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});//store acldiff --git a/src/Business/Grand.Business.Common/Services/Localization/TranslationService.cs b/src/Business/Grand.Business.Common/Services/Localization/TranslationService.csindex 09ab5dd57..9b6431061 100644--- a/src/Business/Grand.Business.Common/Services/Localization/TranslationService.cs+++ b/src/Business/Grand.Business.Common/Services/Localization/TranslationService.cs@@ -77,13 +77,13 @@ namespace Grand.Business.Common.Services.Localization/// <param name="Name">A string representing a name</param>/// <param name="languageId">Language identifier</param>/// <returns>Translate resource</returns>- public virtual Task<TranslationResource> GetTranslateResourceByName(string name, string languageId)+ public virtual async Task<TranslationResource> GetTranslateResourceByName(string name, string languageId){var query = from lsr in _translationRepository.Tableorderby lsr.Namewhere lsr.LanguageId == languageId && lsr.Name == nameselect lsr;- var translateResource = query.FirstOrDefaultAsync2();+ var translateResource = await Task.FromResult(query.FirstOrDefault());return translateResource;}@@ -296,9 +296,9 @@ namespace Grand.Business.Common.Services.Localizationcontinue;//bulk insert- var resource = await (from l in _translationRepository.Table+ var resource = (from l in _translationRepository.Tablewhere l.Name == name.ToLowerInvariant() && l.LanguageId == language.Id- select l).FirstOrDefaultAsync2();+ select l).FirstOrDefault();if (resource != null){diff --git a/src/Business/Grand.Business.Common/Services/Logging/CustomerActivityService.cs b/src/Business/Grand.Business.Common/Services/Logging/CustomerActivityService.csindex 0f39e07f2..74c545fa1 100644--- a/src/Business/Grand.Business.Common/Services/Logging/CustomerActivityService.cs+++ b/src/Business/Grand.Business.Common/Services/Logging/CustomerActivityService.cs@@ -122,7 +122,7 @@ namespace Grand.Business.Common.Services.Loggingvar query = from alt in _activityLogTypeRepository.Tableorderby alt.Nameselect alt;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}/// <summary>diff --git a/src/Business/Grand.Business.Common/Services/Logging/DefaultLogger.cs b/src/Business/Grand.Business.Common/Services/Logging/DefaultLogger.csindex 4b3863172..5a23a374f 100644--- a/src/Business/Grand.Business.Common/Services/Logging/DefaultLogger.cs+++ b/src/Business/Grand.Business.Common/Services/Logging/DefaultLogger.cs@@ -103,7 +103,7 @@ namespace Grand.Business.Common.Services.Loggingwhere logIds.Contains(l.Id)select l;- var logItems = await query.ToListAsync2();+ var logItems = await Task.FromResult(query.ToList());var sortedLogItems = new List<Log>();foreach (string id in logIds){diff --git a/src/Business/Grand.Business.Common/Services/Security/PermissionService.cs b/src/Business/Grand.Business.Common/Services/Security/PermissionService.csindex 2e4d992d0..b4a7d7ab4 100644--- a/src/Business/Grand.Business.Common/Services/Security/PermissionService.cs+++ b/src/Business/Grand.Business.Common/Services/Security/PermissionService.cs@@ -70,7 +70,7 @@ namespace Grand.Business.Common.Services.Securitystring key = string.Format(CacheKey.PERMISSIONS_ALLOWED_KEY, customerGroup.Id, permissionSystemName);return await _cacheBase.GetAsync(key, async () =>{- var permissionRecord = await _permissionRepository.Table.Where(x => x.SystemName == permissionSystemName).FirstOrDefaultAsync2();+ var permissionRecord = await Task.FromResult(_permissionRepository.Table.Where(x => x.SystemName == permissionSystemName).FirstOrDefault());return permissionRecord?.CustomerGroups.Contains(customerGroup.Id) ?? false;});}@@ -130,7 +130,7 @@ namespace Grand.Business.Common.Services.Securityvar query = from pr in _permissionRepository.Tableorderby pr.Nameselect pr;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}/// <summary>@@ -227,8 +227,8 @@ namespace Grand.Business.Common.Services.Security/// <returns>Permission action</returns>public virtual async Task<IList<PermissionAction>> GetPermissionActions(string systemName, string customeroleId){- return await _permissionActionRepository.Table- .Where(x => x.SystemName == systemName && x.CustomerGroupId == customeroleId).ToListAsync2();+ return await Task.FromResult(_permissionActionRepository.Table+ .Where(x => x.SystemName == systemName && x.CustomerGroupId == customeroleId).ToList());}/// <summary>@@ -284,8 +284,8 @@ namespace Grand.Business.Common.Services.Securityvar key = string.Format(CacheKey.PERMISSIONS_ALLOWED_ACTION_KEY, group.Id, permissionSystemName, permissionActionName);var permissionAction = await _cacheBase.GetAsync(key, async () =>{- return await _permissionActionRepository.Table.Where(x => x.SystemName == permissionSystemName && x.CustomerGroupId == group.Id && x.Action == permissionActionName)- .FirstOrDefaultAsync2();+ return await Task.FromResult(_permissionActionRepository.Table.Where(x => x.SystemName == permissionSystemName && x.CustomerGroupId == group.Id && x.Action == permissionActionName)+ .FirstOrDefault());});if (permissionAction != null)return false;diff --git a/src/Business/Grand.Business.Common/Services/Seo/SlugService.cs b/src/Business/Grand.Business.Common/Services/Seo/SlugService.csindex 97dfc1514..15c278863 100644--- a/src/Business/Grand.Business.Common/Services/Seo/SlugService.cs+++ b/src/Business/Grand.Business.Common/Services/Seo/SlugService.cs@@ -233,7 +233,7 @@ namespace Grand.Business.Common.Services.Seour.LanguageId == languageId &&ur.IsActiveselect ur.Slug;- var slug = await query.FirstOrDefaultAsync2();+ var slug = await Task.FromResult(query.FirstOrDefault());if (slug == null)slug = "";return slug;@@ -262,7 +262,7 @@ namespace Grand.Business.Common.Services.Seour.LanguageId == languageIdselect ur;- var allUrlEntity = await query.ToListAsync2();+ var allUrlEntity = query.ToList();var activeUrlEntity = allUrlEntity.FirstOrDefault(x => x.IsActive);if (!string.IsNullOrWhiteSpace(slug))diff --git a/src/Business/Grand.Business.Common/Services/Stores/StoreService.cs b/src/Business/Grand.Business.Common/Services/Stores/StoreService.csindex 602807752..4afb996a1 100644--- a/src/Business/Grand.Business.Common/Services/Stores/StoreService.cs+++ b/src/Business/Grand.Business.Common/Services/Stores/StoreService.cs@@ -56,9 +56,9 @@ namespace Grand.Business.Common.Services.Stores{if (_allStores == null){- _allStores = await _cacheBase.GetAsync(CacheKey.STORES_ALL_KEY, () =>+ _allStores = await _cacheBase.GetAsync(CacheKey.STORES_ALL_KEY, async () =>{- return _storeRepository.Table.OrderBy(x => x.DisplayOrder).ToListAsync2();+ return await Task.FromResult(_storeRepository.Table.OrderBy(x => x.DisplayOrder).ToList());});}return _allStores;diff --git a/src/Business/Grand.Business.Customers/Services/AffiliateService.cs b/src/Business/Grand.Business.Customers/Services/AffiliateService.csindex 846d09318..409a4e98f 100644--- a/src/Business/Grand.Business.Customers/Services/AffiliateService.cs+++ b/src/Business/Grand.Business.Customers/Services/AffiliateService.cs@@ -60,13 +60,13 @@ namespace Grand.Business.Customers.Services/// </summary>/// <param name="friendlyUrlName">Friendly url name</param>/// <returns>Affiliate</returns>- public virtual Task<Affiliate> GetAffiliateByFriendlyUrlName(string friendlyUrlName)+ public virtual async Task<Affiliate> GetAffiliateByFriendlyUrlName(string friendlyUrlName){var query = from a in _affiliateRepository.Tableorderby a.Idwhere a.FriendlyUrlName.Contains(friendlyUrlName.ToLowerInvariant())select a;- var affiliate = query.FirstOrDefaultAsync2();+ var affiliate = await Task.FromResult(query.FirstOrDefault());return affiliate;}diff --git a/src/Business/Grand.Business.Customers/Services/CustomerAttributeService.cs b/src/Business/Grand.Business.Customers/Services/CustomerAttributeService.csindex 482dba433..86bd942a5 100644--- a/src/Business/Grand.Business.Customers/Services/CustomerAttributeService.cs+++ b/src/Business/Grand.Business.Customers/Services/CustomerAttributeService.cs@@ -53,12 +53,12 @@ namespace Grand.Business.Customers.Servicespublic virtual async Task<IList<CustomerAttribute>> GetAllCustomerAttributes(){string key = CacheKey.CUSTOMERATTRIBUTES_ALL_KEY;- return await _cacheBase.GetAsync(key, () =>+ return await _cacheBase.GetAsync(key, async () =>{var query = from ca in _customerAttributeRepository.Tableorderby ca.DisplayOrderselect ca;- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}diff --git a/src/Business/Grand.Business.Customers/Services/CustomerHistoryPasswordService.cs b/src/Business/Grand.Business.Customers/Services/CustomerHistoryPasswordService.csindex 8a2743077..0e32c5127 100644--- a/src/Business/Grand.Business.Customers/Services/CustomerHistoryPasswordService.cs+++ b/src/Business/Grand.Business.Customers/Services/CustomerHistoryPasswordService.cs@@ -54,10 +54,12 @@ namespace Grand.Business.Customers.Services/// <returns>List of customer passwords</returns>public virtual async Task<IList<CustomerHistoryPassword>> GetPasswords(string customerId, int passwordsToReturn){- return await _customerHistoryPasswordProductRepository.Table.Where(x=>x.CustomerId == customerId)+ return await Task.FromResult(_customerHistoryPasswordProductRepository+ .Table+ .Where(x=>x.CustomerId == customerId).OrderByDescending(password => password.CreatedOnUtc).Take(passwordsToReturn)- .ToListAsync2();+ .ToList());}}diff --git a/src/Business/Grand.Business.Customers/Services/CustomerNoteService.cs b/src/Business/Grand.Business.Customers/Services/CustomerNoteService.csindex 0f68122cb..ef28227ce 100644--- a/src/Business/Grand.Business.Customers/Services/CustomerNoteService.cs+++ b/src/Business/Grand.Business.Customers/Services/CustomerNoteService.cs@@ -34,7 +34,7 @@ namespace Grand.Business.Customers.Servicesif (string.IsNullOrWhiteSpace(id))return Task.FromResult<CustomerNote>(null);- return _customerNoteRepository.Table.Where(x => x.Id == id).FirstOrDefaultAsync2();+ return _customerNoteRepository.GetByIdAsync(id);}/// <summary>@@ -84,7 +84,7 @@ namespace Grand.Business.Customers.Servicesquery = query.OrderByDescending(x => x.CreatedOnUtc);- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}#endregiondiff --git a/src/Business/Grand.Business.Customers/Services/CustomerService.cs b/src/Business/Grand.Business.Customers/Services/CustomerService.csindex 422bedffa..40bebb4f5 100644--- a/src/Business/Grand.Business.Customers/Services/CustomerService.cs+++ b/src/Business/Grand.Business.Customers/Services/CustomerService.cs@@ -122,7 +122,7 @@ namespace Grand.Business.Customers.Servicesquery = query.Where(c => c.PasswordFormatId == passwordFormat);query = query.OrderByDescending(c => c.CreatedOnUtc);- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}/// <summary>@@ -209,7 +209,7 @@ namespace Grand.Business.Customers.Servicesvar query = from c in _customerRepository.Tablewhere customerIds.Contains(c.Id)select c;- var customers = await query.ToListAsync2();+ var customers = query.ToList();//sort by passed identifiersvar sortedCustomers = new List<Customer>();foreach (var id in customerIds)@@ -218,7 +218,7 @@ namespace Grand.Business.Customers.Servicesif (customer != null)sortedCustomers.Add(customer);}- return sortedCustomers;+ return await Task.FromResult(sortedCustomers);}/// <summary>@@ -226,9 +226,9 @@ namespace Grand.Business.Customers.Services/// </summary>/// <param name="customerGuid">Customer GUID</param>/// <returns>A customer</returns>- public virtual Task<Customer> GetCustomerByGuid(Guid customerGuid)+ public virtual async Task<Customer> GetCustomerByGuid(Guid customerGuid){- return _customerRepository.Table.Where(x => x.CustomerGuid == customerGuid).FirstOrDefaultAsync2();+ return await Task.FromResult(_customerRepository.Table.Where(x => x.CustomerGuid == customerGuid).FirstOrDefault());}/// <summary>@@ -236,12 +236,12 @@ namespace Grand.Business.Customers.Services/// </summary>/// <param name="email">Email</param>/// <returns>Customer</returns>- public virtual Task<Customer> GetCustomerByEmail(string email)+ public virtual async Task<Customer> GetCustomerByEmail(string email){if (string.IsNullOrWhiteSpace(email))- return Task.FromResult<Customer>(null);+ return null;- return _customerRepository.Table.Where(x => x.Email == email.ToLowerInvariant()).FirstOrDefaultAsync2();+ return await Task.FromResult(_customerRepository.Table.Where(x => x.Email == email.ToLowerInvariant()).FirstOrDefault());}/// <summary>@@ -249,12 +249,12 @@ namespace Grand.Business.Customers.Services/// </summary>/// <param name="systemName">System name</param>/// <returns>Customer</returns>- public virtual Task<Customer> GetCustomerBySystemName(string systemName)+ public virtual async Task<Customer> GetCustomerBySystemName(string systemName){if (string.IsNullOrWhiteSpace(systemName))- return Task.FromResult<Customer>(null);+ return null;- return _customerRepository.Table.Where(x => x.SystemName == systemName).FirstOrDefaultAsync2();+ return await Task.FromResult(_customerRepository.Table.Where(x => x.SystemName == systemName).FirstOrDefault());}/// <summary>@@ -262,12 +262,12 @@ namespace Grand.Business.Customers.Services/// </summary>/// <param name="username">Username</param>/// <returns>Customer</returns>- public virtual Task<Customer> GetCustomerByUsername(string username)+ public virtual async Task<Customer> GetCustomerByUsername(string username){if (string.IsNullOrWhiteSpace(username))- return Task.FromResult<Customer>(null);+ return null;- return _customerRepository.Table.Where(x => x.Username == username.ToLowerInvariant()).FirstOrDefaultAsync2();+ return await Task.FromResult(_customerRepository.Table.Where(x => x.Username == username.ToLowerInvariant()).FirstOrDefault());}/// <summary>diff --git a/src/Business/Grand.Business.Customers/Services/SalesEmployeeService.cs b/src/Business/Grand.Business.Customers/Services/SalesEmployeeService.csindex 4bb89e949..e2d9233dd 100644--- a/src/Business/Grand.Business.Customers/Services/SalesEmployeeService.cs+++ b/src/Business/Grand.Business.Customers/Services/SalesEmployeeService.cs@@ -49,12 +49,12 @@ namespace Grand.Business.Customers.Services/// <returns>Warehouses</returns>public virtual async Task<IList<SalesEmployee>> GetAll(){- return await _cacheBase.GetAsync(CacheKey.SALESEMPLOYEE_ALL, () =>+ return await _cacheBase.GetAsync(CacheKey.SALESEMPLOYEE_ALL, async () =>{var query = from se in _salesEmployeeRepository.Tableorderby se.DisplayOrderselect se;- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}diff --git a/src/Business/Grand.Business.Customers/Services/UserApiService.cs b/src/Business/Grand.Business.Customers/Services/UserApiService.csindex 17f1791a4..facb04914 100644--- a/src/Business/Grand.Business.Customers/Services/UserApiService.cs+++ b/src/Business/Grand.Business.Customers/Services/UserApiService.cs@@ -36,9 +36,9 @@ namespace Grand.Business.Customers.Services/// Get user api by email/// </summary>/// <param name="id">id</param>- public virtual Task<UserApi> GetUserByEmail(string email)+ public virtual async Task<UserApi> GetUserByEmail(string email){- return _userRepository.Table.Where(x => x.Email == email.ToLowerInvariant()).FirstOrDefaultAsync2();+ return await Task.FromResult(_userRepository.Table.Where(x => x.Email == email.ToLowerInvariant()).FirstOrDefault());}/// <summary>diff --git a/src/Business/Grand.Business.Customers/Services/VendorService.cs b/src/Business/Grand.Business.Customers/Services/VendorService.csindex 4b3d52a7d..37ae0e05a 100644--- a/src/Business/Grand.Business.Customers/Services/VendorService.cs+++ b/src/Business/Grand.Business.Customers/Services/VendorService.cs@@ -178,7 +178,7 @@ namespace Grand.Business.Customers.Servicesvar query = from c in _vendorRepository.Tablewhere c.AppliedDiscounts.Any(x => x == discountId)select c;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}#region Vendor reviews@@ -344,7 +344,7 @@ namespace Grand.Business.Customers.Services{query = query.Where(x => x.Id == vendorId);}- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}#endregiondiff --git a/src/Business/Grand.Business.Marketing/Services/Banners/BannerService.cs b/src/Business/Grand.Business.Marketing/Services/Banners/BannerService.csindex 4a7762e15..6ee945ad8 100644--- a/src/Business/Grand.Business.Marketing/Services/Banners/BannerService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Banners/BannerService.cs@@ -92,7 +92,7 @@ namespace Grand.Business.Marketing.Services.Bannersvar query = from c in _bannerRepository.Tableorderby c.CreatedOnUtcselect c;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}}diff --git a/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.cs b/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.csindex 1fec33331..06f27b310 100644--- a/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.cs@@ -140,7 +140,7 @@ namespace Grand.Business.Marketing.Services.Campaignsvar query = from c in _campaignRepository.Tableorderby c.CreatedOnUtcselect c;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}public virtual async Task<IPagedList<CampaignHistory>> GetCampaignHistory(Campaign campaign, int pageIndex = 0, int pageSize = int.MaxValue)diff --git a/src/Business/Grand.Business.Marketing/Services/Contacts/ContactAttributeService.cs b/src/Business/Grand.Business.Marketing/Services/Contacts/ContactAttributeService.csindex ac4b1cbe4..8c1893000 100644--- a/src/Business/Grand.Business.Marketing/Services/Contacts/ContactAttributeService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Contacts/ContactAttributeService.cs@@ -77,7 +77,7 @@ namespace Grand.Business.Marketing.Services.Contactspublic virtual async Task<IList<ContactAttribute>> GetAllContactAttributes(string storeId = "", bool ignorAcl = false){string key = string.Format(CacheKey.CONTACTATTRIBUTES_ALL_KEY, storeId, ignorAcl);- return await _cacheBase.GetAsync(key, () =>+ return await _cacheBase.GetAsync(key, async () =>{var query = from p in _contactAttributeRepository.Tableselect p;@@ -102,7 +102,7 @@ namespace Grand.Business.Marketing.Services.Contactsselect p;}}- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}diff --git a/src/Business/Grand.Business.Marketing/Services/Contacts/InteractiveFormService.cs b/src/Business/Grand.Business.Marketing/Services/Contacts/InteractiveFormService.csindex 49ce77946..eaa853310 100644--- a/src/Business/Grand.Business.Marketing/Services/Contacts/InteractiveFormService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Contacts/InteractiveFormService.cs@@ -91,9 +91,9 @@ namespace Grand.Business.Marketing.Services.Contactspublic virtual async Task<InteractiveForm> GetFormBySystemName(string systemName){if (string.IsNullOrEmpty(systemName))- throw new ArgumentNullException("systemName");+ throw new ArgumentNullException(nameof(systemName));- return await _formRepository.Table.Where(x => x.SystemName == systemName).FirstOrDefaultAsync2();+ return await Task.FromResult(_formRepository.Table.Where(x => x.SystemName == systemName).FirstOrDefault());}/// <summary>@@ -107,7 +107,7 @@ namespace Grand.Business.Marketing.Services.Contactsorderby c.CreatedOnUtcselect c;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}}diff --git a/src/Business/Grand.Business.Marketing/Services/Contacts/PopupService.cs b/src/Business/Grand.Business.Marketing/Services/Contacts/PopupService.csindex bea0dd358..22cb60fee 100644--- a/src/Business/Grand.Business.Marketing/Services/Contacts/PopupService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Contacts/PopupService.cs@@ -64,7 +64,7 @@ namespace Grand.Business.Marketing.Services.Contactswhere c.CustomerId == customerId && c.Id == idselect c;- var popup = await query.FirstOrDefaultAsync2();+ var popup = await Task.FromResult(query.FirstOrDefault());if (popup != null){var archiveBanner = new PopupArchive()diff --git a/src/Business/Grand.Business.Marketing/Services/Courses/CourseActionService.cs b/src/Business/Grand.Business.Marketing/Services/Courses/CourseActionService.csindex d2dbdca46..1c84c4c19 100644--- a/src/Business/Grand.Business.Marketing/Services/Courses/CourseActionService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Courses/CourseActionService.cs@@ -30,14 +30,14 @@ namespace Grand.Business.Marketing.Services.Courseswhere a.CustomerId == customerId && a.LessonId == lessonIdselect a;- return await query.FirstOrDefaultAsync2();+ return await Task.FromResult(query.FirstOrDefault());}public virtual async Task<bool> CustomerLessonCompleted(string customerId, string lessonId){- var query = await (from a in _courseActionRepository.Table+ var query = await Task.FromResult((from a in _courseActionRepository.Tablewhere a.CustomerId == customerId && a.LessonId == lessonId- select a).FirstOrDefaultAsync2();+ select a).FirstOrDefault());return query != null ? query.Finished : false;}diff --git a/src/Business/Grand.Business.Marketing/Services/Courses/CourseLessonService.cs b/src/Business/Grand.Business.Marketing/Services/Courses/CourseLessonService.csindex 76e18e9dc..b999ca88f 100644--- a/src/Business/Grand.Business.Marketing/Services/Courses/CourseLessonService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Courses/CourseLessonService.cs@@ -41,7 +41,7 @@ namespace Grand.Business.Marketing.Services.Courseswhere c.CourseId == courseIdselect c;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}public virtual Task<CourseLesson> GetById(string id)diff --git a/src/Business/Grand.Business.Marketing/Services/Courses/CourseLevelService.cs b/src/Business/Grand.Business.Marketing/Services/Courses/CourseLevelService.csindex 90063475d..73ce17ba8 100644--- a/src/Business/Grand.Business.Marketing/Services/Courses/CourseLevelService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Courses/CourseLevelService.cs@@ -38,7 +38,7 @@ namespace Grand.Business.Marketing.Services.Coursesorderby l.DisplayOrderselect l;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}public virtual Task<CourseLevel> GetById(string id)diff --git a/src/Business/Grand.Business.Marketing/Services/Courses/CourseService.cs b/src/Business/Grand.Business.Marketing/Services/Courses/CourseService.csindex b45b755e2..11828cdcf 100644--- a/src/Business/Grand.Business.Marketing/Services/Courses/CourseService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Courses/CourseService.cs@@ -75,17 +75,17 @@ namespace Grand.Business.Marketing.Services.Courses}//courses without assigned product- var q1 = await query.Where(x => string.IsNullOrEmpty(x.ProductId)).ToListAsync2();+ var q1 = query.Where(x => string.IsNullOrEmpty(x.ProductId)).ToList();//get products from orders - paid/not deleted/for customer/store- var pl = await _orderRepository.Table.Where(x => x.CustomerId == customer.Id && !x.Deleted+ var pl = _orderRepository.Table.Where(x => x.CustomerId == customer.Id && !x.Deleted&& x.PaymentStatusId == Domain.Payments.PaymentStatus.Paid- && x.StoreId == storeId).SelectMany(x => x.OrderItems, (p, pr) => pr.ProductId).Distinct().ToListAsync2();+ && x.StoreId == storeId).SelectMany(x => x.OrderItems, (p, pr) => pr.ProductId).Distinct().ToList();//courses assigned to products- var q2 = await query.Where(x => pl.Contains(x.ProductId)).ToListAsync2();+ var q2 = query.Where(x => pl.Contains(x.ProductId)).ToList();- return q1.Concat(q2).ToList();+ return await Task.FromResult(q1.Concat(q2).ToList());}public virtual Task<Course> GetById(string id)diff --git a/src/Business/Grand.Business.Marketing/Services/Courses/CourseSubjectService.cs b/src/Business/Grand.Business.Marketing/Services/Courses/CourseSubjectService.csindex 486f54f56..ff302b0aa 100644--- a/src/Business/Grand.Business.Marketing/Services/Courses/CourseSubjectService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Courses/CourseSubjectService.cs@@ -42,7 +42,7 @@ namespace Grand.Business.Marketing.Services.Coursesorderby c.DisplayOrderselect c;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}public virtual Task<CourseSubject> GetById(string id)diff --git a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerProductService.cs b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerProductService.csindex 85cfbdaf8..a64240cd4 100644--- a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerProductService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerProductService.cs@@ -58,8 +58,7 @@ namespace Grand.Business.Marketing.Services.Customersvar key = string.Format(CacheKey.CUSTOMER_PRODUCT_PRICE_KEY_ID, customerId, productId);var productprice = await _cacheBase.GetAsync(key, async () =>{- var pp = await _customerProductPriceRepository.Table.Where(x => x.CustomerId == customerId && x.ProductId == productId)- .FirstOrDefaultAsync2();+ var pp = await Task.FromResult(_customerProductPriceRepository.Table.Where(x => x.CustomerId == customerId && x.ProductId == productId).FirstOrDefault());if (pp == null)return (null, false);else@@ -154,13 +153,13 @@ namespace Grand.Business.Marketing.Services.Customers/// <param name="customerId">Customer Identifier</param>/// <param name="productId">Product Identifier</param>/// <returns>Customer product</returns>- public virtual Task<CustomerProduct> GetCustomerProduct(string customerId, string productId)+ public virtual async Task<CustomerProduct> GetCustomerProduct(string customerId, string productId){var query = from pp in _customerProductRepository.Tablewhere pp.CustomerId == customerId && pp.ProductId == productIdselect pp;- return query.FirstOrDefaultAsync2();+ return await Task.FromResult(query.FirstOrDefault());}/// <summary>diff --git a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerReminderService.cs b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerReminderService.csindex a8de50012..32563fdb3 100644--- a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerReminderService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerReminderService.cs@@ -608,7 +608,7 @@ namespace Grand.Business.Marketing.Services.Customersvar query = from p in _customerReminderRepository.Tableorderby p.DisplayOrderselect p;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}/// <summary>@@ -682,30 +682,30 @@ namespace Grand.Business.Marketing.Services.Customersvar customerReminder = new List<CustomerReminder>();if (String.IsNullOrEmpty(id)){- customerReminder = await (from cr in _customerReminderRepository.Table+ customerReminder = (from cr in _customerReminderRepository.Tablewhere cr.Active && datetimeUtcNow >= cr.StartDateTimeUtc && datetimeUtcNow <= cr.EndDateTimeUtc&& cr.ReminderRuleId == CustomerReminderRuleEnum.AbandonedCart- select cr).ToListAsync2();+ select cr).ToList();}else{- customerReminder = await (from cr in _customerReminderRepository.Table+ customerReminder = (from cr in _customerReminderRepository.Tablewhere cr.Id == id && cr.ReminderRuleId == CustomerReminderRuleEnum.AbandonedCart- select cr).ToListAsync2();+ select cr).ToList();}foreach (var reminder in customerReminder){- var customers = await (from cu in _customerRepository.Table+ var customers = (from cu in _customerRepository.Tablewhere cu.ShoppingCartItems.Any() && cu.LastUpdateCartDateUtc > reminder.LastUpdateDate && cu.Active && !cu.Deleted&& (!String.IsNullOrEmpty(cu.Email))- select cu).ToListAsync2();+ select cu).ToList();foreach (var customer in customers){- var history = await (from hc in _customerReminderHistoryRepository.Table+ var history = (from hc in _customerReminderHistoryRepository.Tablewhere hc.CustomerId == customer.Id && hc.CustomerReminderId == reminder.Id- select hc).ToListAsync2();+ select hc).ToList();if (history.Any()){var activereminderhistory = history.FirstOrDefault(x => x.Status == CustomerReminderHistoryStatusEnum.Started);@@ -775,30 +775,30 @@ namespace Grand.Business.Marketing.Services.Customersvar customerReminder = new List<CustomerReminder>();if (String.IsNullOrEmpty(id)){- customerReminder = await (from cr in _customerReminderRepository.Table+ customerReminder = (from cr in _customerReminderRepository.Tablewhere cr.Active && datetimeUtcNow >= cr.StartDateTimeUtc && datetimeUtcNow <= cr.EndDateTimeUtc&& cr.ReminderRuleId == CustomerReminderRuleEnum.RegisteredCustomer- select cr).ToListAsync2();+ select cr).ToList();}else{- customerReminder = await (from cr in _customerReminderRepository.Table+ customerReminder = (from cr in _customerReminderRepository.Tablewhere cr.Id == id && cr.ReminderRuleId == CustomerReminderRuleEnum.RegisteredCustomer- select cr).ToListAsync2();+ select cr).ToList();}foreach (var reminder in customerReminder){- var customers = await (from cu in _customerRepository.Table+ var customers = (from cu in _customerRepository.Tablewhere cu.CreatedOnUtc > reminder.LastUpdateDate && cu.Active && !cu.Deleted&& (!String.IsNullOrEmpty(cu.Email))&& !cu.IsSystemAccount- select cu).ToListAsync2();+ select cu).ToList();foreach (var customer in customers){- var history = await (from hc in _customerReminderHistoryRepository.Table+ var history = (from hc in _customerReminderHistoryRepository.Tablewhere hc.CustomerId == customer.Id && hc.CustomerReminderId == reminder.Id- select hc).ToListAsync2();+ select hc).ToList();if (history.Any()){var activereminderhistory = history.FirstOrDefault(x => x.Status == CustomerReminderHistoryStatusEnum.Started);@@ -868,29 +868,29 @@ namespace Grand.Business.Marketing.Services.Customersvar customerReminder = new List<CustomerReminder>();if (String.IsNullOrEmpty(id)){- customerReminder = await (from cr in _customerReminderRepository.Table+ customerReminder = (from cr in _customerReminderRepository.Tablewhere cr.Active && datetimeUtcNow >= cr.StartDateTimeUtc && datetimeUtcNow <= cr.EndDateTimeUtc&& cr.ReminderRuleId == CustomerReminderRuleEnum.LastActivity- select cr).ToListAsync2();+ select cr).ToList();}else{- customerReminder = await (from cr in _customerReminderRepository.Table+ customerReminder = (from cr in _customerReminderRepository.Tablewhere cr.Id == id && cr.ReminderRuleId == CustomerReminderRuleEnum.LastActivity- select cr).ToListAsync2();+ select cr).ToList();}foreach (var reminder in customerReminder){- var customers = await (from cu in _customerRepository.Table+ var customers = (from cu in _customerRepository.Tablewhere cu.LastActivityDateUtc < reminder.LastUpdateDate && cu.Active && !cu.Deleted&& (!String.IsNullOrEmpty(cu.Email))- select cu).ToListAsync2();+ select cu).ToList();foreach (var customer in customers){- var history = await (from hc in _customerReminderHistoryRepository.Table+ var history = (from hc in _customerReminderHistoryRepository.Tablewhere hc.CustomerId == customer.Id && hc.CustomerReminderId == reminder.Id- select hc).ToListAsync2();+ select hc).ToList();if (history.Any()){var activereminderhistory = history.FirstOrDefault(x => x.Status == CustomerReminderHistoryStatusEnum.Started);@@ -959,30 +959,30 @@ namespace Grand.Business.Marketing.Services.Customersvar customerReminder = new List<CustomerReminder>();if (String.IsNullOrEmpty(id)){- customerReminder = await (from cr in _customerReminderRepository.Table+ customerReminder = (from cr in _customerReminderRepository.Tablewhere cr.Active && datetimeUtcNow >= cr.StartDateTimeUtc && datetimeUtcNow <= cr.EndDateTimeUtc&& cr.ReminderRuleId == CustomerReminderRuleEnum.LastPurchase- select cr).ToListAsync2();+ select cr).ToList();}else{- customerReminder = await (from cr in _customerReminderRepository.Table+ customerReminder = (from cr in _customerReminderRepository.Tablewhere cr.Id == id && cr.ReminderRuleId == CustomerReminderRuleEnum.LastPurchase- select cr).ToListAsync2();+ select cr).ToList();}foreach (var reminder in customerReminder){- var customers = await (from cu in _customerRepository.Table+ var customers = (from cu in _customerRepository.Tablewhere cu.LastPurchaseDateUtc < reminder.LastUpdateDate || cu.LastPurchaseDateUtc == null&& (!String.IsNullOrEmpty(cu.Email)) && cu.Active && !cu.Deleted&& !cu.IsSystemAccount- select cu).ToListAsync2();+ select cu).ToList();foreach (var customer in customers){- var history = await (from hc in _customerReminderHistoryRepository.Table+ var history = (from hc in _customerReminderHistoryRepository.Tablewhere hc.CustomerId == customer.Id && hc.CustomerReminderId == reminder.Id- select hc).ToListAsync2();+ select hc).ToList();if (history.Any()){var activereminderhistory = history.FirstOrDefault(x => x.Status == CustomerReminderHistoryStatusEnum.Started);@@ -1052,16 +1052,16 @@ namespace Grand.Business.Marketing.Services.Customersvar customerReminder = new List<CustomerReminder>();if (String.IsNullOrEmpty(id)){- customerReminder = await (from cr in _customerReminderRepository.Table+ customerReminder = (from cr in _customerReminderRepository.Tablewhere cr.Active && datetimeUtcNow >= cr.StartDateTimeUtc && datetimeUtcNow <= cr.EndDateTimeUtc&& cr.ReminderRuleId == CustomerReminderRuleEnum.Birthday- select cr).ToListAsync2();+ select cr).ToList();}else{- customerReminder = await (from cr in _customerReminderRepository.Table+ customerReminder = (from cr in _customerReminderRepository.Tablewhere cr.Id == id && cr.ReminderRuleId == CustomerReminderRuleEnum.Birthday- select cr).ToListAsync2();+ select cr).ToList();}foreach (var reminder in customerReminder)@@ -1072,16 +1072,16 @@ namespace Grand.Business.Marketing.Services.Customersstring dateDDMM = DateTime.Now.AddDays(day).ToString("-MM-dd");- var customers = await (from cu in _customerRepository.Table+ var customers = (from cu in _customerRepository.Tablewhere (!String.IsNullOrEmpty(cu.Email)) && cu.Active && !cu.Deleted&& cu.UserFields.Any(x => x.Key == "DateOfBirth" && x.Value.Contains(dateDDMM))- select cu).ToListAsync2();+ select cu).ToList();foreach (var customer in customers){- var history = await (from hc in _customerReminderHistoryRepository.Table+ var history = (from hc in _customerReminderHistoryRepository.Tablewhere hc.CustomerId == customer.Id && hc.CustomerReminderId == reminder.Id- select hc).ToListAsync2();+ select hc).ToList();if (history.Any()){var activereminderhistory = history.FirstOrDefault(x => x.Status == CustomerReminderHistoryStatusEnum.Started);@@ -1135,9 +1135,9 @@ namespace Grand.Business.Marketing.Services.Customers}}- var activehistory = await (from hc in _customerReminderHistoryRepository.Table+ var activehistory = (from hc in _customerReminderHistoryRepository.Tablewhere hc.CustomerReminderId == reminder.Id && hc.Status == CustomerReminderHistoryStatusEnum.Started- select hc).ToListAsync2();+ select hc).ToList();foreach (var activereminderhistory in activehistory){@@ -1169,16 +1169,16 @@ namespace Grand.Business.Marketing.Services.Customersvar customerReminder = new List<CustomerReminder>();if (String.IsNullOrEmpty(id)){- customerReminder = await (from cr in _customerReminderRepository.Table+ customerReminder = (from cr in _customerReminderRepository.Tablewhere cr.Active && datetimeUtcNow >= cr.StartDateTimeUtc && datetimeUtcNow <= cr.EndDateTimeUtc&& cr.ReminderRuleId == CustomerReminderRuleEnum.CompletedOrder- select cr).ToListAsync2();+ select cr).ToList();}else{- customerReminder = await (from cr in _customerReminderRepository.Table+ customerReminder = (from cr in _customerReminderRepository.Tablewhere cr.Id == id && cr.ReminderRuleId == CustomerReminderRuleEnum.CompletedOrder- select cr).ToListAsync2();+ select cr).ToList();}foreach (var reminder in customerReminder)@@ -1187,19 +1187,19 @@ namespace Grand.Business.Marketing.Services.Customersif (reminder.Levels.OrderBy(x => x.Level).FirstOrDefault() != null)day = reminder.Levels.OrderBy(x => x.Level).FirstOrDefault().Day;- var orders = await (from or in _orderRepository.Table+ var orders = (from or in _orderRepository.Tablewhere or.OrderStatusId == (int)OrderStatusSystem.Complete&& or.CreatedOnUtc >= reminder.LastUpdateDate && or.CreatedOnUtc >= dateNow.AddDays(-day)- select or).ToListAsync2();+ select or).ToList();foreach (var order in orders){- var history = await (from hc in _customerReminderHistoryRepository.Table+ var history = (from hc in _customerReminderHistoryRepository.Tablewhere hc.BaseOrderId == order.Id && hc.CustomerReminderId == reminder.Id- select hc).ToListAsync2();+ select hc).ToList();- Customer customer = await _customerRepository.Table.Where(x => x.Id == order.CustomerId && x.Active && !x.Deleted).FirstOrDefaultAsync2();- if (customer != null)+ Customer customer = await _customerRepository.GetByIdAsync(order.CustomerId);+ if (customer != null && customer.Active && !customer.Deleted){if (history.Any()){@@ -1255,9 +1255,9 @@ namespace Grand.Business.Marketing.Services.Customers}}- var activehistory = await (from hc in _customerReminderHistoryRepository.Table+ var activehistory = (from hc in _customerReminderHistoryRepository.Tablewhere hc.CustomerReminderId == reminder.Id && hc.Status == CustomerReminderHistoryStatusEnum.Started- select hc).ToListAsync2();+ select hc).ToList();foreach (var activereminderhistory in activehistory){@@ -1290,16 +1290,16 @@ namespace Grand.Business.Marketing.Services.Customersvar customerReminder = new List<CustomerReminder>();if (String.IsNullOrEmpty(id)){- customerReminder = await (from cr in _customerReminderRepository.Table+ customerReminder = (from cr in _customerReminderRepository.Tablewhere cr.Active && datetimeUtcNow >= cr.StartDateTimeUtc && datetimeUtcNow <= cr.EndDateTimeUtc&& cr.ReminderRuleId == CustomerReminderRuleEnum.UnpaidOrder- select cr).ToListAsync2();+ select cr).ToList();}else{- customerReminder = await (from cr in _customerReminderRepository.Table+ customerReminder = (from cr in _customerReminderRepository.Tablewhere cr.Id == id && cr.ReminderRuleId == CustomerReminderRuleEnum.UnpaidOrder- select cr).ToListAsync2();+ select cr).ToList();}foreach (var reminder in customerReminder)@@ -1308,19 +1308,19 @@ namespace Grand.Business.Marketing.Services.Customersif (reminder.Levels.OrderBy(x => x.Level).FirstOrDefault() != null)day = reminder.Levels.OrderBy(x => x.Level).FirstOrDefault().Day;- var orders = await (from or in _orderRepository.Table+ var orders = (from or in _orderRepository.Tablewhere or.PaymentStatusId == PaymentStatus.Pending&& or.CreatedOnUtc >= reminder.LastUpdateDate && or.CreatedOnUtc >= dateNow.AddDays(-day)- select or).ToListAsync2();+ select or).ToList();foreach (var order in orders){- var history = await (from hc in _customerReminderHistoryRepository.Table+ var history = (from hc in _customerReminderHistoryRepository.Tablewhere hc.BaseOrderId == order.Id && hc.CustomerReminderId == reminder.Id- select hc).ToListAsync2();+ select hc).ToList();- Customer customer = await _customerRepository.Table.Where(x => x.Id == order.CustomerId && x.Active && !x.Deleted).FirstOrDefaultAsync2();- if (customer != null)+ Customer customer = await _customerRepository.GetByIdAsync(order.CustomerId);+ if (customer != null && customer.Active && !customer.Deleted){if (history.Any()){@@ -1375,9 +1375,9 @@ namespace Grand.Business.Marketing.Services.Customers}}}- var activehistory = await (from hc in _customerReminderHistoryRepository.Table+ var activehistory = (from hc in _customerReminderHistoryRepository.Tablewhere hc.CustomerReminderId == reminder.Id && hc.Status == CustomerReminderHistoryStatusEnum.Started- select hc).ToListAsync2();+ select hc).ToList();foreach (var activereminderhistory in activehistory){diff --git a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerTagService.cs b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerTagService.csindex cbd33dbf2..d3ddbac64 100644--- a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerTagService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerTagService.cs@@ -104,13 +104,13 @@ namespace Grand.Business.Marketing.Services.Customers/// </summary>/// <param name="name">Customer tag name</param>/// <returns>Customer tag</returns>- public virtual Task<CustomerTag> GetCustomerTagByName(string name)+ public virtual async Task<CustomerTag> GetCustomerTagByName(string name){var query = from pt in _customerTagRepository.Tablewhere pt.Name == nameselect pt;- return query.FirstOrDefaultAsync2();+ return await Task.FromResult(query.FirstOrDefault());}/// <summary>@@ -123,7 +123,7 @@ namespace Grand.Business.Marketing.Services.Customersvar query = from pt in _customerTagRepository.Tablewhere pt.Name.ToLower().Contains(name.ToLower())select pt;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}/// <summary>@@ -179,12 +179,12 @@ namespace Grand.Business.Marketing.Services.Customers/// <returns>Number of customers</returns>public virtual async Task<int> GetCustomerCount(string customerTagId){- var query = await _customerRepository.Table.+ var query = _customerRepository.Table.Where(x => x.CustomerTags.Contains(customerTagId)).- GroupBy(p => p, (k, s) => new { Counter = s.Count() }).ToListAsync2();+ GroupBy(p => p, (k, s) => new { Counter = s.Count() }).ToList();if (query.Count > 0)return query.FirstOrDefault().Counter;- return 0;+ return await Task.FromResult(0);}#region Customer tag product@@ -198,13 +198,13 @@ namespace Grand.Business.Marketing.Services.Customerspublic virtual async Task<IList<CustomerTagProduct>> GetCustomerTagProducts(string customerTagId){string key = string.Format(CacheKey.CUSTOMERTAGPRODUCTS_ROLE_KEY, customerTagId);- return await _cacheBase.GetAsync(key, () =>+ return await _cacheBase.GetAsync(key, async () =>{var query = from cr in _customerTagProductRepository.Tablewhere (cr.CustomerTagId == customerTagId)orderby cr.DisplayOrderselect cr;- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}diff --git a/src/Business/Grand.Business.Marketing/Services/Documents/DocumentTypeService.cs b/src/Business/Grand.Business.Marketing/Services/Documents/DocumentTypeService.csindex a3412e7cd..ed45a2025 100644--- a/src/Business/Grand.Business.Marketing/Services/Documents/DocumentTypeService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Documents/DocumentTypeService.cs@@ -37,7 +37,7 @@ namespace Grand.Business.Marketing.Services.Documentsvar query = from t in _documentTypeRepository.Tableorderby t.DisplayOrderselect t;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}public virtual Task<DocumentType> GetById(string id)diff --git a/src/Business/Grand.Business.Marketing/Services/Knowledgebase/KnowledgebaseService.cs b/src/Business/Grand.Business.Marketing/Services/Knowledgebase/KnowledgebaseService.csindex 2ec32e083..cbcf790e0 100644--- a/src/Business/Grand.Business.Marketing/Services/Knowledgebase/KnowledgebaseService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Knowledgebase/KnowledgebaseService.cs@@ -53,7 +53,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebase/// <param name="id"></param>public virtual async Task DeleteKnowledgebaseCategory(KnowledgebaseCategory kc){- var children = await _knowledgebaseCategoryRepository.Table.Where(x => x.ParentCategoryId == kc.Id).ToListAsync2();+ var children = _knowledgebaseCategoryRepository.Table.Where(x => x.ParentCategoryId == kc.Id).ToList();await _knowledgebaseCategoryRepository.DeleteAsync(kc);foreach (var child in children){@@ -85,9 +85,9 @@ namespace Grand.Business.Marketing.Services.Knowledgebase/// </summary>/// <param name="id"></param>/// <returns>knowledgebase category</returns>- public virtual Task<KnowledgebaseCategory> GetKnowledgebaseCategory(string id)+ public virtual async Task<KnowledgebaseCategory> GetKnowledgebaseCategory(string id){- return _knowledgebaseCategoryRepository.Table.Where(x => x.Id == id).FirstOrDefaultAsync2();+ return await Task.FromResult(_knowledgebaseCategoryRepository.Table.Where(x => x.Id == id).FirstOrDefault());}/// <summary>@@ -124,7 +124,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebaseselect p;}- var toReturn = await query.FirstOrDefaultAsync2();+ var toReturn = await Task.FromResult(query.FirstOrDefault());return toReturn;});}@@ -152,8 +152,8 @@ namespace Grand.Business.Marketing.Services.Knowledgebase/// <returns>List of knowledgebase categories</returns>public virtual async Task<List<KnowledgebaseCategory>> GetKnowledgebaseCategories(){- var categories = await _knowledgebaseCategoryRepository.Table.OrderBy(x => x.ParentCategoryId).ThenBy(x => x.DisplayOrder).ToListAsync2();- return categories.SortCategoriesForTree();+ var categories = _knowledgebaseCategoryRepository.Table.OrderBy(x => x.ParentCategoryId).ThenBy(x => x.DisplayOrder).ToList();+ return await Task.FromResult(categories.SortCategoriesForTree());}/// <summary>@@ -163,7 +163,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebase/// <returns>knowledgebase article</returns>public virtual Task<KnowledgebaseArticle> GetKnowledgebaseArticle(string id){- return _knowledgebaseArticleRepository.Table.Where(x => x.Id == id).FirstOrDefaultAsync2();+ return _knowledgebaseArticleRepository.GetByIdAsync(id);}/// <summary>@@ -194,7 +194,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebaseselect p;}query = query.OrderBy(x => x.DisplayOrder);- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}/// <summary>@@ -243,7 +243,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebase/// <returns>IPagedList<KnowledgebaseArticle></returns>public virtual async Task<IPagedList<KnowledgebaseArticle>> GetKnowledgebaseArticlesByCategoryId(string id, int pageIndex = 0, int pageSize = int.MaxValue){- var articles = await _knowledgebaseArticleRepository.Table.Where(x => x.ParentCategoryId == id).OrderBy(x => x.DisplayOrder).ToListAsync2();+ var articles = await Task.FromResult(_knowledgebaseArticleRepository.Table.Where(x => x.ParentCategoryId == id).OrderBy(x => x.DisplayOrder).ToList());return new PagedList<KnowledgebaseArticle>(articles, pageIndex, pageSize);}@@ -278,7 +278,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebaseselect p;}query = query.OrderBy(x => x.DisplayOrder);- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}@@ -316,7 +316,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebase}query = query.OrderBy(x => x.DisplayOrder);- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}@@ -328,7 +328,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebase{var key = string.Format(CacheKey.ARTICLE_BY_ID, id, string.Join(",", _workContext.CurrentCustomer.GetCustomerGroupIds()),_workContext.CurrentStore.Id);- return await _cacheBase.GetAsync(key, () =>+ return await _cacheBase.GetAsync(key, async () =>{var query = from p in _knowledgebaseArticleRepository.Tableselect p;@@ -352,7 +352,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebaseselect p;}- return query.FirstOrDefaultAsync2();+ return await Task.FromResult(query.FirstOrDefault());});}@@ -389,7 +389,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebaseselect p;}query = query.OrderBy(x => x.DisplayOrder);- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}@@ -429,7 +429,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebaseselect p;}query = query.OrderBy(x => x.DisplayOrder);- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}@@ -467,7 +467,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebaseselect p; ;}query = query.OrderBy(x => x.DisplayOrder);- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}@@ -504,7 +504,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebaseselect p;}query = query.OrderBy(x => x.DisplayOrder);- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}@@ -531,7 +531,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebase}query = query.OrderBy(x => x.DisplayOrder);- var toReturn = await query.ToListAsync2();+ var toReturn = await Task.FromResult(query.ToList());return new PagedList<KnowledgebaseArticle>(toReturn, pageIndex, pageSize);}@@ -582,7 +582,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebaseorderby c.CreatedOnUtcwhere (customerId == "" || c.CustomerId == customerId)select c;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}/// <summary>@@ -608,7 +608,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebasevar query = from bc in _articleCommentRepository.Tablewhere commentIds.Contains(bc.Id)select bc;- var comments = await query.ToListAsync2();+ var comments = query.ToList();//sort by passed identifiersvar sortedComments = new List<KnowledgebaseArticleComment>();foreach (string id in commentIds)@@ -617,7 +617,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebaseif (comment != null)sortedComments.Add(comment);}- return sortedComments;+ return await Task.FromResult(sortedComments);}public virtual async Task<IList<KnowledgebaseArticleComment>> GetArticleCommentsByArticleId(string articleId)@@ -626,7 +626,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebasewhere c.ArticleId == articleIdorderby c.CreatedOnUtcselect c;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}public virtual async Task DeleteArticleComment(KnowledgebaseArticleComment articleComment)diff --git a/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsletterCategoryService.cs b/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsletterCategoryService.csindex 59614abc3..050d569cb 100644--- a/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsletterCategoryService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsletterCategoryService.cs@@ -105,7 +105,7 @@ namespace Grand.Business.Marketing.Services.Newsteletterswhere !p.LimitedToStores || p.Stores.Contains(storeId)orderby p.DisplayOrderselect p;- return await query.ToListAsync2();+ return await Task.FromResult(query.ToList());}#endregion}diff --git a/src/Business/Grand.Business.Marketing/Services/PushNotifications/PushNotificationsService.cs b/src/Business/Grand.Business.Marketing/Services/PushNotifications/PushNotificationsService.csindex 454714163..11c4525dd 100644--- a/src/Business/Grand.Business.Marketing/Services/PushNotifications/PushNotificationsService.cs+++ b/src/Business/Grand.Business.Marketing/Services/PushNotifications/PushNotificationsService.cs@@ -65,7 +65,7 @@ namespace Grand.Business.Marketing.Services.PushNotifications/// <param name="CustomerId"></param>public virtual async Task<PushRegistration> GetPushReceiverByCustomerId(string CustomerId){- return await _pushRegistratiosnRepository.Table.Where(x => x.CustomerId == CustomerId).FirstOrDefaultAsync2();+ return await Task.FromResult(_pushRegistratiosnRepository.Table.Where(x => x.CustomerId == CustomerId).FirstOrDefault());}/// <summary>@@ -83,7 +83,7 @@ namespace Grand.Business.Marketing.Services.PushNotifications/// </summary>public virtual async Task<List<PushRegistration>> GetPushReceivers(){- return await _pushRegistratiosnRepository.Table.Where(x => x.Allowed).ToListAsync2();+ return await Task.FromResult(_pushRegistratiosnRepository.Table.Where(x => x.Allowed).ToList());}/// <summary>@@ -117,7 +117,7 @@ namespace Grand.Business.Marketing.Services.PushNotifications/// </summary>public virtual async Task<IPagedList<PushMessage>> GetPushMessages(int pageIndex = 0, int pageSize = int.MaxValue){- var allMessages = await _pushMessagesRepository.Table.OrderByDescending(x => x.SentOn).ToListAsync2();+ var allMessages = await Task.FromResult(_pushMessagesRepository.Table.OrderByDescending(x => x.SentOn).ToList());return new PagedList<PushMessage>(allMessages.Skip(pageIndex * pageSize).Take(pageSize).ToList(), pageIndex, pageSize, allMessages.Count);}@@ -126,7 +126,7 @@ namespace Grand.Business.Marketing.Services.PushNotifications/// </summary>public virtual async Task<IPagedList<PushRegistration>> GetPushReceivers(int pageIndex = 0, int pageSize = int.MaxValue){- var allReceivers = await _pushRegistratiosnRepository.Table.OrderByDescending(x => x.RegisteredOn).ToListAsync2();+ var allReceivers = await Task.FromResult(_pushRegistratiosnRepository.Table.OrderByDescending(x => x.RegisteredOn).ToList());return new PagedList<PushRegistration>(allReceivers.Skip(pageIndex * pageSize).Take(pageSize).ToList(), pageIndex, pageSize, allReceivers.Count);}@@ -244,10 +244,10 @@ namespace Grand.Business.Marketing.Services.PushNotifications/// <summary>/// Gets all push receivers/// </summary>- /// <param name="Id"></param>- public virtual Task<PushRegistration> GetPushReceiver(string Id)+ /// <param name="id">Ident</param>+ public virtual Task<PushRegistration> GetPushReceiver(string id){- return _pushRegistratiosnRepository.Table.Where(x => x.Id == Id).FirstOrDefaultAsync2();+ return _pushRegistratiosnRepository.GetByIdAsync(id);}}}diff --git a/src/Business/Grand.Business.Messages/Queries/Handlers/GetBidsByProductIdQueryHandler.cs b/src/Business/Grand.Business.Messages/Queries/Handlers/GetBidsByProductIdQueryHandler.csindex a1d0e4844..08ac42db7 100644--- a/src/Business/Grand.Business.Messages/Queries/Handlers/GetBidsByProductIdQueryHandler.cs+++ b/src/Business/Grand.Business.Messages/Queries/Handlers/GetBidsByProductIdQueryHandler.cs@@ -19,10 +19,10 @@ namespace Grand.Business.Messages.Queries.Models.Handlerspublic async Task<IList<Bid>> Handle(GetBidsByProductIdQuery request, CancellationToken cancellationToken){- return await _bidRepository+ return await Task.FromResult(_bidRepository.Table.Where(x => x.ProductId == request.ProductId).OrderByDescending(x => x.Date)- .ToListAsync2();+ .ToList());}}}diff --git a/src/Business/Grand.Business.Messages/Services/EmailAccountService.cs b/src/Business/Grand.Business.Messages/Services/EmailAccountService.csindex e65f18b69..be6703099 100644--- a/src/Business/Grand.Business.Messages/Services/EmailAccountService.cs+++ b/src/Business/Grand.Business.Messages/Services/EmailAccountService.cs@@ -150,12 +150,12 @@ namespace Grand.Business.Messages.Services/// <returns>Email accounts list</returns>public virtual async Task<IList<EmailAccount>> GetAllEmailAccounts(){- return await _cacheBase.GetAsync(CacheKey.EMAILACCOUNT_ALL_KEY, () =>+ return await _cacheBase.GetAsync(CacheKey.EMAILACCOUNT_ALL_KEY, async () =>{var query = from ea in _emailAccountRepository.Tableorderby ea.Idselect ea;- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}}diff --git a/src/Business/Grand.Business.Messages/Services/MessageTemplateService.cs b/src/Business/Grand.Business.Messages/Services/MessageTemplateService.csindex a509e7928..f87ee2e45 100644--- a/src/Business/Grand.Business.Messages/Services/MessageTemplateService.cs+++ b/src/Business/Grand.Business.Messages/Services/MessageTemplateService.cs@@ -126,7 +126,7 @@ namespace Grand.Business.Messages.Servicesquery = query.Where(t => t.Name == messageTemplateName);query = query.OrderBy(t => t.Id);- var templates = await query.ToListAsync2();+ var templates = await Task.FromResult(query.ToList());//store aclif (!String.IsNullOrEmpty(storeId))@@ -149,7 +149,7 @@ namespace Grand.Business.Messages.Servicespublic virtual async Task<IList<MessageTemplate>> GetAllMessageTemplates(string storeId){string key = string.Format(CacheKey.MESSAGETEMPLATES_ALL_KEY, storeId);- return await _cacheBase.GetAsync(key, () =>+ return await _cacheBase.GetAsync(key, async () =>{var query = from p in _messageTemplateRepository.Tableselect p;@@ -164,7 +164,7 @@ namespace Grand.Business.Messages.Servicesselect p;query = query.OrderBy(t => t.Name);}- return query.ToListAsync2();+ return await Task.FromResult(query.ToList());});}diff --git a/src/Business/Grand.Business.Messages/Services/QueuedEmailService.cs b/src/Business/Grand.Business.Messages/Services/QueuedEmailService.csindex 45c9716b4..b2422322a 100644--- a/src/Business/Grand.Business.Messages/Services/QueuedEmailService.cs+++ b/src/Business/Grand.Business.Messages/Services/QueuedEmailService.cs@@ -111,7 +111,7 @@ namespace Grand.Business.Messages.Servicesvar query = from qe in _queuedEmailRepository.Tablewhere queuedEmailIds.Contains(qe.Id)select qe;- var queuedEmails = await query.ToListAsync2();+ var queuedEmails = query.ToList();//sort by passed identifiersvar sortedQueuedEmails = new List<QueuedEmail>();foreach (string id in queuedEmailIds)@@ -120,7 +120,7 @@ namespace Grand.Business.Messages.Servicesif (queuedEmail != null)sortedQueuedEmails.Add(queuedEmail);}- return sortedQueuedEmails;+ return await Task.FromResult(sortedQueuedEmails);}/// <summary>diff --git a/src/Business/Grand.Business.Storage/Services/DownloadService.cs b/src/Business/Grand.Business.Storage/Services/DownloadService.csindex 0fb297c63..a1cd4953d 100644--- a/src/Business/Grand.Business.Storage/Services/DownloadService.cs+++ b/src/Business/Grand.Business.Storage/Services/DownloadService.cs@@ -79,11 +79,11 @@ namespace Grand.Business.Storage.Serviceswhere o.DownloadGuid == downloadGuidselect o;- var order = (await query.ToListAsync2()).FirstOrDefault();+ var order = query.FirstOrDefault();if (!order.UseDownloadUrl)order.DownloadBinary = await DownloadAsBytes(order.DownloadObjectId);- return order;+ return await Task.FromResult(order);}/// <summary>diff --git a/src/Business/Grand.Business.System/Commands/Handlers/Catalog/SendNotificationsToSubscribersCommandHandler.cs b/src/Business/Grand.Business.System/Commands/Handlers/Catalog/SendNotificationsToSubscribersCommandHandler.csindex 2e73d18e5..37bf385a3 100644--- a/src/Business/Grand.Business.System/Commands/Handlers/Catalog/SendNotificationsToSubscribersCommandHandler.cs+++ b/src/Business/Grand.Business.System/Commands/Handlers/Catalog/SendNotificationsToSubscribersCommandHandler.cs@@ -64,9 +64,9 @@ namespace Grand.Business.System.Commands.Handlers.Catalog/// <returns>Subscriptions</returns>private async Task<IList<OutOfStockSubscription>> GetAllSubscriptionsByProductId(string productId, IList<CustomAttribute> attributes, string warehouseId){- var query = await _outOfStockSubscriptionRepository.Table+ var query = _outOfStockSubscriptionRepository.Table.Where(biss => biss.ProductId == productId)- .OrderByDescending(biss => biss.CreatedOnUtc).ToListAsync2();+ .OrderByDescending(biss => biss.CreatedOnUtc).ToList();//warehouseif (!string.IsNullOrEmpty(warehouseId))@@ -79,7 +79,7 @@ namespace Grand.Business.System.Commands.Handlers.Catalogquery = query.Where(x => x.Attributes.Any(y => y.Key == item.Key && y.Value == item.Value)).ToList();}- return query.ToList();+ return await Task.FromResult(query.ToList());}}}diff --git a/src/Business/Grand.Business.System/Services/Admin/AdminSiteMapService.cs b/src/Business/Grand.Business.System/Services/Admin/AdminSiteMapService.csindex 01d9c7ca2..450cf644b 100644--- a/src/Business/Grand.Business.System/Services/Admin/AdminSiteMapService.cs+++ b/src/Business/Grand.Business.System/Services/Admin/AdminSiteMapService.cs@@ -29,11 +29,11 @@ namespace Grand.Business.System.Services.Adminvar query = from c in _adminSiteMapRepository.Tableselect c;- var list = await query.ToListAsync2();+ var list = query.ToList();if (list.Any())return list;else- return StandardAdminSiteMap.SiteMap;+ return await Task.FromResult(StandardAdminSiteMap.SiteMap);});}}diff --git a/src/Business/Grand.Business.System/Services/Reports/OrderReportService.cs b/src/Business/Grand.Business.System/Services/Reports/OrderReportService.csindex de9669f65..3573227a3 100644--- a/src/Business/Grand.Business.System/Services/Reports/OrderReportService.cs+++ b/src/Business/Grand.Business.System/Services/Reports/OrderReportService.cs@@ -99,7 +99,7 @@ namespace Grand.Business.System.Services.ReportsSumOrders = r.SumOrders});- return await report.ToListAsync2();+ return await Task.FromResult(report.ToList());}@@ -133,14 +133,14 @@ namespace Grand.Business.System.Services.Reportsvar daydiff = (endTimeUtc.Value - startTimeUtc.Value).TotalDays;if (daydiff > 31){- var query = await builderquery.GroupBy(x =>+ var query = builderquery.GroupBy(x =>new { Year = x.CreatedOnUtc.Year, Month = x.CreatedOnUtc.Month }).Select(g => new OrderStats {Year = g.Key.Year,Month = g.Key.Month,Count = g.Count(),Amount = g.Sum(x => x.OrderTotal * x.CurrencyRate)- }).ToListAsync2();+ }).ToList();foreach (var item in query){@@ -153,7 +153,7 @@ namespace Grand.Business.System.Services.Reports}else{- var query = await builderquery.GroupBy(x =>+ var query = builderquery.GroupBy(x =>new { Year = x.CreatedOnUtc.Year, Month = x.CreatedOnUtc.Month, Day = x.CreatedOnUtc.Day }).Select(g => new OrderStats {Year = g.Key.Year,@@ -161,7 +161,7 @@ namespace Grand.Business.System.Services.ReportsDay = g.Key.Day,Count = g.Count(),Amount = g.Sum(x => x.OrderTotal * x.CurrencyRate)- }).ToListAsync2();+ }).ToList();foreach (var item in query){@@ -172,10 +172,7 @@ namespace Grand.Business.System.Services.Reports});}}---- return report;+ return await Task.FromResult(report);}/// <summary>@@ -264,13 +261,13 @@ namespace Grand.Business.System.Services.Reportsif (!string.IsNullOrEmpty(tagid))builderquery = builderquery.Where(o => o.OrderTags.Any(y => y == tagid));- var query = await builderquery+ var query = builderquery.GroupBy(x => 1).Select(g => new OrderAverageReportLine {CountOrders = g.Count(),SumShippingExclTax = g.Sum(o => o.OrderShippingExclTax * o.CurrencyRate),SumTax = g.Sum(o => o.OrderTax * o.CurrencyRate),SumOrders = g.Sum(o => o.OrderTotal * o.CurrencyRate)- }).ToListAsync2();+ }).ToList();var item2 = query.Count() > 0 ? query.FirstOrDefault() : new OrderAverageReportLine {@@ -279,7 +276,7 @@ namespace Grand.Business.System.Services.ReportsSumTax = decimal.Zero,SumOrders = decimal.Zero,};- return item2;+ return await Task.FromResult(item2);}/// <summary>@@ -421,11 +418,11 @@ namespace Grand.Business.System.Services.ReportsTotalQuantity = x.Sum(y => y.Quantity)});- var queryItemOrdered = orderBy == 1 ? await queryItem.OrderByDescending(x => x.TotalQuantity).ToListAsync2() :- await queryItem.OrderByDescending(x => x.TotalAmount).ToListAsync2();+ var queryItemOrdered = orderBy == 1 ? queryItem.OrderByDescending(x => x.TotalQuantity).ToList() :+ queryItem.OrderByDescending(x => x.TotalAmount).ToList();var result = new PagedList<BestsellersReportLine>(queryItemOrdered, pageIndex, pageSize);- return result;+ return await Task.FromResult(result);}@@ -449,11 +446,11 @@ namespace Grand.Business.System.Services.Reports&& (string.IsNullOrEmpty(salesEmployeeId) || o.SeId == salesEmployeeId)group o by 1 into gselect new ReportPeriodOrder() { Amount = g.Sum(x => x.OrderTotal / x.CurrencyRate), Count = g.Count() };- var report = (await query.ToListAsync2())?.FirstOrDefault();+ var report = query.ToList()?.FirstOrDefault();if (report == null)report = new ReportPeriodOrder();report.Date = date;- return report;+ return await Task.FromResult(report);}@@ -481,12 +478,12 @@ namespace Grand.Business.System.Services.Reportsif (recordsToReturn > 0)product = product.Take(recordsToReturn);- var report = await product.ToListAsync2();+ var report = product.ToList();var ids = new List<string>();foreach (var reportLine in report)ids.Add(reportLine.ProductId);- return ids.ToArray();+ return await Task.FromResult(ids.ToArray());}/// <summary>@@ -508,14 +505,14 @@ namespace Grand.Business.System.Services.ReportscreatedFromUtc = !createdFromUtc.HasValue ? DateTime.MinValue : createdFromUtc;createdToUtc = !createdToUtc.HasValue ? DateTime.MaxValue : createdToUtc;- var query = (await (from order in _orderRepository.Table+ var query = ((from order in _orderRepository.Tablewhere(string.IsNullOrEmpty(storeId) || order.StoreId == storeId) &&(createdFromUtc.Value <= order.CreatedOnUtc) &&(createdToUtc.Value >= order.CreatedOnUtc) &&(!order.Deleted)from orderItem in order.OrderItems- select new { orderItem.ProductId }).ToListAsync2()).Distinct().Select(x => x.ProductId);+ select new { orderItem.ProductId }).ToList()).Distinct().Select(x => x.ProductId);var qproducts = from p in _productRepository.Tableorderby p.Namediff --git a/src/Business/Grand.Business.System/Services/Reports/ProductsReportService.cs b/src/Business/Grand.Business.System/Services/Reports/ProductsReportService.csindex ee6e24e61..f0f73a2e9 100644--- a/src/Business/Grand.Business.System/Services/Reports/ProductsReportService.cs+++ b/src/Business/Grand.Business.System/Services/Reports/ProductsReportService.cs@@ -50,7 +50,7 @@ namespace Grand.Business.System.Services.Reportsif (!string.IsNullOrEmpty(storeId))query_simple_products = query_simple_products.Where(x => x.Stores.Contains(storeId));- var products = await query_simple_products.ToListAsync2();+ var products = query_simple_products.ToList();//Track inventory for product by product attributesvar query2_1 = from p in _productRepository.Table@@ -77,9 +77,9 @@ namespace Grand.Business.System.Services.Reportswhere c.StockQuantity <= 0select c;- var combinations = await query2_2.ToListAsync2();+ var combinations = query2_2.ToList();- return (products, combinations);+ return await Task.FromResult((products, combinations));}}}diff --git a/src/Core/Grand.Domain/Data/RepositoryExtensions.cs b/src/Core/Grand.Domain/Data/RepositoryExtensions.csdeleted file mode 100644index 01e7c6e85..000000000--- a/src/Core/Grand.Domain/Data/RepositoryExtensions.cs+++ /dev/null@@ -1,22 +0,0 @@-using MongoDB.Driver;-using MongoDB.Driver.Linq;-using System.Collections.Generic;-using System.Linq;-using System.Threading.Tasks;--namespace Grand.Domain.Data-{- public static class RepositoryExtensions- {- public static Task<List<T>> ToListAsync2<T>(this IQueryable<T> query)- {- return ((IMongoQueryable<T>)query).ToListAsync();- }-- public static Task<T> FirstOrDefaultAsync2<T>(this IQueryable<T> query)- {- return ((IMongoQueryable<T>)query).FirstOrDefaultAsync();- }-- }-}