Webiant Logo Webiant Logo
  1. No results found.

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

TopicTemplateService.cs

using Nop.Core.Domain.Topics;
using Nop.Data;

namespace Nop.Services.Topics;

/// 
/// Topic template service
/// 
public partial class TopicTemplateService : ITopicTemplateService
{
    #region Fields

    protected readonly IRepository _topicTemplateRepository;

    #endregion

    #region Ctor

    public TopicTemplateService(IRepository topicTemplateRepository)
    {
        _topicTemplateRepository = topicTemplateRepository;
    }

    #endregion

    #region Methods

    /// 
    /// Delete topic template
    /// 
    /// Topic template
    /// A task that represents the asynchronous operation
    public virtual async Task DeleteTopicTemplateAsync(TopicTemplate topicTemplate)
    {
        await _topicTemplateRepository.DeleteAsync(topicTemplate);
    }

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

        return templates;
    }

    /// 
    /// Gets a topic template
    /// 
    /// Topic template identifier
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the topic template
    /// 
    public virtual async Task GetTopicTemplateByIdAsync(int topicTemplateId)
    {
        return await _topicTemplateRepository.GetByIdAsync(topicTemplateId, cache => default);
    }

    /// 
    /// Inserts topic template
    /// 
    /// Topic template
    /// A task that represents the asynchronous operation
    public virtual async Task InsertTopicTemplateAsync(TopicTemplate topicTemplate)
    {
        await _topicTemplateRepository.InsertAsync(topicTemplate);
    }

    /// 
    /// Updates the topic template
    /// 
    /// Topic template
    /// A task that represents the asynchronous operation
    public virtual async Task UpdateTopicTemplateAsync(TopicTemplate topicTemplate)
    {
        await _topicTemplateRepository.UpdateAsync(topicTemplate);
    }

    #endregion
}