Mango.Nop.Plugins/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ProductTextMappingDbTable.cs

28 lines
1.2 KiB
C#

using FruitBank.Common.Entities;
using LinqToDB;
using Mango.Nop.Data.Repositories;
using Nop.Core.Caching;
using Nop.Core.Configuration;
using Nop.Core.Events;
using Nop.Data;
using Mango.Nop.Core.Loggers;
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
public class ProductTextMappingDbTable : MgDbTableBase<ProductTextMapping>
{
public ProductTextMappingDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings)
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings)
{
}
public IQueryable<ProductTextMapping> GetByRawText(string rawText)
=> GetAll().Where(m => m.RawText == rawText.ToLower().Trim());
public IQueryable<ProductTextMapping> GetByRawText(string rawText, bool isPreorder)
=> GetByRawText(rawText).Where(m => m.IsPreorder == isPreorder);
public IQueryable<ProductTextMapping> GetRecentByRawText(string rawText, bool isPreorder, int lastCount = 5)
=> GetByRawText(rawText, isPreorder).OrderByDescending(m => m.CreatedOnUtc).Take(lastCount);
}