Webiant Logo Webiant Logo
  1. No results found.

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

TaxCategoryService.cs

using Nop.Core.Domain.Tax;
using Nop.Data;

namespace Nop.Services.Tax;

/// 
/// Tax category service
/// 
public partial class TaxCategoryService : ITaxCategoryService
{
    #region Fields

    protected readonly IRepository _taxCategoryRepository;

    #endregion

    #region Ctor

    public TaxCategoryService(IRepository taxCategoryRepository)
    {
        _taxCategoryRepository = taxCategoryRepository;
    }

    #endregion

    #region Methods

    /// 
    /// Deletes a tax category
    /// 
    /// Tax category
    /// A task that represents the asynchronous operation
    public virtual async Task DeleteTaxCategoryAsync(TaxCategory taxCategory)
    {
        await _taxCategoryRepository.DeleteAsync(taxCategory);
    }

    /// 
    /// Gets all tax categories
    /// 
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the ax categories
    /// 
    public virtual async Task> GetAllTaxCategoriesAsync()
    {
        var taxCategories = await _taxCategoryRepository.GetAllAsync(query =>
        {
            return from tc in query
                orderby tc.DisplayOrder, tc.Id
                select tc;
        }, cache => default);

        return taxCategories;
    }

    /// 
    /// Gets a tax category
    /// 
    /// Tax category identifier
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the ax category
    /// 
    public virtual async Task GetTaxCategoryByIdAsync(int taxCategoryId)
    {
        return await _taxCategoryRepository.GetByIdAsync(taxCategoryId, cache => default);
    }

    /// 
    /// Inserts a tax category
    /// 
    /// Tax category
    /// A task that represents the asynchronous operation
    public virtual async Task InsertTaxCategoryAsync(TaxCategory taxCategory)
    {
        await _taxCategoryRepository.InsertAsync(taxCategory);
    }

    /// 
    /// Updates the tax category
    /// 
    /// Tax category
    /// A task that represents the asynchronous operation
    public virtual async Task UpdateTaxCategoryAsync(TaxCategory taxCategory)
    {
        await _taxCategoryRepository.UpdateAsync(taxCategory);
    }

    #endregion
}