using Nop.Core.Domain.Catalog; using Nop.Data; namespace Nop.Services.Catalog; /// /// Product template service /// public partial class ProductTemplateService : IProductTemplateService { #region Fields protected readonly IRepository _productTemplateRepository; #endregion #region Ctor public ProductTemplateService(IRepository productTemplateRepository) { _productTemplateRepository = productTemplateRepository; } #endregion #region Methods /// /// Delete product template /// /// Product template /// A task that represents the asynchronous operation public virtual async Task DeleteProductTemplateAsync(ProductTemplate productTemplate) { await _productTemplateRepository.DeleteAsync(productTemplate); } /// /// Gets all product templates /// /// /// A task that represents the asynchronous operation /// The task result contains the product templates /// public virtual async Task> GetAllProductTemplatesAsync() { var templates = await _productTemplateRepository.GetAllAsync(query => { return from pt in query orderby pt.DisplayOrder, pt.Id select pt; }, cache => default); return templates; } /// /// Gets a product template /// /// Product template identifier /// /// A task that represents the asynchronous operation /// The task result contains the product template /// public virtual async Task GetProductTemplateByIdAsync(int productTemplateId) { return await _productTemplateRepository.GetByIdAsync(productTemplateId, cache => default); } /// /// Inserts product template /// /// Product template /// A task that represents the asynchronous operation public virtual async Task InsertProductTemplateAsync(ProductTemplate productTemplate) { await _productTemplateRepository.InsertAsync(productTemplate); } /// /// Updates the product template /// /// Product template /// A task that represents the asynchronous operation public virtual async Task UpdateProductTemplateAsync(ProductTemplate productTemplate) { await _productTemplateRepository.UpdateAsync(productTemplate); } #endregion }