Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

CategoryTemplateService.cs

using Nop.Core.Domain.Catalog;
using Nop.Data;

namespace Nop.Services.Catalog;

/// 
/// Category template service
/// 
public partial class CategoryTemplateService : ICategoryTemplateService
{
    #region Fields

    protected readonly IRepository _categoryTemplateRepository;

    #endregion

    #region Ctor

    public CategoryTemplateService(IRepository categoryTemplateRepository)
    {
        _categoryTemplateRepository = categoryTemplateRepository;
    }

    #endregion

    #region Methods

    /// 
    /// Delete category template
    /// 
    /// Category template
    /// A task that represents the asynchronous operation
    public virtual async Task DeleteCategoryTemplateAsync(CategoryTemplate categoryTemplate)
    {
        await _categoryTemplateRepository.DeleteAsync(categoryTemplate);
    }

    /// 
    /// Gets all category templates
    /// 
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the category templates
    /// 
    public virtual async Task> GetAllCategoryTemplatesAsync()
    {
        var templates = await _categoryTemplateRepository.GetAllAsync(query =>
        {
            return from pt in query
                orderby pt.DisplayOrder, pt.Id
                select pt;
        }, cache => default);

        return templates;
    }

    /// 
    /// Gets a category template
    /// 
    /// Category template identifier
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the category template
    /// 
    public virtual async Task GetCategoryTemplateByIdAsync(int categoryTemplateId)
    {
        return await _categoryTemplateRepository.GetByIdAsync(categoryTemplateId, cache => default);
    }

    /// 
    /// Inserts category template
    /// 
    /// Category template
    /// A task that represents the asynchronous operation
    public virtual async Task InsertCategoryTemplateAsync(CategoryTemplate categoryTemplate)
    {
        await _categoryTemplateRepository.InsertAsync(categoryTemplate);
    }

    /// 
    /// Updates the category template
    /// 
    /// Category template
    /// A task that represents the asynchronous operation
    public virtual async Task UpdateCategoryTemplateAsync(CategoryTemplate categoryTemplate)
    {
        await _categoryTemplateRepository.UpdateAsync(categoryTemplate);
    }

    #endregion
}