Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Grand.Business.Core.Commands.Customers;
using Grand.Business.Core.Commands.Customers;
using Grand.Business.Core.Events.Customers;
using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Authentication;
Expand Down Expand Up @@ -327,7 +327,7 @@ public virtual async Task<IList<ExternalAuthentication>> GetExternalIdentifiers(
var query = from p in _externalAuthenticationRecordRepository.Table
where p.CustomerId == customer.Id
select p;
return await Task.FromResult(query.ToList());
return await _externalAuthenticationRecordRepository.ToListAsync(query);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Grand.Business.Core.Interfaces.Catalog.Brands;
using Grand.Business.Core.Interfaces.Catalog.Brands;
using Grand.Data;
using Grand.Domain.Catalog;
using Grand.Infrastructure.Caching;
Expand Down Expand Up @@ -53,7 +53,7 @@ public virtual async Task<IList<BrandLayout>> GetAllBrandLayouts()
var query = from pt in _brandLayoutRepository.Table
orderby pt.DisplayOrder
select pt;
return await Task.FromResult(query.ToList());
return await _brandLayoutRepository.ToListAsync(query);
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Grand.Business.Core.Interfaces.Catalog.Brands;
using Grand.Business.Core.Interfaces.Catalog.Brands;
using Grand.Data;
using Grand.Domain;
using Grand.Domain.Catalog;
Expand Down Expand Up @@ -166,7 +166,7 @@ public virtual async Task<IList<Brand>> GetAllBrandsByDiscount(string discountId
where c.AppliedDiscounts.Any(x => x == discountId)
select c;

return await Task.FromResult(query.ToList());
return await _brandRepository.ToListAsync(query);
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Grand.Business.Core.Interfaces.Catalog.Categories;
using Grand.Business.Core.Interfaces.Catalog.Categories;
using Grand.Data;
using Grand.Domain.Catalog;
using Grand.Infrastructure.Caching;
Expand Down Expand Up @@ -53,7 +53,7 @@ public virtual async Task<IList<CategoryLayout>> GetAllCategoryLayouts()
var query = from pt in _categoryLayoutRepository.Table
orderby pt.DisplayOrder
select pt;
return await Task.FromResult(query.ToList());
return await _categoryLayoutRepository.ToListAsync(query);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public virtual async Task<IList<Category>> GetMenuCategories()
{
case true when
string.IsNullOrEmpty(CurrentStore.Id) || _accessControlConfig.IgnoreStoreLimitations:
return await Task.FromResult(query.ToList());
return await _categoryRepository.ToListAsync(query);
case false:
{
//Limited to customer group (access control list)
Expand All @@ -146,7 +146,7 @@ public virtual async Task<IList<Category>> GetMenuCategories()
query = from p in query
where !p.LimitedToStores || p.Stores.Contains(CurrentStore.Id)
select p;
return await Task.FromResult(query.ToList());
return await _categoryRepository.ToListAsync(query);
}

/// <summary>
Expand Down Expand Up @@ -217,7 +217,7 @@ public virtual async Task<IList<Category>> GetAllCategoriesDisplayedOnHomePage(b
var query = _categoryRepository.Table
.Where(x => x.Published && x.ShowOnHomePage)
.OrderBy(x => x.DisplayOrder);
var categories = await Task.FromResult(query.ToList());
var categories = await _categoryRepository.ToListAsync(query);
if (!showHidden)
categories = categories
.Where(c => _aclService.Authorize(c, CurrentCustomer) &&
Expand All @@ -238,7 +238,7 @@ public virtual async Task<IList<Category>> GetAllCategoriesFeaturedProductsOnHom
.Where(x => x.Published && x.FeaturedProductsOnHomePage)
.OrderBy(x => x.DisplayOrder);

var categories = await Task.FromResult(query.ToList());
var categories = await _categoryRepository.ToListAsync(query);
if (!showHidden)
categories = categories
.Where(c => _aclService.Authorize(c, CurrentCustomer) &&
Expand All @@ -257,7 +257,7 @@ public virtual async Task<IList<Category>> GetAllCategoriesSearchBox()
.Where(x => x.Published && x.ShowOnSearchBox)
.OrderBy(x => x.SearchBoxDisplayOrder);

var categories = (await Task.FromResult(query.ToList()))
var categories = (await _categoryRepository.ToListAsync(query))
.Where(c => _aclService.Authorize(c, CurrentCustomer) &&
_aclService.Authorize(c, CurrentStore.Id))
.ToList();
Expand Down Expand Up @@ -392,7 +392,7 @@ public virtual async Task<IList<Category>> GetAllCategoriesByDiscount(string dis
where c.AppliedDiscounts.Any(x => x == discountId)
select c;

return await Task.FromResult(query.ToList());
return await _categoryRepository.ToListAsync(query);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Grand.Business.Core.Interfaces.Catalog.Collections;
using Grand.Business.Core.Interfaces.Catalog.Collections;
using Grand.Data;
using Grand.Domain.Catalog;
using Grand.Infrastructure.Caching;
Expand Down Expand Up @@ -53,7 +53,7 @@ public virtual async Task<IList<CollectionLayout>> GetAllCollectionLayouts()
var query = from pt in _collectionLayoutRepository.Table
orderby pt.DisplayOrder
select pt;
return await Task.FromResult(query.ToList());
return await _collectionLayoutRepository.ToListAsync(query);
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Grand.Business.Core.Interfaces.Catalog.Collections;
using Grand.Business.Core.Interfaces.Catalog.Collections;
using Grand.Business.Core.Interfaces.Common.Security;
using Grand.Data;
using Grand.Domain;
Expand Down Expand Up @@ -109,7 +109,7 @@ public virtual async Task<IList<Collection>> GetAllCollectionFeaturedProductsOnH
var query = _collectionRepository.Table.Where(x => x.Published && x.FeaturedProductsOnHomePage)
.OrderBy(x => x.DisplayOrder);

var collections = await Task.FromResult(query.ToList());
var collections = await _collectionRepository.ToListAsync(query);
if (!showHidden)
collections = collections
.Where(c => _aclService.Authorize(c, _contextAccessor.WorkContext.CurrentCustomer) &&
Expand Down Expand Up @@ -193,7 +193,7 @@ public virtual async Task<IList<Collection>> GetAllCollectionsByDiscount(string
where c.AppliedDiscounts.Any(x => x == discountId)
select c;

return await Task.FromResult(query.ToList());
return await _collectionRepository.ToListAsync(query);
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Grand.Business.Core.Interfaces.Catalog.Directory;
using Grand.Business.Core.Interfaces.Catalog.Directory;
using Grand.Data;
using Grand.Domain.Directory;
using Grand.Infrastructure.Caching;
Expand Down Expand Up @@ -94,7 +94,7 @@ public virtual async Task<IList<MeasureDimension>> GetAllMeasureDimensions()
var query = from md in _measureDimensionRepository.Table
orderby md.DisplayOrder
select md;
return await Task.FromResult(query.ToList());
return await _measureDimensionRepository.ToListAsync(query);
});
}

Expand Down Expand Up @@ -250,7 +250,7 @@ public virtual async Task<IList<MeasureWeight>> GetAllMeasureWeights()
var query = from mw in _measureWeightRepository.Table
orderby mw.DisplayOrder
select mw;
return await Task.FromResult(query.ToList());
return await _measureWeightRepository.ToListAsync(query);
});
}

Expand Down Expand Up @@ -391,7 +391,7 @@ public virtual async Task<IList<MeasureUnit>> GetAllMeasureUnits()
var query = from md in _measureUnitRepository.Table
orderby md.DisplayOrder
select md;
return await Task.FromResult(query.ToList());
return await _measureUnitRepository.ToListAsync(query);
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Grand.Business.Core.Interfaces.Catalog.Directory;
using Grand.Business.Core.Interfaces.Catalog.Directory;
using Grand.Business.Core.Utilities.Catalog;
using Grand.Data;
using Grand.Domain;
Expand Down Expand Up @@ -71,7 +71,7 @@ public virtual async Task<SearchTerm> GetSearchTermByKeyword(string keyword, str
var query = from st in _searchTermRepository.Table
where st.Keyword == keyword && st.StoreId == storeId
select st;
return await Task.FromResult(query.FirstOrDefault());
return await _searchTermRepository.FirstOrDefaultAsync(query);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public virtual async Task<IList<Discount>> GetDiscountsQuery(DiscountType? disco

query = query.OrderBy(d => d.Name);

return await Task.FromResult(query.ToList());
return await _discountRepository.ToListAsync(query);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public async Task<bool> ExistsCodeInDiscount(string couponCode, string discountI
if (used.HasValue)
query = query.Where(x => x.Used == used.Value);

var result = await Task.FromResult(query.ToList());
var result = await _discountCouponRepository.ToListAsync(query);
return result.Count != 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ public virtual async Task UpdateHighestBid(Product product, double bid, string h

public virtual async Task<IList<Product>> GetAuctionsToEnd()
{
return await Task.FromResult(_productRepository.Table
return await _productRepository.ToListAsync(_productRepository.Table
.Where(x => x.ProductTypeId == ProductType.Auction &&
!x.AuctionEnded && x.AvailableEndDateTimeUtc < DateTime.UtcNow).ToList());
!x.AuctionEnded && x.AvailableEndDateTimeUtc < DateTime.UtcNow));
}

public virtual async Task UpdateAuctionEnded(Product product, bool ended, bool endDate = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,9 @@ public virtual async Task<IList<CustomerGroupProduct>> GetCustomerGroupProducts(
var key = string.Format(CacheKey.CUSTOMERGROUPSPRODUCTS_ROLE_KEY, customerGroupId);
return await _cacheBase.GetAsync(key, async () =>
{
return await Task.FromResult(_customerGroupProductRepository
return (await _customerGroupProductRepository.ToListAsync(_customerGroupProductRepository
.Table.Where(x => x.CustomerGroupId == customerGroupId)
.OrderBy(x => x.DisplayOrder)
.ToList());
.OrderBy(x => x.DisplayOrder))).ToList();
});
}

Expand All @@ -110,9 +109,9 @@ public virtual async Task<IList<CustomerGroupProduct>> GetCustomerGroupProducts(
/// <returns>Customer group product</returns>
public virtual async Task<CustomerGroupProduct> GetCustomerGroupProduct(string customerGroupId, string productId)
{
return await Task.FromResult(_customerGroupProductRepository.Table
return await _customerGroupProductRepository.FirstOrDefaultAsync(_customerGroupProductRepository.Table
.Where(x => x.CustomerGroupId == customerGroupId && x.ProductId == productId)
.OrderBy(x => x.DisplayOrder).FirstOrDefault());
.OrderBy(x => x.DisplayOrder));
}

/// <summary>
Expand All @@ -127,7 +126,7 @@ public virtual async Task<CustomerGroupProduct> GetCustomerGroupProductById(stri
orderby cr.DisplayOrder
select cr;

return await Task.FromResult(query.FirstOrDefault());
return await _customerGroupProductRepository.FirstOrDefaultAsync(query);
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private async Task<bool> CheckExistsInventoryJournal(Product product, ShipmentIt
where j.ProductId == product.Id && j.PositionId == shipmentItem.Id
select j.Id;

return await Task.FromResult(query.Any());
return await _inventoryJournalRepository.AnyAsync(query);
}

private async Task ReverseBookedInventory(Product product, InventoryJournal inventoryJournal)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Grand.Business.Core.Commands.Catalog;
using Grand.Business.Core.Commands.Catalog;
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Data;
using Grand.Domain;
Expand Down Expand Up @@ -82,7 +82,7 @@ orderby biss.CreatedOnUtc descending
biss.WarehouseId == warehouseId
select biss;

var outOfStockSubscriptionlist = await Task.FromResult(query.ToList());
var outOfStockSubscriptionlist = await _outOfStockSubscriptionRepository.ToListAsync(query);
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();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Data;
using Grand.Domain.Catalog;
using Grand.Infrastructure.Caching;
Expand Down Expand Up @@ -53,7 +53,7 @@ public virtual async Task<IList<ProductLayout>> GetAllProductLayouts()
var query = from pt in _productLayoutRepository.Table
orderby pt.DisplayOrder
select pt;
return await Task.FromResult(query.ToList());
return await _productLayoutRepository.ToListAsync(query);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ public virtual Task<CustomerReservationsHelper> GetCustomerReservationsHelperByI
/// </returns>
public virtual async Task<IList<CustomerReservationsHelper>> GetCustomerReservationsHelpers(string customerId)
{
return await Task.FromResult(_customerReservationsHelperRepository.Table.Where(x => x.CustomerId == customerId)
.ToList());
return await _customerReservationsHelperRepository.ToListAsync(
_customerReservationsHelperRepository.Table.Where(x => x.CustomerId == customerId));
}

/// <summary>
Expand All @@ -182,7 +182,7 @@ public virtual async Task<IList<CustomerReservationsHelper>> GetCustomerReservat
/// </returns>
public virtual async Task<IList<CustomerReservationsHelper>> GetCustomerReservationsHelperBySciId(string sciId)
{
return await Task.FromResult(_customerReservationsHelperRepository.Table
.Where(x => x.ShoppingCartItemId == sciId).ToList());
return await _customerReservationsHelperRepository.ToListAsync(
_customerReservationsHelperRepository.Table.Where(x => x.ShoppingCartItemId == sciId));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Grand.Business.Core.Events.Catalog;
using Grand.Business.Core.Events.Catalog;
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Common.Security;
using Grand.Business.Core.Queries.Catalog;
Expand Down Expand Up @@ -65,7 +65,7 @@ public virtual async Task<IList<string>> GetAllProductsDisplayedOnHomePage()
var query = _productRepository.Table.Where(x => x.Published && x.ShowOnHomePage && x.VisibleIndividually)
.OrderBy(x => x.DisplayOrder).ThenBy(x => x.Name).Select(x => x.Id);

return await Task.FromResult(query.ToList());
return await _productRepository.ToListAsync(query);
}

/// <summary>
Expand All @@ -78,7 +78,7 @@ public virtual async Task<IList<string>> GetAllProductsDisplayedOnBestSeller()
.OrderBy(x => x.DisplayOrder).ThenBy(x => x.Name)
.Select(x => x.Id);

var products = await Task.FromResult(query.ToList());
var products = await _productRepository.ToListAsync(query);

return products;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Data;
using Grand.Domain.Catalog;
using Grand.Infrastructure.Caching;
Expand Down Expand Up @@ -74,7 +74,7 @@ private async Task<Dictionary<string, int>> GetProductCount()
public virtual async Task<IList<ProductTag>> GetAllProductTags()
{
return await _cacheBase.GetAsync(CacheKey.PRODUCTTAG_ALL_KEY,
async () => await Task.FromResult(_productTagRepository.Table.ToList()));
async () => await _productTagRepository.ToListAsync(_productTagRepository.Table));
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Data;
using Grand.Domain.Catalog;
using Grand.Infrastructure.Caching;
Expand Down Expand Up @@ -70,7 +70,7 @@ protected async Task<IList<string>> GetRecentlyViewedProductsIds(string customer
where p.CustomerId == customerId
orderby p.CreatedOnUtc descending
select p.ProductId;
return await Task.FromResult(query.Take(number).ToList());
return await _recentlyViewedProducts.ToListAsync(query.Take(number));
});
}

Expand Down
Loading
Loading