Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Remove RepositoryExtensions

KrzysztofPajak10d6db8f459f
diff --git a/src/Business/Grand.Business.Authentication/Services/ExternalAuthenticationService.cs b/src/Business/Grand.Business.Authentication/Services/ExternalAuthenticationService.cs
index 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.Services
var query = from p in _externalAuthenticationRecordRepository.Table
where p.CustomerId == customer.Id
select 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.cs
index 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.Handlers
public 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.cs
index 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.Handlers
orderby cr.DisplayOrder
select 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.cs
index 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.Handlers
orderby cr.DisplayOrder
select 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.cs
index 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.Handlers
from item in p.ProductSpecificationAttributes
select 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.cs
index 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.Handlers
orderby cr.DisplayOrder
select 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.cs
index 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.Table
orderby pt.DisplayOrder
select 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.cs
index 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.Brands
where c.AppliedDiscounts.Any(x => x == discountId)
select c;
- return await query.ToListAsync2();
+ return await Task.FromResult(query.ToList());
}
#endregion
diff --git a/src/Business/Grand.Business.Catalog/Services/Categories/CategoryLayoutService.cs b/src/Business/Grand.Business.Catalog/Services/Categories/CategoryLayoutService.cs
index 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.Table
orderby pt.DisplayOrder
select 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.cs
index 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.Categories
select p;
}
}
- return await query.ToListAsync2();
+ return await Task.FromResult(query.ToList());
}
/// <summary>
@@ -203,7 +203,7 @@ namespace Grand.Business.Catalog.Services.Categories
var 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.Categories
where 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.cs
index 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.Table
orderby pt.DisplayOrder
select 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.cs
index 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.Collections
where c.AppliedDiscounts.Any(x => x == discountId)
select c;
- return await query.ToListAsync2();
+ return await Task.FromResult(query.ToList());
}
#endregion
diff --git a/src/Business/Grand.Business.Catalog/Services/Discounts/DiscountService.cs b/src/Business/Grand.Business.Catalog/Services/Discounts/DiscountService.cs
index 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.Discounts
string 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.Table
select 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.Discounts
if (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.Discounts
if (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.cs
index 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.Products
public 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.Products
public 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.cs
index 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.Products
public 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.cs
index 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.Products
biss.WarehouseId == warehouseId
select 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.cs
index 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.cs
index 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.Products
public 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.cs
index 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.Table
orderby pt.DisplayOrder
select 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.cs
index 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.cs
index 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.Products
var 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.Products
query = query.Where(p => p.VendorId == vendorId);
}
- var products = await query.OrderBy(x => x.DisplayOrder).ToListAsync2();
+ var products = query.OrderBy(x => x.DisplayOrder).ToList();
//ACL mapping
if (!showHidden)
@@ -588,7 +586,7 @@ namespace Grand.Business.Catalog.Services.Products
products = 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.Products
return 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.cs
index 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.Products
select 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.Products
where pt.Name == name
select pt;
- return query.FirstOrDefaultAsync2();
+ return Task.FromResult(query.FirstOrDefault());
}
/// <summary>
@@ -131,7 +131,7 @@ namespace Grand.Business.Catalog.Services.Products
var query = from pt in _productTagRepository.Table
where pt.SeName == sename
select 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.cs
index 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.Products
where p.CustomerId == customerId
orderby p.CreatedOnUtc descending
select 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.cs
index 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.Products
sename = 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.Products
var query = from p in _specificationAttributeRepository.Table
where 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.cs
index 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.Tax
public 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.Table
orderby tc.DisplayOrder
select 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.cs
index 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.CheckoutAttributes
public 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.Table
select 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.cs
index 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.GiftVouchers
select 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.GiftVouchers
query = 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.cs
index 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.Orders
query = 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());
}
#endregion
diff --git a/src/Business/Grand.Business.Checkout/Services/Orders/MerchandiseReturnService.cs b/src/Business/Grand.Business.Checkout/Services/Orders/MerchandiseReturnService.cs
index 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.Orders
var query = from rra in _merchandiseReturnActionRepository.Table
orderby rra.DisplayOrder, rra.Id
select rra;
- return await query.ToListAsync2();
+ return await Task.FromResult(query.ToList());
});
}
@@ -272,7 +272,7 @@ namespace Grand.Business.Checkout.Services.Orders
var query = from rra in _merchandiseReturnReasonRepository.Table
orderby rra.DisplayOrder, rra.Id
select rra;
- return await query.ToListAsync2();
+ return await Task.FromResult(query.ToList());
});
}
@@ -367,7 +367,7 @@ namespace Grand.Business.Checkout.Services.Orders
orderby merchandiseReturnNote.CreatedOnUtc descending
select 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());
}
#endregion
diff --git a/src/Business/Grand.Business.Checkout/Services/Orders/OrderService.cs b/src/Business/Grand.Business.Checkout/Services/Orders/OrderService.cs
index 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.Orders
where 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.Orders
if (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.Orders
var query = from o in _orderRepository.Table
where orderIds.Contains(o.Id)
select o;
- var orders = await query.ToListAsync2();
+ var orders = await Task.FromResult(query.ToList());
//sort by passed identifiers
var sortedOrders = new List<Order>();
foreach (string id in orderIds)
@@ -136,7 +136,7 @@ namespace Grand.Business.Checkout.Services.Orders
var query = from o in _orderRepository.Table
where o.OrderGuid == orderGuid
select 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.Orders
where orderItem.OrderItemGuid == orderItemGuid
select orderItem;
- return query.FirstOrDefaultAsync2();
+ return Task.FromResult(query.FirstOrDefault());
}
/// <summary>
@@ -333,7 +331,7 @@ namespace Grand.Business.Checkout.Services.Orders
orderby orderNote.CreatedOnUtc descending
select 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.cs
index 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.Orders
public 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.Table
select 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.cs
index 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.Orders
select 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.Orders
where pt.Name == name
select 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.cs
index 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.Payments
if (!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.cs
index 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.Table
orderby dd.DisplayOrder
select 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.cs
index 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.Table
orderby pp.DisplayOrder
select 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.cs
index 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.Shipping
var query = from o in _shipmentRepository.Table
where shipmentIds.Contains(o.Id)
select o;
- var shipments = await query.ToListAsync2();
+ var shipments = await Task.FromResult(query.ToList());
//sort by passed identifiers
var sortedOrders = new List<Shipment>();
@@ -125,7 +125,7 @@ namespace Grand.Business.Checkout.Services.Shipping
public 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.Shipping
orderby shipmentNote.CreatedOnUtc descending
select 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.cs
index 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.Table
orderby sm.DisplayOrder
select 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.cs
index 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.Table
orderby wh.DisplayOrder
select 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.cs
index 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.Services
where (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.Services
orderby c.CreatedOnUtc
select c;
- return await query.ToListAsync2();
+ return await Task.FromResult(query.ToList());
}
/// Get blog comments by identifiers
@@ -276,7 +276,7 @@ namespace Grand.Business.Cms.Services
var query = from bc in _blogCommentRepository.Table
where commentIds.Contains(bc.Id)
select bc;
- var comments = await query.ToListAsync2();
+ var comments = query.ToList();
//sort by passed identifiers
var sortedComments = new List<BlogComment>();
foreach (string id in commentIds)
@@ -285,7 +285,7 @@ namespace Grand.Business.Cms.Services
if (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.Services
if (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.Services
query = 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.Services
orderby bp.DisplayOrder
select bp;
- return await query.ToListAsync2();
+ return await Task.FromResult(query.ToList());
}
#endregion
diff --git a/src/Business/Grand.Business.Cms/Services/NewsService.cs b/src/Business/Grand.Business.Cms/Services/NewsService.cs
index 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.Services
where (customerId == "" || c.CustomerId == customerId)
select c;
- return await query2.ToListAsync2();
+ return await Task.FromResult(query2.ToList());
}
#endregion
diff --git a/src/Business/Grand.Business.Cms/Services/PageLayoutService.cs b/src/Business/Grand.Business.Cms/Services/PageLayoutService.cs
index 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.Table
orderby pt.DisplayOrder
select 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.cs
index 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.Services
query = 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.Services
public 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.Table
select p;
@@ -125,7 +125,7 @@ namespace Grand.Business.Cms.Services
query = 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.cs
index 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.Addresses
public 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.Table
orderby aa.DisplayOrder
select 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.cs
index 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.Directory
select 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.Directory
var query = from c in _countryRepository.Table
where countryIds.Contains(c.Id)
select c;
- var countries = await query.ToListAsync2();
+ var countries = await Task.FromResult(query.ToList());
//sort by passed identifiers
var 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.cs
index 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.Directory
return 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.Table
where 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.Directory
public 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.Table
select p;
@@ -130,7 +130,7 @@ namespace Grand.Business.Common.Services.Directory
if (!showHidden)
query = query.Where(c => c.Published);
query = query.OrderBy(c => c.DisplayOrder);
- return query.ToListAsync2();
+ return await Task.FromResult(query.ToList());
});
//store acl
diff --git a/src/Business/Grand.Business.Common/Services/Directory/GroupService.cs b/src/Business/Grand.Business.Common/Services/Directory/GroupService.cs
index 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.Directory
public 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.Table
orderby cr.Name
select 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.cs
index 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.Directory
if (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.Directory
if (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.cs
index 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.Directory
public 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.Table
orderby md.DisplayOrder
select md;
- return query.ToListAsync2();
+ return await Task.FromResult(query.ToList());
});
}
@@ -271,12 +271,12 @@ namespace Grand.Business.Common.Services.Directory
public 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.Table
orderby mw.DisplayOrder
select mw;
- return query.ToListAsync2();
+ return await Task.FromResult(query.ToList());
});
}
@@ -430,12 +430,12 @@ namespace Grand.Business.Common.Services.Directory
public 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.Table
orderby md.DisplayOrder
select 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.cs
index 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.Localization
public 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.Table
select p;
@@ -64,7 +64,7 @@ namespace Grand.Business.Common.Services.Localization
if (!showHidden)
query = query.Where(l => l.Published);
query = query.OrderBy(l => l.DisplayOrder);
- return query.ToListAsync2();
+ return await Task.FromResult(query.ToList());
});
//store acl
diff --git a/src/Business/Grand.Business.Common/Services/Localization/TranslationService.cs b/src/Business/Grand.Business.Common/Services/Localization/TranslationService.cs
index 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.Table
orderby lsr.Name
where lsr.LanguageId == languageId && lsr.Name == name
select lsr;
- var translateResource = query.FirstOrDefaultAsync2();
+ var translateResource = await Task.FromResult(query.FirstOrDefault());
return translateResource;
}
@@ -296,9 +296,9 @@ namespace Grand.Business.Common.Services.Localization
continue;
//bulk insert
- var resource = await (from l in _translationRepository.Table
+ var resource = (from l in _translationRepository.Table
where 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.cs
index 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.Logging
var query = from alt in _activityLogTypeRepository.Table
orderby alt.Name
select 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.cs
index 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.Logging
where 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.cs
index 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.Security
string 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.Security
var query = from pr in _permissionRepository.Table
orderby pr.Name
select 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.Security
var 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.cs
index 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.Seo
ur.LanguageId == languageId &&
ur.IsActive
select 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.Seo
ur.LanguageId == languageId
select 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.cs
index 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.cs
index 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.Table
orderby a.Id
where 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.cs
index 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.Services
public 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.Table
orderby ca.DisplayOrder
select 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.cs
index 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.cs
index 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.Services
if (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.Services
query = query.OrderByDescending(x => x.CreatedOnUtc);
- return await query.ToListAsync2();
+ return await Task.FromResult(query.ToList());
}
#endregion
diff --git a/src/Business/Grand.Business.Customers/Services/CustomerService.cs b/src/Business/Grand.Business.Customers/Services/CustomerService.cs
index 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.Services
query = 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.Services
var query = from c in _customerRepository.Table
where customerIds.Contains(c.Id)
select c;
- var customers = await query.ToListAsync2();
+ var customers = query.ToList();
//sort by passed identifiers
var sortedCustomers = new List<Customer>();
foreach (var id in customerIds)
@@ -218,7 +218,7 @@ namespace Grand.Business.Customers.Services
if (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.cs
index 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.Table
orderby se.DisplayOrder
select 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.cs
index 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.cs
index 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.Services
var query = from c in _vendorRepository.Table
where 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());
}
#endregion
diff --git a/src/Business/Grand.Business.Marketing/Services/Banners/BannerService.cs b/src/Business/Grand.Business.Marketing/Services/Banners/BannerService.cs
index 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.Banners
var query = from c in _bannerRepository.Table
orderby c.CreatedOnUtc
select 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.cs
index 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.Campaigns
var query = from c in _campaignRepository.Table
orderby c.CreatedOnUtc
select 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.cs
index 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.Contacts
public 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.Table
select p;
@@ -102,7 +102,7 @@ namespace Grand.Business.Marketing.Services.Contacts
select 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.cs
index 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.Contacts
public 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.Contacts
orderby c.CreatedOnUtc
select 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.cs
index 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.Contacts
where c.CustomerId == customerId && c.Id == id
select 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.cs
index 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.Courses
where a.CustomerId == customerId && a.LessonId == lessonId
select 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.Table
where 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.cs
index 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.Courses
where c.CourseId == courseId
select 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.cs
index 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.Courses
orderby l.DisplayOrder
select 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.cs
index 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.cs
index 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.Courses
orderby c.DisplayOrder
select 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.cs
index 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.Customers
var 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.Table
where pp.CustomerId == customerId && pp.ProductId == productId
select 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.cs
index 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.Customers
var query = from p in _customerReminderRepository.Table
orderby p.DisplayOrder
select p;
- return await query.ToListAsync2();
+ return await Task.FromResult(query.ToList());
}
/// <summary>
@@ -682,30 +682,30 @@ namespace Grand.Business.Marketing.Services.Customers
var customerReminder = new List<CustomerReminder>();
if (String.IsNullOrEmpty(id))
{
- customerReminder = await (from cr in _customerReminderRepository.Table
+ customerReminder = (from cr in _customerReminderRepository.Table
where 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.Table
where 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.Table
where 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.Table
where 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.Customers
var customerReminder = new List<CustomerReminder>();
if (String.IsNullOrEmpty(id))
{
- customerReminder = await (from cr in _customerReminderRepository.Table
+ customerReminder = (from cr in _customerReminderRepository.Table
where 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.Table
where 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.Table
where 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.Table
where 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.Customers
var customerReminder = new List<CustomerReminder>();
if (String.IsNullOrEmpty(id))
{
- customerReminder = await (from cr in _customerReminderRepository.Table
+ customerReminder = (from cr in _customerReminderRepository.Table
where 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.Table
where 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.Table
where 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.Table
where 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.Customers
var customerReminder = new List<CustomerReminder>();
if (String.IsNullOrEmpty(id))
{
- customerReminder = await (from cr in _customerReminderRepository.Table
+ customerReminder = (from cr in _customerReminderRepository.Table
where 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.Table
where 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.Table
where 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.Table
where 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.Customers
var customerReminder = new List<CustomerReminder>();
if (String.IsNullOrEmpty(id))
{
- customerReminder = await (from cr in _customerReminderRepository.Table
+ customerReminder = (from cr in _customerReminderRepository.Table
where 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.Table
where 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.Customers
string dateDDMM = DateTime.Now.AddDays(day).ToString("-MM-dd");
- var customers = await (from cu in _customerRepository.Table
+ var customers = (from cu in _customerRepository.Table
where (!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.Table
where 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.Table
where 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.Customers
var customerReminder = new List<CustomerReminder>();
if (String.IsNullOrEmpty(id))
{
- customerReminder = await (from cr in _customerReminderRepository.Table
+ customerReminder = (from cr in _customerReminderRepository.Table
where 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.Table
where 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.Customers
if (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.Table
where 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.Table
where 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.Table
where 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.Customers
var customerReminder = new List<CustomerReminder>();
if (String.IsNullOrEmpty(id))
{
- customerReminder = await (from cr in _customerReminderRepository.Table
+ customerReminder = (from cr in _customerReminderRepository.Table
where 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.Table
where 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.Customers
if (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.Table
where 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.Table
where 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.Table
where 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.cs
index 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.Table
where pt.Name == name
select pt;
- return query.FirstOrDefaultAsync2();
+ return await Task.FromResult(query.FirstOrDefault());
}
/// <summary>
@@ -123,7 +123,7 @@ namespace Grand.Business.Marketing.Services.Customers
var query = from pt in _customerTagRepository.Table
where 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.Customers
public 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.Table
where (cr.CustomerTagId == customerTagId)
orderby cr.DisplayOrder
select 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.cs
index 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.Documents
var query = from t in _documentTypeRepository.Table
orderby t.DisplayOrder
select 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.cs
index 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.Knowledgebase
select 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.Knowledgebase
select 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.Knowledgebase
select 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.Table
select p;
@@ -352,7 +352,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebase
select p;
}
- return query.FirstOrDefaultAsync2();
+ return await Task.FromResult(query.FirstOrDefault());
});
}
@@ -389,7 +389,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebase
select 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.Knowledgebase
select 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.Knowledgebase
select 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.Knowledgebase
select 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.Knowledgebase
orderby c.CreatedOnUtc
where (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.Knowledgebase
var query = from bc in _articleCommentRepository.Table
where commentIds.Contains(bc.Id)
select bc;
- var comments = await query.ToListAsync2();
+ var comments = query.ToList();
//sort by passed identifiers
var sortedComments = new List<KnowledgebaseArticleComment>();
foreach (string id in commentIds)
@@ -617,7 +617,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebase
if (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.Knowledgebase
where c.ArticleId == articleId
orderby c.CreatedOnUtc
select 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.cs
index 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.Newsteletters
where !p.LimitedToStores || p.Stores.Contains(storeId)
orderby p.DisplayOrder
select 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.cs
index 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.cs
index 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.Handlers
public 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.cs
index 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.Table
orderby ea.Id
select 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.cs
index 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.Services
query = 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 acl
if (!String.IsNullOrEmpty(storeId))
@@ -149,7 +149,7 @@ namespace Grand.Business.Messages.Services
public 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.Table
select p;
@@ -164,7 +164,7 @@ namespace Grand.Business.Messages.Services
select 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.cs
index 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.Services
var query = from qe in _queuedEmailRepository.Table
where queuedEmailIds.Contains(qe.Id)
select qe;
- var queuedEmails = await query.ToListAsync2();
+ var queuedEmails = query.ToList();
//sort by passed identifiers
var sortedQueuedEmails = new List<QueuedEmail>();
foreach (string id in queuedEmailIds)
@@ -120,7 +120,7 @@ namespace Grand.Business.Messages.Services
if (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.cs
index 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.Services
where o.DownloadGuid == downloadGuid
select 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.cs
index 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();
//warehouse
if (!string.IsNullOrEmpty(warehouseId))
@@ -79,7 +79,7 @@ namespace Grand.Business.System.Commands.Handlers.Catalog
query = 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.cs
index 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.Admin
var query = from c in _adminSiteMapRepository.Table
select 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.cs
index 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.Reports
SumOrders = r.SumOrders
});
- return await report.ToListAsync2();
+ return await Task.FromResult(report.ToList());
}
@@ -133,14 +133,14 @@ namespace Grand.Business.System.Services.Reports
var 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.Reports
Day = 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.Reports
if (!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.Reports
SumTax = decimal.Zero,
SumOrders = decimal.Zero,
};
- return item2;
+ return await Task.FromResult(item2);
}
/// <summary>
@@ -421,11 +418,11 @@ namespace Grand.Business.System.Services.Reports
TotalQuantity = 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 g
select 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.Reports
if (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.Reports
createdFromUtc = !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.Table
where
(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.Table
orderby p.Name
diff --git a/src/Business/Grand.Business.System/Services/Reports/ProductsReportService.cs b/src/Business/Grand.Business.System/Services/Reports/ProductsReportService.cs
index 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.Reports
if (!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 attributes
var query2_1 = from p in _productRepository.Table
@@ -77,9 +77,9 @@ namespace Grand.Business.System.Services.Reports
where c.StockQuantity <= 0
select 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.cs
deleted file mode 100644
index 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();
- }
-
- }
-}