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.

Refactoring - use repository extensions (marketing service)

KrzysztofPajak80ced56d6686
diff --git a/src/Business/Grand.Business.Marketing/Services/Banners/BannerService.cs b/src/Business/Grand.Business.Marketing/Services/Banners/BannerService.cs
index c50bb0293..4a7762e15 100644
--- a/src/Business/Grand.Business.Marketing/Services/Banners/BannerService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Banners/BannerService.cs
@@ -3,8 +3,6 @@ using Grand.Infrastructure.Extensions;
using Grand.Domain.Data;
using Grand.Domain.Messages;
using MediatR;
-using MongoDB.Driver;
-using MongoDB.Driver.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -94,7 +92,7 @@ namespace Grand.Business.Marketing.Services.Banners
var query = from c in _bannerRepository.Table
orderby c.CreatedOnUtc
select c;
- return await query.ToListAsync();
+ return await query.ToListAsync2();
}
}
diff --git a/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.cs b/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.cs
index 48f8ef46c..1fec33331 100644
--- a/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.cs
@@ -11,8 +11,6 @@ using Grand.Domain.Customers;
using Grand.Domain.Data;
using Grand.Domain.Messages;
using MediatR;
-using MongoDB.Driver;
-using MongoDB.Driver.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -142,7 +140,7 @@ namespace Grand.Business.Marketing.Services.Campaigns
var query = from c in _campaignRepository.Table
orderby c.CreatedOnUtc
select c;
- return await query.ToListAsync();
+ return await query.ToListAsync2();
}
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 b6f926914..ac4b1cbe4 100644
--- a/src/Business/Grand.Business.Marketing/Services/Contacts/ContactAttributeService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Contacts/ContactAttributeService.cs
@@ -1,20 +1,17 @@
using Grand.Business.Marketing.Interfaces.Contacts;
+using Grand.Domain.Customers;
+using Grand.Domain.Data;
+using Grand.Domain.Messages;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Caching.Constants;
using Grand.Infrastructure.Extensions;
-using Grand.Domain.Catalog;
-using Grand.Domain.Customers;
-using Grand.Domain.Data;
-using Grand.Domain.Messages;
+using Grand.SharedKernel.Extensions;
using MediatR;
-using MongoDB.Driver;
-using MongoDB.Driver.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
-using Grand.SharedKernel.Extensions;
namespace Grand.Business.Marketing.Services.Contacts
{
@@ -82,7 +79,9 @@ namespace Grand.Business.Marketing.Services.Contacts
string key = string.Format(CacheKey.CONTACTATTRIBUTES_ALL_KEY, storeId, ignorAcl);
return await _cacheBase.GetAsync(key, () =>
{
- var query = _contactAttributeRepository.Table;
+ var query = from p in _contactAttributeRepository.Table
+ select p;
+
query = query.OrderBy(c => c.DisplayOrder);
if ((!String.IsNullOrEmpty(storeId) && !CommonHelper.IgnoreStoreLimitations) ||
@@ -103,7 +102,7 @@ namespace Grand.Business.Marketing.Services.Contacts
select p;
}
}
- return query.ToListAsync();
+ return query.ToListAsync2();
});
}
diff --git a/src/Business/Grand.Business.Marketing/Services/Contacts/ContactUsService.cs b/src/Business/Grand.Business.Marketing/Services/Contacts/ContactUsService.cs
index ef4973aba..693592a84 100644
--- a/src/Business/Grand.Business.Marketing/Services/Contacts/ContactUsService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Contacts/ContactUsService.cs
@@ -4,9 +4,9 @@ using Grand.Domain;
using Grand.Domain.Data;
using Grand.Domain.Messages;
using MediatR;
-using MongoDB.Driver;
using System;
using System.Threading.Tasks;
+using System.Linq;
namespace Grand.Business.Marketing.Services.Contacts
{
@@ -65,26 +65,26 @@ namespace Grand.Business.Marketing.Services.Contacts
string email = "", string vendorId = "", string customerId = "", string storeId = "",
int pageIndex = 0, int pageSize = int.MaxValue)
{
- var builder = Builders<ContactUs>.Filter;
- var filter = builder.Where(c => true);
+
+ var query = from c in _contactusRepository.Table
+ select c;
if (fromUtc.HasValue)
- filter = filter & builder.Where(l => fromUtc.Value <= l.CreatedOnUtc);
+ query = query.Where(l => fromUtc.Value <= l.CreatedOnUtc);
if (toUtc.HasValue)
- filter = filter & builder.Where(l => toUtc.Value >= l.CreatedOnUtc);
+ query = query.Where(l => toUtc.Value >= l.CreatedOnUtc);
if (!String.IsNullOrEmpty(vendorId))
- filter = filter & builder.Where(l => vendorId == l.VendorId);
+ query = query.Where(l => vendorId == l.VendorId);
if (!String.IsNullOrEmpty(customerId))
- filter = filter & builder.Where(l => customerId == l.CustomerId);
+ query = query.Where(l => customerId == l.CustomerId);
if (!String.IsNullOrEmpty(storeId))
- filter = filter & builder.Where(l => storeId == l.StoreId);
+ query = query.Where(l => storeId == l.StoreId);
if (!String.IsNullOrEmpty(email))
- filter = filter & builder.Where(l => l.Email.ToLower().Contains(email.ToLower()));
+ query = query.Where(l => l.Email.ToLower().Contains(email.ToLower()));
- var builderSort = Builders<ContactUs>.Sort.Descending(x => x.CreatedOnUtc);
- var query = _contactusRepository.Collection;
- var contactus = await PagedList<ContactUs>.Create(query, filter, builderSort, pageIndex, pageSize);
+ query = query.OrderByDescending(x => x.CreatedOnUtc);
+ var contactus = await PagedList<ContactUs>.Create(query, pageIndex, pageSize);
return contactus;
}
diff --git a/src/Business/Grand.Business.Marketing/Services/Contacts/InteractiveFormService.cs b/src/Business/Grand.Business.Marketing/Services/Contacts/InteractiveFormService.cs
index b852838d8..49ce77946 100644
--- a/src/Business/Grand.Business.Marketing/Services/Contacts/InteractiveFormService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Contacts/InteractiveFormService.cs
@@ -3,8 +3,6 @@ using Grand.Infrastructure.Extensions;
using Grand.Domain.Data;
using Grand.Domain.Messages;
using MediatR;
-using MongoDB.Driver;
-using MongoDB.Driver.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -95,7 +93,7 @@ namespace Grand.Business.Marketing.Services.Contacts
if (string.IsNullOrEmpty(systemName))
throw new ArgumentNullException("systemName");
- return await _formRepository.Table.FirstOrDefaultAsync(x => x.SystemName == systemName);
+ return await _formRepository.Table.Where(x => x.SystemName == systemName).FirstOrDefaultAsync2();
}
/// <summary>
@@ -108,7 +106,8 @@ namespace Grand.Business.Marketing.Services.Contacts
var query = from c in _formRepository.Table
orderby c.CreatedOnUtc
select c;
- return await query.ToListAsync();
+
+ return await query.ToListAsync2();
}
}
diff --git a/src/Business/Grand.Business.Marketing/Services/Contacts/PopupService.cs b/src/Business/Grand.Business.Marketing/Services/Contacts/PopupService.cs
index e3c18a990..b76876526 100644
--- a/src/Business/Grand.Business.Marketing/Services/Contacts/PopupService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Contacts/PopupService.cs
@@ -3,8 +3,6 @@ using Grand.Infrastructure.Extensions;
using Grand.Domain.Data;
using Grand.Domain.Messages;
using MediatR;
-using MongoDB.Driver;
-using MongoDB.Driver.Linq;
using System;
using System.Linq;
using System.Threading.Tasks;
@@ -54,7 +52,7 @@ namespace Grand.Business.Marketing.Services.Contacts
where c.CustomerId == customerId
orderby c.CreatedOnUtc
select c;
- return await query.FirstOrDefaultAsync();
+ return await query.FirstOrDefaultAsync2();
}
public virtual async Task MovepopupToArchive(string id, string customerId)
@@ -66,7 +64,7 @@ namespace Grand.Business.Marketing.Services.Contacts
where c.CustomerId == customerId && c.Id == id
select c;
- var popup = await query.FirstOrDefaultAsync();
+ var popup = await query.FirstOrDefaultAsync2();
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 b344d7632..d2dbdca46 100644
--- a/src/Business/Grand.Business.Marketing/Services/Courses/CourseActionService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Courses/CourseActionService.cs
@@ -3,10 +3,9 @@ using Grand.Infrastructure.Extensions;
using Grand.Domain.Courses;
using Grand.Domain.Data;
using MediatR;
-using MongoDB.Driver;
-using MongoDB.Driver.Linq;
using System;
using System.Threading.Tasks;
+using System.Linq;
namespace Grand.Business.Marketing.Services.Courses
{
@@ -31,14 +30,14 @@ namespace Grand.Business.Marketing.Services.Courses
where a.CustomerId == customerId && a.LessonId == lessonId
select a;
- return await query.FirstOrDefaultAsync();
+ return await query.FirstOrDefaultAsync2();
}
public virtual async Task<bool> CustomerLessonCompleted(string customerId, string lessonId)
{
var query = await (from a in _courseActionRepository.Table
where a.CustomerId == customerId && a.LessonId == lessonId
- select a).FirstOrDefaultAsync();
+ select a).FirstOrDefaultAsync2();
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 ca7871089..76e18e9dc 100644
--- a/src/Business/Grand.Business.Marketing/Services/Courses/CourseLessonService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Courses/CourseLessonService.cs
@@ -3,8 +3,6 @@ using Grand.Infrastructure.Extensions;
using Grand.Domain.Courses;
using Grand.Domain.Data;
using MediatR;
-using MongoDB.Driver;
-using MongoDB.Driver.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -43,7 +41,7 @@ namespace Grand.Business.Marketing.Services.Courses
where c.CourseId == courseId
select c;
- return await query.ToListAsync();
+ return await query.ToListAsync2();
}
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 0eb6fcbb5..90063475d 100644
--- a/src/Business/Grand.Business.Marketing/Services/Courses/CourseLevelService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Courses/CourseLevelService.cs
@@ -3,11 +3,10 @@ using Grand.Infrastructure.Extensions;
using Grand.Domain.Courses;
using Grand.Domain.Data;
using MediatR;
-using MongoDB.Driver;
-using MongoDB.Driver.Linq;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
+using System.Linq;
namespace Grand.Business.Marketing.Services.Courses
{
@@ -39,7 +38,7 @@ namespace Grand.Business.Marketing.Services.Courses
orderby l.DisplayOrder
select l;
- return await query.ToListAsync();
+ return await query.ToListAsync2();
}
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 56827c566..b45b755e2 100644
--- a/src/Business/Grand.Business.Marketing/Services/Courses/CourseService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Courses/CourseService.cs
@@ -7,8 +7,6 @@ using Grand.Domain.Orders;
using Grand.Infrastructure.Extensions;
using Grand.SharedKernel.Extensions;
using MediatR;
-using MongoDB.Driver;
-using MongoDB.Driver.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -77,15 +75,15 @@ namespace Grand.Business.Marketing.Services.Courses
}
//courses without assigned product
- var q1 = await query.Where(x => string.IsNullOrEmpty(x.ProductId)).ToListAsync();
+ var q1 = await query.Where(x => string.IsNullOrEmpty(x.ProductId)).ToListAsync2();
//get products from orders - paid/not deleted/for customer/store
var pl = await _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().ToListAsync();
+ && x.StoreId == storeId).SelectMany(x => x.OrderItems, (p, pr) => pr.ProductId).Distinct().ToListAsync2();
//courses assigned to products
- var q2 = await query.Where(x => pl.Contains(x.ProductId)).ToListAsync();
+ var q2 = await query.Where(x => pl.Contains(x.ProductId)).ToListAsync2();
return q1.Concat(q2).ToList();
}
diff --git a/src/Business/Grand.Business.Marketing/Services/Courses/CourseSubjectService.cs b/src/Business/Grand.Business.Marketing/Services/Courses/CourseSubjectService.cs
index b3346e870..486f54f56 100644
--- a/src/Business/Grand.Business.Marketing/Services/Courses/CourseSubjectService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Courses/CourseSubjectService.cs
@@ -3,8 +3,6 @@ using Grand.Infrastructure.Extensions;
using Grand.Domain.Courses;
using Grand.Domain.Data;
using MediatR;
-using MongoDB.Driver;
-using MongoDB.Driver.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -44,7 +42,7 @@ namespace Grand.Business.Marketing.Services.Courses
orderby c.DisplayOrder
select c;
- return await query.ToListAsync();
+ return await query.ToListAsync2();
}
public virtual Task<CourseSubject> GetById(string id)
diff --git a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerActionEventService.cs b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerActionEventService.cs
index 79fde0125..14e070f68 100644
--- a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerActionEventService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerActionEventService.cs
@@ -7,8 +7,6 @@ using Grand.Domain.Customers;
using Grand.Domain.Data;
using Grand.Domain.Orders;
using MediatR;
-using MongoDB.Driver;
-using MongoDB.Driver.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -52,7 +50,7 @@ namespace Grand.Business.Marketing.Services.Customers
{
return await _cacheBase.GetAsync(CacheKey.CUSTOMER_ACTION_TYPE, () =>
{
- return _customerActionTypeRepository.Table.ToListAsync();
+ return _customerActionTypeRepository.Table.ToListAsync2();
});
}
diff --git a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerActionService.cs b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerActionService.cs
index 2305fb442..a13b4c304 100644
--- a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerActionService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerActionService.cs
@@ -6,8 +6,6 @@ using Grand.Domain;
using Grand.Domain.Customers;
using Grand.Domain.Data;
using MediatR;
-using MongoDB.Driver;
-using MongoDB.Driver.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -64,7 +62,7 @@ namespace Grand.Business.Marketing.Services.Customers
public virtual async Task<IList<CustomerAction>> GetCustomerActions()
{
var query = _customerActionRepository.Table;
- return await query.ToListAsync();
+ return await query.ToListAsync2();
}
/// <summary>
@@ -121,7 +119,7 @@ namespace Grand.Business.Marketing.Services.Customers
public virtual async Task<IList<CustomerActionType>> GetCustomerActionType()
{
var query = _customerActionTypeRepository.Table;
- return await query.ToListAsync();
+ return await query.ToListAsync2();
}
public virtual async Task<IPagedList<CustomerActionHistory>> GetAllCustomerActionHistory(string customerActionId, int pageIndex = 0, int pageSize = 2147483647)
diff --git a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerCoordinatesService.cs b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerCoordinatesService.cs
index 0887710e4..75dd5ce37 100644
--- a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerCoordinatesService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerCoordinatesService.cs
@@ -4,7 +4,6 @@ using Grand.Infrastructure;
using Grand.Domain.Customers;
using Grand.Domain.Data;
using MediatR;
-using MongoDB.Driver;
using System;
using System.Threading.Tasks;
@@ -49,13 +48,8 @@ namespace Grand.Business.Marketing.Services.Customers
var coordinates = new MongoDB.Driver.GeoJsonObjectModel.GeoJson2DCoordinates(longitude, latitude);
customer.Coordinates = coordinates;
- var builder = Builders<Customer>.Filter;
- var filter = builder.Eq(x => x.Id, customer.Id);
- var update = Builders<Customer>.Update
- .Set(x => x.Coordinates, coordinates);
-
//update customer
- await _customerRepository.Collection.UpdateOneAsync(filter, update);
+ await _customerRepository.UpdateField(customer.Id, x => x.Coordinates, coordinates);
//raise event
await _mediator.Publish(new CustomerCoordinatesEvent(customer));
diff --git a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerProductService.cs b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerProductService.cs
index 56ecd3c0b..85cfbdaf8 100644
--- a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerProductService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerProductService.cs
@@ -6,9 +6,9 @@ using Grand.Domain;
using Grand.Domain.Customers;
using Grand.Domain.Data;
using MediatR;
-using MongoDB.Driver.Linq;
using System;
using System.Threading.Tasks;
+using System.Linq;
namespace Grand.Business.Marketing.Services.Customers
{
@@ -58,9 +58,8 @@ 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)
- .FirstOrDefaultAsync();
+ var pp = await _customerProductPriceRepository.Table.Where(x => x.CustomerId == customerId && x.ProductId == productId)
+ .FirstOrDefaultAsync2();
if (pp == null)
return (null, false);
else
@@ -161,7 +160,7 @@ namespace Grand.Business.Marketing.Services.Customers
where pp.CustomerId == customerId && pp.ProductId == productId
select pp;
- return query.FirstOrDefaultAsync();
+ return query.FirstOrDefaultAsync2();
}
/// <summary>
diff --git a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerReminderService.cs b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerReminderService.cs
index fab706d31..a8de50012 100644
--- a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerReminderService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerReminderService.cs
@@ -17,8 +17,6 @@ using Grand.Domain.Orders;
using Grand.Domain.Payments;
using Grand.SharedKernel.Extensions;
using MediatR;
-using MongoDB.Driver;
-using MongoDB.Driver.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -610,7 +608,7 @@ namespace Grand.Business.Marketing.Services.Customers
var query = from p in _customerReminderRepository.Table
orderby p.DisplayOrder
select p;
- return await query.ToListAsync();
+ return await query.ToListAsync2();
}
/// <summary>
@@ -687,13 +685,13 @@ namespace Grand.Business.Marketing.Services.Customers
customerReminder = await (from cr in _customerReminderRepository.Table
where cr.Active && datetimeUtcNow >= cr.StartDateTimeUtc && datetimeUtcNow <= cr.EndDateTimeUtc
&& cr.ReminderRuleId == CustomerReminderRuleEnum.AbandonedCart
- select cr).ToListAsync();
+ select cr).ToListAsync2();
}
else
{
customerReminder = await (from cr in _customerReminderRepository.Table
where cr.Id == id && cr.ReminderRuleId == CustomerReminderRuleEnum.AbandonedCart
- select cr).ToListAsync();
+ select cr).ToListAsync2();
}
foreach (var reminder in customerReminder)
@@ -701,13 +699,13 @@ namespace Grand.Business.Marketing.Services.Customers
var customers = await (from cu in _customerRepository.Table
where cu.ShoppingCartItems.Any() && cu.LastUpdateCartDateUtc > reminder.LastUpdateDate && cu.Active && !cu.Deleted
&& (!String.IsNullOrEmpty(cu.Email))
- select cu).ToListAsync();
+ select cu).ToListAsync2();
foreach (var customer in customers)
{
var history = await (from hc in _customerReminderHistoryRepository.Table
where hc.CustomerId == customer.Id && hc.CustomerReminderId == reminder.Id
- select hc).ToListAsync();
+ select hc).ToListAsync2();
if (history.Any())
{
var activereminderhistory = history.FirstOrDefault(x => x.Status == CustomerReminderHistoryStatusEnum.Started);
@@ -780,13 +778,13 @@ namespace Grand.Business.Marketing.Services.Customers
customerReminder = await (from cr in _customerReminderRepository.Table
where cr.Active && datetimeUtcNow >= cr.StartDateTimeUtc && datetimeUtcNow <= cr.EndDateTimeUtc
&& cr.ReminderRuleId == CustomerReminderRuleEnum.RegisteredCustomer
- select cr).ToListAsync();
+ select cr).ToListAsync2();
}
else
{
customerReminder = await (from cr in _customerReminderRepository.Table
where cr.Id == id && cr.ReminderRuleId == CustomerReminderRuleEnum.RegisteredCustomer
- select cr).ToListAsync();
+ select cr).ToListAsync2();
}
foreach (var reminder in customerReminder)
{
@@ -794,13 +792,13 @@ namespace Grand.Business.Marketing.Services.Customers
where cu.CreatedOnUtc > reminder.LastUpdateDate && cu.Active && !cu.Deleted
&& (!String.IsNullOrEmpty(cu.Email))
&& !cu.IsSystemAccount
- select cu).ToListAsync();
+ select cu).ToListAsync2();
foreach (var customer in customers)
{
var history = await (from hc in _customerReminderHistoryRepository.Table
where hc.CustomerId == customer.Id && hc.CustomerReminderId == reminder.Id
- select hc).ToListAsync();
+ select hc).ToListAsync2();
if (history.Any())
{
var activereminderhistory = history.FirstOrDefault(x => x.Status == CustomerReminderHistoryStatusEnum.Started);
@@ -873,26 +871,26 @@ namespace Grand.Business.Marketing.Services.Customers
customerReminder = await (from cr in _customerReminderRepository.Table
where cr.Active && datetimeUtcNow >= cr.StartDateTimeUtc && datetimeUtcNow <= cr.EndDateTimeUtc
&& cr.ReminderRuleId == CustomerReminderRuleEnum.LastActivity
- select cr).ToListAsync();
+ select cr).ToListAsync2();
}
else
{
customerReminder = await (from cr in _customerReminderRepository.Table
where cr.Id == id && cr.ReminderRuleId == CustomerReminderRuleEnum.LastActivity
- select cr).ToListAsync();
+ select cr).ToListAsync2();
}
foreach (var reminder in customerReminder)
{
var customers = await (from cu in _customerRepository.Table
where cu.LastActivityDateUtc < reminder.LastUpdateDate && cu.Active && !cu.Deleted
&& (!String.IsNullOrEmpty(cu.Email))
- select cu).ToListAsync();
+ select cu).ToListAsync2();
foreach (var customer in customers)
{
var history = await (from hc in _customerReminderHistoryRepository.Table
where hc.CustomerId == customer.Id && hc.CustomerReminderId == reminder.Id
- select hc).ToListAsync();
+ select hc).ToListAsync2();
if (history.Any())
{
var activereminderhistory = history.FirstOrDefault(x => x.Status == CustomerReminderHistoryStatusEnum.Started);
@@ -964,13 +962,13 @@ namespace Grand.Business.Marketing.Services.Customers
customerReminder = await (from cr in _customerReminderRepository.Table
where cr.Active && datetimeUtcNow >= cr.StartDateTimeUtc && datetimeUtcNow <= cr.EndDateTimeUtc
&& cr.ReminderRuleId == CustomerReminderRuleEnum.LastPurchase
- select cr).ToListAsync();
+ select cr).ToListAsync2();
}
else
{
customerReminder = await (from cr in _customerReminderRepository.Table
where cr.Id == id && cr.ReminderRuleId == CustomerReminderRuleEnum.LastPurchase
- select cr).ToListAsync();
+ select cr).ToListAsync2();
}
foreach (var reminder in customerReminder)
{
@@ -978,13 +976,13 @@ namespace Grand.Business.Marketing.Services.Customers
where cu.LastPurchaseDateUtc < reminder.LastUpdateDate || cu.LastPurchaseDateUtc == null
&& (!String.IsNullOrEmpty(cu.Email)) && cu.Active && !cu.Deleted
&& !cu.IsSystemAccount
- select cu).ToListAsync();
+ select cu).ToListAsync2();
foreach (var customer in customers)
{
var history = await (from hc in _customerReminderHistoryRepository.Table
where hc.CustomerId == customer.Id && hc.CustomerReminderId == reminder.Id
- select hc).ToListAsync();
+ select hc).ToListAsync2();
if (history.Any())
{
var activereminderhistory = history.FirstOrDefault(x => x.Status == CustomerReminderHistoryStatusEnum.Started);
@@ -1057,13 +1055,13 @@ namespace Grand.Business.Marketing.Services.Customers
customerReminder = await (from cr in _customerReminderRepository.Table
where cr.Active && datetimeUtcNow >= cr.StartDateTimeUtc && datetimeUtcNow <= cr.EndDateTimeUtc
&& cr.ReminderRuleId == CustomerReminderRuleEnum.Birthday
- select cr).ToListAsync();
+ select cr).ToListAsync2();
}
else
{
customerReminder = await (from cr in _customerReminderRepository.Table
where cr.Id == id && cr.ReminderRuleId == CustomerReminderRuleEnum.Birthday
- select cr).ToListAsync();
+ select cr).ToListAsync2();
}
foreach (var reminder in customerReminder)
@@ -1077,13 +1075,13 @@ namespace Grand.Business.Marketing.Services.Customers
var customers = await (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).ToListAsync();
+ select cu).ToListAsync2();
foreach (var customer in customers)
{
var history = await (from hc in _customerReminderHistoryRepository.Table
where hc.CustomerId == customer.Id && hc.CustomerReminderId == reminder.Id
- select hc).ToListAsync();
+ select hc).ToListAsync2();
if (history.Any())
{
var activereminderhistory = history.FirstOrDefault(x => x.Status == CustomerReminderHistoryStatusEnum.Started);
@@ -1139,7 +1137,7 @@ namespace Grand.Business.Marketing.Services.Customers
var activehistory = await (from hc in _customerReminderHistoryRepository.Table
where hc.CustomerReminderId == reminder.Id && hc.Status == CustomerReminderHistoryStatusEnum.Started
- select hc).ToListAsync();
+ select hc).ToListAsync2();
foreach (var activereminderhistory in activehistory)
{
@@ -1174,13 +1172,13 @@ namespace Grand.Business.Marketing.Services.Customers
customerReminder = await (from cr in _customerReminderRepository.Table
where cr.Active && datetimeUtcNow >= cr.StartDateTimeUtc && datetimeUtcNow <= cr.EndDateTimeUtc
&& cr.ReminderRuleId == CustomerReminderRuleEnum.CompletedOrder
- select cr).ToListAsync();
+ select cr).ToListAsync2();
}
else
{
customerReminder = await (from cr in _customerReminderRepository.Table
where cr.Id == id && cr.ReminderRuleId == CustomerReminderRuleEnum.CompletedOrder
- select cr).ToListAsync();
+ select cr).ToListAsync2();
}
foreach (var reminder in customerReminder)
@@ -1192,15 +1190,15 @@ namespace Grand.Business.Marketing.Services.Customers
var orders = await (from or in _orderRepository.Table
where or.OrderStatusId == (int)OrderStatusSystem.Complete
&& or.CreatedOnUtc >= reminder.LastUpdateDate && or.CreatedOnUtc >= dateNow.AddDays(-day)
- select or).ToListAsync();
+ select or).ToListAsync2();
foreach (var order in orders)
{
var history = await (from hc in _customerReminderHistoryRepository.Table
where hc.BaseOrderId == order.Id && hc.CustomerReminderId == reminder.Id
- select hc).ToListAsync();
+ select hc).ToListAsync2();
- Customer customer = await _customerRepository.Table.FirstOrDefaultAsync(x => x.Id == order.CustomerId && x.Active && !x.Deleted);
+ Customer customer = await _customerRepository.Table.Where(x => x.Id == order.CustomerId && x.Active && !x.Deleted).FirstOrDefaultAsync2();
if (customer != null)
{
if (history.Any())
@@ -1259,7 +1257,7 @@ namespace Grand.Business.Marketing.Services.Customers
var activehistory = await (from hc in _customerReminderHistoryRepository.Table
where hc.CustomerReminderId == reminder.Id && hc.Status == CustomerReminderHistoryStatusEnum.Started
- select hc).ToListAsync();
+ select hc).ToListAsync2();
foreach (var activereminderhistory in activehistory)
{
@@ -1295,13 +1293,13 @@ namespace Grand.Business.Marketing.Services.Customers
customerReminder = await (from cr in _customerReminderRepository.Table
where cr.Active && datetimeUtcNow >= cr.StartDateTimeUtc && datetimeUtcNow <= cr.EndDateTimeUtc
&& cr.ReminderRuleId == CustomerReminderRuleEnum.UnpaidOrder
- select cr).ToListAsync();
+ select cr).ToListAsync2();
}
else
{
customerReminder = await (from cr in _customerReminderRepository.Table
where cr.Id == id && cr.ReminderRuleId == CustomerReminderRuleEnum.UnpaidOrder
- select cr).ToListAsync();
+ select cr).ToListAsync2();
}
foreach (var reminder in customerReminder)
@@ -1313,15 +1311,15 @@ namespace Grand.Business.Marketing.Services.Customers
var orders = await (from or in _orderRepository.Table
where or.PaymentStatusId == PaymentStatus.Pending
&& or.CreatedOnUtc >= reminder.LastUpdateDate && or.CreatedOnUtc >= dateNow.AddDays(-day)
- select or).ToListAsync();
+ select or).ToListAsync2();
foreach (var order in orders)
{
var history = await (from hc in _customerReminderHistoryRepository.Table
where hc.BaseOrderId == order.Id && hc.CustomerReminderId == reminder.Id
- select hc).ToListAsync();
+ select hc).ToListAsync2();
- Customer customer = await _customerRepository.Table.FirstOrDefaultAsync(x => x.Id == order.CustomerId && x.Active && !x.Deleted);
+ Customer customer = await _customerRepository.Table.Where(x => x.Id == order.CustomerId && x.Active && !x.Deleted).FirstOrDefaultAsync2();
if (customer != null)
{
if (history.Any())
@@ -1379,7 +1377,7 @@ namespace Grand.Business.Marketing.Services.Customers
}
var activehistory = await (from hc in _customerReminderHistoryRepository.Table
where hc.CustomerReminderId == reminder.Id && hc.Status == CustomerReminderHistoryStatusEnum.Started
- select hc).ToListAsync();
+ select hc).ToListAsync2();
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 34b3396fa..1694e137d 100644
--- a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerTagService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerTagService.cs
@@ -6,9 +6,6 @@ using Grand.Domain;
using Grand.Domain.Customers;
using Grand.Domain.Data;
using MediatR;
-using MongoDB.Bson;
-using MongoDB.Driver;
-using MongoDB.Driver.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -73,9 +70,9 @@ namespace Grand.Business.Marketing.Services.Customers
if (customerTag == null)
throw new ArgumentNullException(nameof(customerTag));
- var builder = Builders<Customer>.Update;
+ var builder = MongoDB.Driver.Builders<Customer>.Update;
var updatefilter = builder.Pull(x => x.CustomerTags, customerTag.Id);
- await _customerRepository.Collection.UpdateManyAsync(new BsonDocument(), updatefilter);
+ await _customerRepository.Collection.UpdateManyAsync(new MongoDB.Bson.BsonDocument(), updatefilter);
await _customerTagRepository.DeleteAsync(customerTag);
@@ -90,7 +87,7 @@ namespace Grand.Business.Marketing.Services.Customers
public virtual async Task<IList<CustomerTag>> GetAllCustomerTags()
{
var query = _customerTagRepository.Table;
- return await query.ToListAsync();
+ return await query.ToListAsync2();
}
/// <summary>
@@ -114,7 +111,7 @@ namespace Grand.Business.Marketing.Services.Customers
where pt.Name == name
select pt;
- return query.FirstOrDefaultAsync();
+ return query.FirstOrDefaultAsync2();
}
/// <summary>
@@ -127,7 +124,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.ToListAsync();
+ return await query.ToListAsync2();
}
/// <summary>
@@ -150,9 +147,9 @@ namespace Grand.Business.Marketing.Services.Customers
/// </summary>
public virtual async Task InsertTagToCustomer(string customerTagId, string customerId)
{
- var updatebuilder = Builders<Customer>.Update;
+ var updatebuilder = MongoDB.Driver.Builders<Customer>.Update;
var update = updatebuilder.AddToSet(p => p.CustomerTags, customerTagId);
- await _customerRepository.Collection.UpdateOneAsync(new BsonDocument("_id", customerId), update);
+ await _customerRepository.Collection.UpdateOneAsync(new MongoDB.Bson.BsonDocument("_id", customerId), update);
}
/// <summary>
@@ -160,9 +157,9 @@ namespace Grand.Business.Marketing.Services.Customers
/// </summary>
public virtual async Task DeleteTagFromCustomer(string customerTagId, string customerId)
{
- var updatebuilder = Builders<Customer>.Update;
+ var updatebuilder = MongoDB.Driver.Builders<Customer>.Update;
var update = updatebuilder.Pull(p => p.CustomerTags, customerTagId);
- await _customerRepository.Collection.UpdateOneAsync(new BsonDocument("_id", customerId), update);
+ await _customerRepository.Collection.UpdateOneAsync(new MongoDB.Bson.BsonDocument("_id", customerId), update);
}
/// <summary>
@@ -189,7 +186,7 @@ namespace Grand.Business.Marketing.Services.Customers
{
var query = await _customerRepository.Table.
Where(x => x.CustomerTags.Contains(customerTagId)).
- GroupBy(p => p, (k, s) => new { Counter = s.Count() }).ToListAsync();
+ GroupBy(p => p, (k, s) => new { Counter = s.Count() }).ToListAsync2();
if (query.Count > 0)
return query.FirstOrDefault().Counter;
return 0;
@@ -212,7 +209,7 @@ namespace Grand.Business.Marketing.Services.Customers
where (cr.CustomerTagId == customerTagId)
orderby cr.DisplayOrder
select cr;
- return query.ToListAsync();
+ return query.ToListAsync2();
});
}
@@ -228,7 +225,7 @@ namespace Grand.Business.Marketing.Services.Customers
where cr.CustomerTagId == customerTagId && cr.ProductId == productId
orderby cr.DisplayOrder
select cr;
- return query.FirstOrDefaultAsync();
+ return query.FirstOrDefaultAsync2();
}
/// <summary>
diff --git a/src/Business/Grand.Business.Marketing/Services/Documents/DocumentService.cs b/src/Business/Grand.Business.Marketing/Services/Documents/DocumentService.cs
index b89470850..23428aec7 100644
--- a/src/Business/Grand.Business.Marketing/Services/Documents/DocumentService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Documents/DocumentService.cs
@@ -4,7 +4,6 @@ using Grand.Domain;
using Grand.Domain.Data;
using Grand.Domain.Documents;
using MediatR;
-using MongoDB.Driver.Linq;
using System;
using System.Linq;
using System.Threading.Tasks;
diff --git a/src/Business/Grand.Business.Marketing/Services/Documents/DocumentTypeService.cs b/src/Business/Grand.Business.Marketing/Services/Documents/DocumentTypeService.cs
index ebcec36b3..a3412e7cd 100644
--- a/src/Business/Grand.Business.Marketing/Services/Documents/DocumentTypeService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Documents/DocumentTypeService.cs
@@ -3,8 +3,6 @@ using Grand.Infrastructure.Extensions;
using Grand.Domain.Data;
using Grand.Domain.Documents;
using MediatR;
-using MongoDB.Driver;
-using MongoDB.Driver.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -39,7 +37,7 @@ namespace Grand.Business.Marketing.Services.Documents
var query = from t in _documentTypeRepository.Table
orderby t.DisplayOrder
select t;
- return await query.ToListAsync();
+ return await query.ToListAsync2();
}
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 fab28d59b..21057ba85 100644
--- a/src/Business/Grand.Business.Marketing/Services/Knowledgebase/KnowledgebaseService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Knowledgebase/KnowledgebaseService.cs
@@ -11,8 +11,6 @@ using Grand.Infrastructure.Caching.Constants;
using Grand.Infrastructure.Extensions;
using Grand.SharedKernel.Extensions;
using MediatR;
-using MongoDB.Driver;
-using MongoDB.Driver.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -58,7 +56,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).ToListAsync();
+ var children = await _knowledgebaseCategoryRepository.Table.Where(x => x.ParentCategoryId == kc.Id).ToListAsync2();
await _knowledgebaseCategoryRepository.DeleteAsync(kc);
foreach (var child in children)
{
@@ -92,7 +90,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebase
/// <returns>knowledgebase category</returns>
public virtual Task<KnowledgebaseCategory> GetKnowledgebaseCategory(string id)
{
- return _knowledgebaseCategoryRepository.Table.Where(x => x.Id == id).FirstOrDefaultAsync();
+ return _knowledgebaseCategoryRepository.Table.Where(x => x.Id == id).FirstOrDefaultAsync2();
}
/// <summary>
@@ -104,28 +102,33 @@ namespace Grand.Business.Marketing.Services.Knowledgebase
{
string key = string.Format(CacheKey.KNOWLEDGEBASE_CATEGORY_BY_ID, id, _workContext.CurrentCustomer.GetCustomerGroupIds(),
_workContext.CurrentStore.Id);
- return await _cacheBase.GetAsync(key, () =>
+ return await _cacheBase.GetAsync(key, async () =>
{
- var builder = Builders<KnowledgebaseCategory>.Filter;
- var filter = FilterDefinition<KnowledgebaseCategory>.Empty;
- filter &= builder.Where(x => x.Published);
- filter &= builder.Where(x => x.Id == id);
+ var query = from p in _knowledgebaseCategoryRepository.Table
+ select p;
+
+ query = query.Where(x => x.Published);
+ query = query.Where(x => x.Id == id);
if (!CommonHelper.IgnoreAcl)
{
+ //Limited to customer groups rules
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
- filter &= (builder.AnyIn(x => x.CustomerGroups, allowedCustomerGroupsIds) | builder.Where(x => !x.LimitedToGroups));
+ query = from p in query
+ where !p.LimitedToGroups || allowedCustomerGroupsIds.Any(x => p.CustomerGroups.Contains(x))
+ select p;
}
if (!CommonHelper.IgnoreStoreLimitations)
{
//Store acl
- var currentStoreId = new List<string> { _workContext.CurrentStore.Id };
- filter &= (builder.AnyIn(x => x.Stores, currentStoreId) | builder.Where(x => !x.LimitedToStores));
+ query = from p in query
+ where !p.LimitedToStores || p.Stores.Contains(_workContext.CurrentStore.Id)
+ select p;
}
- var toReturn = _knowledgebaseCategoryRepository.Collection.Find(filter);
- return toReturn.FirstOrDefaultAsync();
+ var toReturn = await query.FirstOrDefaultAsync2();
+ return toReturn;
});
}
@@ -152,7 +155,7 @@ 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).ToListAsync();
+ var categories = await _knowledgebaseCategoryRepository.Table.OrderBy(x => x.ParentCategoryId).ThenBy(x => x.DisplayOrder).ToListAsync2();
return categories.SortCategoriesForTree();
}
@@ -163,7 +166,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).FirstOrDefaultAsync();
+ return _knowledgebaseArticleRepository.Table.Where(x => x.Id == id).FirstOrDefaultAsync2();
}
/// <summary>
@@ -173,26 +176,28 @@ namespace Grand.Business.Marketing.Services.Knowledgebase
/// <param name="storeId">Store ident</param>
public virtual async Task<List<KnowledgebaseArticle>> GetKnowledgebaseArticles(string storeId = "")
{
- var builder = Builders<KnowledgebaseArticle>.Filter;
- var filter = FilterDefinition<KnowledgebaseArticle>.Empty;
+ var query = from p in _knowledgebaseArticleRepository.Table
+ select p;
+
var customer = _workContext.CurrentCustomer;
if (!CommonHelper.IgnoreAcl)
{
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
- filter &= (builder.AnyIn(x => x.CustomerGroups, allowedCustomerGroupsIds) | builder.Where(x => !x.LimitedToGroups));
+ query = from p in query
+ where !p.LimitedToGroups || allowedCustomerGroupsIds.Any(x => p.CustomerGroups.Contains(x))
+ select p;
}
if (!CommonHelper.IgnoreStoreLimitations && !string.IsNullOrEmpty(storeId))
{
- //Store acl
- var currentStoreId = new List<string> { storeId };
- filter &= (builder.AnyIn(x => x.Stores, currentStoreId) | builder.Where(x => !x.LimitedToStores));
+ //Limited to stores rules
+ query = from p in query
+ where !p.LimitedToStores || p.Stores.Contains(storeId)
+ select p;
}
-
- var builderSort = Builders<KnowledgebaseArticle>.Sort.Ascending(x => x.DisplayOrder);
- var toReturn = _knowledgebaseArticleRepository.Collection.Find(filter).Sort(builderSort);
- return await toReturn.ToListAsync();
+ query = query.OrderBy(x => x.DisplayOrder);
+ return await query.ToListAsync2();
}
/// <summary>
@@ -241,7 +246,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).ToListAsync();
+ var articles = await _knowledgebaseArticleRepository.Table.Where(x => x.ParentCategoryId == id).OrderBy(x => x.DisplayOrder).ToListAsync2();
return new PagedList<KnowledgebaseArticle>(articles, pageIndex, pageSize);
}
@@ -253,28 +258,31 @@ namespace Grand.Business.Marketing.Services.Knowledgebase
{
var key = string.Format(CacheKey.KNOWLEDGEBASE_CATEGORIES, string.Join(",", _workContext.CurrentCustomer.GetCustomerGroupIds()),
_workContext.CurrentStore.Id);
- return await _cacheBase.GetAsync(key, () =>
+ return await _cacheBase.GetAsync(key, async () =>
{
- var builder = Builders<KnowledgebaseCategory>.Filter;
- var filter = FilterDefinition<KnowledgebaseCategory>.Empty;
- filter = filter & builder.Where(x => x.Published);
+ var query = from p in _knowledgebaseCategoryRepository.Table
+ select p;
+
+ query = query.Where(x => x.Published);
if (!CommonHelper.IgnoreAcl)
{
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
- filter = filter & (builder.AnyIn(x => x.CustomerGroups, allowedCustomerGroupsIds) | builder.Where(x => !x.LimitedToGroups));
+ query = from p in query
+ where !p.LimitedToGroups || allowedCustomerGroupsIds.Any(x => p.CustomerGroups.Contains(x))
+ select p;
}
if (!CommonHelper.IgnoreStoreLimitations)
{
//Store acl
- var currentStoreId = new List<string> { _workContext.CurrentStore.Id };
- filter = filter & (builder.AnyIn(x => x.Stores, currentStoreId) | builder.Where(x => !x.LimitedToStores));
+ query = from p in query
+ where !p.LimitedToStores || p.Stores.Contains(_workContext.CurrentStore.Id)
+ select p;
}
+ query = query.OrderBy(x => x.DisplayOrder);
+ return await query.ToListAsync2();
- var builderSort = Builders<KnowledgebaseCategory>.Sort.Ascending(x => x.DisplayOrder);
- var toReturn = _knowledgebaseCategoryRepository.Collection.Find(filter).Sort(builderSort);
- return toReturn.ToListAsync();
});
}
@@ -287,28 +295,31 @@ namespace Grand.Business.Marketing.Services.Knowledgebase
var key = string.Format(CacheKey.ARTICLES, string.Join(",", _workContext.CurrentCustomer.GetCustomerGroupIds()),
_workContext.CurrentStore.Id);
- return await _cacheBase.GetAsync(key, () =>
+ return await _cacheBase.GetAsync(key, async () =>
{
- var builder = Builders<KnowledgebaseArticle>.Filter;
- var filter = FilterDefinition<KnowledgebaseArticle>.Empty;
- filter = filter & builder.Where(x => x.Published);
+ var query = from p in _knowledgebaseArticleRepository.Table
+ select p;
+
+ query = query.Where(x => x.Published);
if (!CommonHelper.IgnoreAcl)
{
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
- filter = filter & (builder.AnyIn(x => x.CustomerGroups, allowedCustomerGroupsIds) | builder.Where(x => !x.LimitedToGroups));
+ query = from p in query
+ where !p.LimitedToGroups || allowedCustomerGroupsIds.Any(x => p.CustomerGroups.Contains(x))
+ select p;
}
if (!CommonHelper.IgnoreStoreLimitations)
{
//Store acl
- var currentStoreId = new List<string> { _workContext.CurrentStore.Id };
- filter = filter & (builder.AnyIn(x => x.Stores, currentStoreId) | builder.Where(x => !x.LimitedToStores));
+ query = from p in query
+ where !p.LimitedToStores || p.Stores.Contains(_workContext.CurrentStore.Id)
+ select p;
}
- var builderSort = Builders<KnowledgebaseArticle>.Sort.Ascending(x => x.DisplayOrder);
- var toReturn = _knowledgebaseArticleRepository.Collection.Find(filter).Sort(builderSort);
- return toReturn.ToListAsync();
+ query = query.OrderBy(x => x.DisplayOrder);
+ return await query.ToListAsync2();
});
}
@@ -322,25 +333,29 @@ namespace Grand.Business.Marketing.Services.Knowledgebase
_workContext.CurrentStore.Id);
return await _cacheBase.GetAsync(key, () =>
{
- var builder = Builders<KnowledgebaseArticle>.Filter;
- var filter = FilterDefinition<KnowledgebaseArticle>.Empty;
- filter = filter & builder.Where(x => x.Published);
- filter = filter & builder.Where(x => x.Id == id);
+ var query = from p in _knowledgebaseArticleRepository.Table
+ select p;
+
+ query = query.Where(x => x.Published);
+ query = query.Where(x => x.Id == id);
if (!CommonHelper.IgnoreAcl)
{
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
- filter = filter & (builder.AnyIn(x => x.CustomerGroups, allowedCustomerGroupsIds) | builder.Where(x => !x.LimitedToGroups));
+ query = from p in query
+ where !p.LimitedToGroups || allowedCustomerGroupsIds.Any(x => p.CustomerGroups.Contains(x))
+ select p;
}
if (!CommonHelper.IgnoreStoreLimitations)
{
//Store acl
- var currentStoreId = new List<string> { _workContext.CurrentStore.Id };
- filter = filter & (builder.AnyIn(x => x.Stores, currentStoreId) | builder.Where(x => !x.LimitedToStores));
+ query = from p in query
+ where !p.LimitedToStores || p.Stores.Contains(_workContext.CurrentStore.Id)
+ select p;
}
- return _knowledgebaseArticleRepository.Collection.Find(filter).FirstOrDefaultAsync();
+ return query.FirstOrDefaultAsync2();
});
}
@@ -352,29 +367,32 @@ namespace Grand.Business.Marketing.Services.Knowledgebase
{
var key = string.Format(CacheKey.ARTICLES_BY_CATEGORY_ID, categoryId, string.Join(",", _workContext.CurrentCustomer.GetCustomerGroupIds()),
_workContext.CurrentStore.Id);
- return await _cacheBase.GetAsync(key, () =>
+ return await _cacheBase.GetAsync(key, async () =>
{
- var builder = Builders<KnowledgebaseArticle>.Filter;
- var filter = FilterDefinition<KnowledgebaseArticle>.Empty;
- filter = filter & builder.Where(x => x.Published);
- filter = filter & builder.Where(x => x.ParentCategoryId == categoryId);
+ var query = from p in _knowledgebaseArticleRepository.Table
+ select p;
+
+ query = query.Where(x => x.Published);
+ query = query.Where(x => x.ParentCategoryId == categoryId);
if (!CommonHelper.IgnoreAcl)
{
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
- filter = filter & (builder.AnyIn(x => x.CustomerGroups, allowedCustomerGroupsIds) | builder.Where(x => !x.LimitedToGroups));
+ query = from p in query
+ where !p.LimitedToGroups || allowedCustomerGroupsIds.Any(x => p.CustomerGroups.Contains(x))
+ select p;
}
if (!CommonHelper.IgnoreStoreLimitations)
{
//Store acl
var currentStoreId = new List<string> { _workContext.CurrentStore.Id };
- filter = filter & (builder.AnyIn(x => x.Stores, currentStoreId) | builder.Where(x => !x.LimitedToStores));
+ query = from p in query
+ where !p.LimitedToStores || p.Stores.Contains(_workContext.CurrentStore.Id)
+ select p;
}
-
- var builderSort = Builders<KnowledgebaseArticle>.Sort.Ascending(x => x.DisplayOrder);
- var toReturn = _knowledgebaseArticleRepository.Collection.Find(filter).Sort(builderSort);
- return toReturn.ToListAsync();
+ query = query.OrderBy(x => x.DisplayOrder);
+ return await query.ToListAsync2();
});
}
@@ -386,41 +404,35 @@ namespace Grand.Business.Marketing.Services.Knowledgebase
{
var key = string.Format(CacheKey.ARTICLES_BY_KEYWORD, keyword, string.Join(",", _workContext.CurrentCustomer.GetCustomerGroupIds()),
_workContext.CurrentStore.Id);
- return await _cacheBase.GetAsync(key, () =>
+
+ return await _cacheBase.GetAsync(key, async () =>
{
- var builder = Builders<KnowledgebaseArticle>.Filter;
- var filter = FilterDefinition<KnowledgebaseArticle>.Empty;
- filter = filter & builder.Where(x => x.Published);
+ var query = from p in _knowledgebaseArticleRepository.Table
+ select p;
- if (_fullTextSettings.UseFullTextSearch)
- {
- keyword = "\"" + keyword + "\"";
- keyword = keyword.Replace("+", "\" \"");
- keyword = keyword.Replace(" ", "\" \"");
- filter = filter & builder.Text(keyword);
- }
- else
- {
- filter = filter & builder.Where(p => p.Locales.Any(x => x.LocaleValue != null && x.LocaleValue.ToLower().Contains(keyword.ToLower()))
+ query = query.Where(x => x.Published);
+
+ query = query.Where(p => p.Locales.Any(x => x.LocaleValue != null && x.LocaleValue.ToLower().Contains(keyword.ToLower()))
|| p.Name.ToLower().Contains(keyword.ToLower()) || p.Content.ToLower().Contains(keyword.ToLower()));
- }
if (!CommonHelper.IgnoreAcl)
{
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
- filter = filter & (builder.AnyIn(x => x.CustomerGroups, allowedCustomerGroupsIds) | builder.Where(x => !x.LimitedToGroups));
+ query = from p in query
+ where !p.LimitedToGroups || allowedCustomerGroupsIds.Any(x => p.CustomerGroups.Contains(x))
+ select p;
}
if (!CommonHelper.IgnoreStoreLimitations)
{
//Store acl
var currentStoreId = new List<string> { _workContext.CurrentStore.Id };
- filter = filter & (builder.AnyIn(x => x.Stores, currentStoreId) | builder.Where(x => !x.LimitedToStores));
+ query = from p in query
+ where !p.LimitedToStores || p.Stores.Contains(_workContext.CurrentStore.Id)
+ select p;
}
-
- var builderSort = Builders<KnowledgebaseArticle>.Sort.Ascending(x => x.DisplayOrder);
- var toReturn = _knowledgebaseArticleRepository.Collection.Find(filter).Sort(builderSort);
- return toReturn.ToListAsync();
+ query = query.OrderBy(x => x.DisplayOrder);
+ return await query.ToListAsync2();
});
}
@@ -432,41 +444,34 @@ namespace Grand.Business.Marketing.Services.Knowledgebase
{
var key = string.Format(CacheKey.KNOWLEDGEBASE_CATEGORIES_BY_KEYWORD, keyword, string.Join(",", _workContext.CurrentCustomer.GetCustomerGroupIds()),
_workContext.CurrentStore.Id);
- return await _cacheBase.GetAsync(key, () =>
+ return await _cacheBase.GetAsync(key, async () =>
{
- var builder = Builders<KnowledgebaseCategory>.Filter;
- var filter = FilterDefinition<KnowledgebaseCategory>.Empty;
- filter = filter & builder.Where(x => x.Published);
+ var query = from p in _knowledgebaseCategoryRepository.Table
+ select p;
- if (_fullTextSettings.UseFullTextSearch)
- {
- keyword = "\"" + keyword + "\"";
- keyword = keyword.Replace("+", "\" \"");
- keyword = keyword.Replace(" ", "\" \"");
- filter = filter & builder.Text(keyword);
- }
- else
- {
- filter = filter & builder.Where(p => p.Locales.Any(x => x.LocaleValue != null && x.LocaleValue.ToLower().Contains(keyword.ToLower()))
+ query = query.Where(x => x.Published);
+
+ query = query.Where(p => p.Locales.Any(x => x.LocaleValue != null && x.LocaleValue.ToLower().Contains(keyword.ToLower()))
|| p.Name.ToLower().Contains(keyword.ToLower()) || p.Description.ToLower().Contains(keyword.ToLower()));
- }
if (!CommonHelper.IgnoreAcl)
{
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
- filter = filter & (builder.AnyIn(x => x.CustomerGroups, allowedCustomerGroupsIds) | builder.Where(x => !x.LimitedToGroups));
+ query = from p in query
+ where !p.LimitedToGroups || allowedCustomerGroupsIds.Any(x => p.CustomerGroups.Contains(x))
+ select p;
}
if (!CommonHelper.IgnoreStoreLimitations)
{
//Store acl
- var currentStoreId = new List<string> { _workContext.CurrentStore.Id };
- filter = filter & (builder.AnyIn(x => x.Stores, currentStoreId) | builder.Where(x => !x.LimitedToStores));
+ query = from p in query
+ where !p.LimitedToStores || p.Stores.Contains(_workContext.CurrentStore.Id)
+ select p; ;
}
+ query = query.OrderBy(x => x.DisplayOrder);
+ return await query.ToListAsync2();
- var builderSort = Builders<KnowledgebaseCategory>.Sort.Ascending(x => x.DisplayOrder);
- var toReturn = _knowledgebaseCategoryRepository.Collection.Find(filter).Sort(builderSort);
- return toReturn.ToListAsync();
});
}
@@ -478,29 +483,32 @@ namespace Grand.Business.Marketing.Services.Knowledgebase
{
var key = string.Format(CacheKey.HOMEPAGE_ARTICLES, string.Join(",", _workContext.CurrentCustomer.GetCustomerGroupIds()),
_workContext.CurrentStore.Id);
- return await _cacheBase.GetAsync(key, () =>
+ return await _cacheBase.GetAsync(key, async () =>
{
- var builder = Builders<KnowledgebaseArticle>.Filter;
- var filter = FilterDefinition<KnowledgebaseArticle>.Empty;
- filter = filter & builder.Where(x => x.Published);
- filter = filter & builder.Where(x => x.ShowOnHomepage);
+ var query = from p in _knowledgebaseArticleRepository.Table
+ select p;
+
+ query = query.Where(x => x.Published);
+ query = query.Where(x => x.ShowOnHomepage);
if (!CommonHelper.IgnoreAcl)
{
var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds();
- filter = filter & (builder.AnyIn(x => x.CustomerGroups, allowedCustomerGroupsIds) | builder.Where(x => !x.LimitedToGroups));
+ query = from p in query
+ where !p.LimitedToGroups || allowedCustomerGroupsIds.Any(x => p.CustomerGroups.Contains(x))
+ select p;
}
if (!CommonHelper.IgnoreStoreLimitations)
{
//Store acl
- var currentStoreId = new List<string> { _workContext.CurrentStore.Id };
- filter = filter & (builder.AnyIn(x => x.Stores, currentStoreId) | builder.Where(x => !x.LimitedToStores));
+ query = from p in query
+ where !p.LimitedToStores || p.Stores.Contains(_workContext.CurrentStore.Id)
+ select p;
}
+ query = query.OrderBy(x => x.DisplayOrder);
+ return await query.ToListAsync2();
- var builderSort = Builders<KnowledgebaseArticle>.Sort.Ascending(x => x.DisplayOrder);
- var toReturn = _knowledgebaseArticleRepository.Collection.Find(filter).Sort(builderSort);
- return toReturn.ToListAsync();
});
}
@@ -511,29 +519,22 @@ namespace Grand.Business.Marketing.Services.Knowledgebase
/// <returns>IPagedList<KnowledgebaseArticle></returns>
public virtual async Task<IPagedList<KnowledgebaseArticle>> GetKnowledgebaseArticlesByName(string name, int pageIndex = 0, int pageSize = int.MaxValue)
{
- var builder = Builders<KnowledgebaseArticle>.Filter;
- var filter = FilterDefinition<KnowledgebaseArticle>.Empty;
- filter = filter & builder.Where(x => x.Published);
+ var query = from p in _knowledgebaseArticleRepository.Table
+ select p;
+
+
+ query = query.Where(x => x.Published);
if (!string.IsNullOrEmpty(name))
{
- if (_fullTextSettings.UseFullTextSearch)
- {
- name = "\"" + name + "\"";
- name = name.Replace("+", "\" \"");
- name = name.Replace(" ", "\" \"");
- filter = filter & builder.Text(name);
- }
- else
- {
- filter = filter & builder.Where(p => p.Locales.Any(x => x.LocaleKey == "Name" && x.LocaleValue != null && x.LocaleValue.ToLower().
- Contains(name.ToLower()))
+
+ query = query.Where(p => p.Locales.Any(x => x.LocaleKey == "Name" && x.LocaleValue != null && x.LocaleValue.ToLower().Contains(name.ToLower()))
|| p.Name.ToLower().Contains(name.ToLower()));
- }
+
}
- var builderSort = Builders<KnowledgebaseArticle>.Sort.Ascending(x => x.DisplayOrder);
- var toReturn = await _knowledgebaseArticleRepository.Collection.Find(filter).Sort(builderSort).ToListAsync();
+ query = query.OrderBy(x => x.DisplayOrder);
+ var toReturn = await query.ToListAsync2();
return new PagedList<KnowledgebaseArticle>(toReturn, pageIndex, pageSize);
}
@@ -584,7 +585,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebase
orderby c.CreatedOnUtc
where (customerId == "" || c.CustomerId == customerId)
select c;
- return await query.ToListAsync();
+ return await query.ToListAsync2();
}
/// <summary>
@@ -610,7 +611,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.ToListAsync();
+ var comments = await query.ToListAsync2();
//sort by passed identifiers
var sortedComments = new List<KnowledgebaseArticleComment>();
foreach (string id in commentIds)
@@ -628,7 +629,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebase
where c.ArticleId == articleId
orderby c.CreatedOnUtc
select c;
- return await query.ToListAsync();
+ return await query.ToListAsync2();
}
public virtual async Task DeleteArticleComment(KnowledgebaseArticleComment articleComment)
diff --git a/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsLetterSubscriptionService.cs b/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsLetterSubscriptionService.cs
index 85bf08532..e1a13b51c 100644
--- a/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsLetterSubscriptionService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsLetterSubscriptionService.cs
@@ -8,7 +8,6 @@ using Grand.Domain.Data;
using Grand.Domain.Messages;
using Grand.SharedKernel.Extensions;
using MediatR;
-using MongoDB.Driver.Linq;
using System;
using System.Linq;
using System.Threading.Tasks;
@@ -180,7 +179,7 @@ namespace Grand.Business.Marketing.Services.Newsteletters
orderby nls.Id
select nls;
- return await newsLetterSubscriptions.FirstOrDefaultAsync();
+ return await newsLetterSubscriptions.FirstOrDefaultAsync2();
}
/// <summary>
@@ -201,7 +200,7 @@ namespace Grand.Business.Marketing.Services.Newsteletters
orderby nls.Id
select nls;
- return await newsLetterSubscriptions.FirstOrDefaultAsync();
+ return await newsLetterSubscriptions.FirstOrDefaultAsync2();
}
/// <summary>
@@ -219,7 +218,7 @@ namespace Grand.Business.Marketing.Services.Newsteletters
orderby nls.Id
select nls;
- return await newsLetterSubscriptions.FirstOrDefaultAsync();
+ return await newsLetterSubscriptions.FirstOrDefaultAsync2();
}
/// <summary>
@@ -237,7 +236,8 @@ namespace Grand.Business.Marketing.Services.Newsteletters
int pageIndex = 0, int pageSize = int.MaxValue)
{
//do not filter by customer group
- var query = _subscriptionRepository.Table;
+ var query = from p in _subscriptionRepository.Table
+ select p;
if (!String.IsNullOrEmpty(email))
query = query.Where(nls => nls.Email.ToLower().Contains(email.ToLower()));
diff --git a/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsletterCategoryService.cs b/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsletterCategoryService.cs
index 85baf487a..6b125755c 100644
--- a/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsletterCategoryService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsletterCategoryService.cs
@@ -3,8 +3,6 @@ using Grand.Infrastructure.Extensions;
using Grand.Domain.Data;
using Grand.Domain.Messages;
using MediatR;
-using MongoDB.Driver;
-using MongoDB.Driver.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -94,7 +92,7 @@ namespace Grand.Business.Marketing.Services.Newsteletters
/// <returns>NewsletterCategories</returns>
public virtual async Task<IList<NewsletterCategory>> GetAllNewsletterCategory()
{
- return await _newsletterCategoryRepository.Table.ToListAsync();
+ return await _newsletterCategoryRepository.Table.ToListAsync2();
}
/// <summary>
@@ -107,7 +105,7 @@ namespace Grand.Business.Marketing.Services.Newsteletters
where !p.LimitedToStores || p.Stores.Contains(storeId)
orderby p.DisplayOrder
select p;
- return await query.ToListAsync();
+ return await query.ToListAsync2();
}
#endregion
}
diff --git a/src/Business/Grand.Business.Marketing/Services/PushNotifications/PushNotificationsService.cs b/src/Business/Grand.Business.Marketing/Services/PushNotifications/PushNotificationsService.cs
index 8ab1659c4..454714163 100644
--- a/src/Business/Grand.Business.Marketing/Services/PushNotifications/PushNotificationsService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/PushNotifications/PushNotificationsService.cs
@@ -7,8 +7,6 @@ using Grand.Domain;
using Grand.Domain.Data;
using Grand.Domain.PushNotifications;
using MediatR;
-using MongoDB.Driver;
-using MongoDB.Driver.Linq;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@@ -67,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).FirstOrDefaultAsync();
+ return await _pushRegistratiosnRepository.Table.Where(x => x.CustomerId == CustomerId).FirstOrDefaultAsync2();
}
/// <summary>
@@ -85,23 +83,23 @@ namespace Grand.Business.Marketing.Services.PushNotifications
/// </summary>
public virtual async Task<List<PushRegistration>> GetPushReceivers()
{
- return await _pushRegistratiosnRepository.Table.Where(x => x.Allowed).ToListAsync();
+ return await _pushRegistratiosnRepository.Table.Where(x => x.Allowed).ToListAsync2();
}
/// <summary>
/// Gets number of customers that accepted push notifications permission popup
/// </summary>
- public virtual Task<int> GetAllowedReceivers()
+ public virtual async Task<int> GetAllowedReceivers()
{
- return _pushRegistratiosnRepository.Table.Where(x => x.Allowed).CountAsync();
+ return await Task.FromResult(_pushRegistratiosnRepository.Table.Where(x => x.Allowed).Count());
}
/// <summary>
/// Gets number of customers that denied push notifications permission popup
/// </summary>
- public virtual Task<int> GetDeniedReceivers()
+ public virtual async Task<int> GetDeniedReceivers()
{
- return _pushRegistratiosnRepository.Table.Where(x => !x.Allowed).CountAsync();
+ return await Task.FromResult(_pushRegistratiosnRepository.Table.Where(x => !x.Allowed).Count());
}
/// <summary>
@@ -119,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).ToListAsync();
+ var allMessages = await _pushMessagesRepository.Table.OrderByDescending(x => x.SentOn).ToListAsync2();
return new PagedList<PushMessage>(allMessages.Skip(pageIndex * pageSize).Take(pageSize).ToList(), pageIndex, pageSize, allMessages.Count);
}
@@ -128,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).ToListAsync();
+ var allReceivers = await _pushRegistratiosnRepository.Table.OrderByDescending(x => x.RegisteredOn).ToListAsync2();
return new PagedList<PushRegistration>(allReceivers.Skip(pageIndex * pageSize).Take(pageSize).ToList(), pageIndex, pageSize, allReceivers.Count);
}
@@ -249,7 +247,7 @@ namespace Grand.Business.Marketing.Services.PushNotifications
/// <param name="Id"></param>
public virtual Task<PushRegistration> GetPushReceiver(string Id)
{
- return _pushRegistratiosnRepository.Table.Where(x => x.Id == Id).FirstOrDefaultAsync();
+ return _pushRegistratiosnRepository.Table.Where(x => x.Id == Id).FirstOrDefaultAsync2();
}
}
}
diff --git a/src/Core/Grand.Domain/Data/RepositoryExtensions.cs b/src/Core/Grand.Domain/Data/RepositoryExtensions.cs
index 72ea81f13..96889191e 100644
--- a/src/Core/Grand.Domain/Data/RepositoryExtensions.cs
+++ b/src/Core/Grand.Domain/Data/RepositoryExtensions.cs
@@ -31,5 +31,7 @@ namespace Grand.Domain.Data
{
return ((IMongoQueryable<T>)query).FirstOrDefaultAsync();
}
+
+
}
}