Try your search with a different keyword or use * as a wildcard.
using Nop.Core.Domain.Messages;
using Nop.Data;
using Nop.Services.Catalog;
using Nop.Services.Stores;
namespace Nop.Services.Messages;
///
/// Represents newsletter subscription type service implementation
///
public partial class NewsLetterSubscriptionTypeService : INewsLetterSubscriptionTypeService
{
#region Fields
protected readonly IRepository _newsLetterSubscriptionTypeRepository;
protected readonly IStoreMappingService _storeMappingService;
#endregion
#region Ctor
public NewsLetterSubscriptionTypeService(IRepository newsLetterSubscriptionTypeRepository,
IStoreMappingService storeMappingService)
{
_newsLetterSubscriptionTypeRepository = newsLetterSubscriptionTypeRepository;
_storeMappingService = storeMappingService;
}
#endregion
#region Methods
///
/// Inserts a newsletter subscription type
///
/// Newsletter subscription type
/// A task that represents the asynchronous operation
public virtual async Task InsertNewsLetterSubscriptionTypeAsync(NewsLetterSubscriptionType newsLetterSubscriptionType)
{
ArgumentNullException.ThrowIfNull(newsLetterSubscriptionType);
await _newsLetterSubscriptionTypeRepository.InsertAsync(newsLetterSubscriptionType);
}
///
/// Updates a newsletter subscription type
///
/// Newsletter subscription type
/// A task that represents the asynchronous operation
public virtual async Task UpdateNewsLetterSubscriptionTypeAsync(NewsLetterSubscriptionType newsLetterSubscriptionType)
{
ArgumentNullException.ThrowIfNull(newsLetterSubscriptionType);
await _newsLetterSubscriptionTypeRepository.UpdateAsync(newsLetterSubscriptionType);
}
///
/// Deletes a newsletter subscription type
///
/// Newsletter subscription type
/// A task that represents the asynchronous operation
public virtual async Task DeleteNewsLetterSubscriptionTypeAsync(NewsLetterSubscriptionType newsLetterSubscriptionType)
{
ArgumentNullException.ThrowIfNull(newsLetterSubscriptionType);
await _newsLetterSubscriptionTypeRepository.DeleteAsync(newsLetterSubscriptionType);
}
///
/// Gets a newsletter subscription type by newsletter subscription type identifier
///
/// The newsletter subscription type identifier
///
/// A task that represents the asynchronous operation
/// The task result contains the newsletter subscription type
///
public virtual async Task GetNewsLetterSubscriptionTypeByIdAsync(int newsLetterSubscriptionTypeId)
{
return await _newsLetterSubscriptionTypeRepository.GetByIdAsync(newsLetterSubscriptionTypeId, cache => default);
}
///
/// Gets the newsletter subscription type list
///
/// Load records allowed only in a specified store; pass 0 to load all records
///
/// A task that represents the asynchronous operation
/// The task result contains the newsletter subscription types
///
public virtual async Task> GetAllNewsLetterSubscriptionTypesAsync(int storeId = 0)
{
return await _newsLetterSubscriptionTypeRepository.GetAllAsync(async query =>
{
if (storeId > 0)
query = await _storeMappingService.ApplyStoreMapping(query, storeId);
query = query
.OrderBy(subscriptionType => subscriptionType.DisplayOrder)
.ThenBy(subscriptionType => subscriptionType.Id);
return query;
});
}
#endregion
}