Try your search with a different keyword or use * as a wildcard.
using Nop.Core.Caching;
using Nop.Core.Domain.Catalog;
using Nop.Data;
namespace Nop.Services.Catalog;
///
/// Review type service implementation
///
public partial class ReviewTypeService : IReviewTypeService
{
#region Fields
protected readonly IRepository _productReviewReviewTypeMappingRepository;
protected readonly IRepository _reviewTypeRepository;
protected readonly IStaticCacheManager _staticCacheManager;
#endregion
#region Ctor
public ReviewTypeService(IRepository productReviewReviewTypeMappingRepository,
IRepository reviewTypeRepository,
IStaticCacheManager staticCacheManager)
{
_productReviewReviewTypeMappingRepository = productReviewReviewTypeMappingRepository;
_reviewTypeRepository = reviewTypeRepository;
_staticCacheManager = staticCacheManager;
}
#endregion
#region Methods
#region Review type
///
/// Gets all review types
///
///
/// A task that represents the asynchronous operation
/// The task result contains the review types
///
public virtual async Task> GetAllReviewTypesAsync()
{
return await _reviewTypeRepository.GetAllAsync(
query => query.OrderBy(reviewType => reviewType.DisplayOrder).ThenBy(reviewType => reviewType.Id),
cache => default);
}
///
/// Gets a review type
///
/// Review type identifier
///
/// A task that represents the asynchronous operation
/// The task result contains the review type
///
public virtual async Task GetReviewTypeByIdAsync(int reviewTypeId)
{
return await _reviewTypeRepository.GetByIdAsync(reviewTypeId, cache => default);
}
///
/// Inserts a review type
///
/// Review type
/// A task that represents the asynchronous operation
public virtual async Task InsertReviewTypeAsync(ReviewType reviewType)
{
await _reviewTypeRepository.InsertAsync(reviewType);
}
///
/// Updates a review type
///
/// Review type
/// A task that represents the asynchronous operation
public virtual async Task UpdateReviewTypeAsync(ReviewType reviewType)
{
await _reviewTypeRepository.UpdateAsync(reviewType);
}
///
/// Delete review type
///
/// Review type
/// A task that represents the asynchronous operation
public virtual async Task DeleteReviewTypeAsync(ReviewType reviewType)
{
await _reviewTypeRepository.DeleteAsync(reviewType);
}
#endregion
#region Product review type mapping
///
/// Gets product review and review type mappings by product review identifier
///
/// The product review identifier
///
/// A task that represents the asynchronous operation
/// The task result contains the product review and review type mapping collection
///
public async Task> GetProductReviewReviewTypeMappingsByProductReviewIdAsync(
int productReviewId)
{
var key = _staticCacheManager.PrepareKeyForDefaultCache(NopCatalogDefaults.ProductReviewTypeMappingByReviewTypeCacheKey, productReviewId);
var query = from pam in _productReviewReviewTypeMappingRepository.Table
orderby pam.Id
where pam.ProductReviewId == productReviewId
select pam;
var productReviewReviewTypeMappings = await _staticCacheManager.GetAsync(key, async () => await query.ToListAsync());
return productReviewReviewTypeMappings;
}
///
/// Inserts a product review and review type mapping
///
/// Product review and review type mapping
/// A task that represents the asynchronous operation
public virtual async Task InsertProductReviewReviewTypeMappingsAsync(ProductReviewReviewTypeMapping productReviewReviewType)
{
await _productReviewReviewTypeMappingRepository.InsertAsync(productReviewReviewType);
}
#endregion
#endregion
}