using Nop.Core.Domain.Shipping; using Nop.Data; namespace Nop.Services.Shipping.Date; /// /// Represents the date range service /// public partial class DateRangeService : IDateRangeService { #region Fields protected readonly IRepository _deliveryDateRepository; protected readonly IRepository _productAvailabilityRangeRepository; #endregion #region Ctor public DateRangeService(IRepository deliveryDateRepository, IRepository productAvailabilityRangeRepository) { _deliveryDateRepository = deliveryDateRepository; _productAvailabilityRangeRepository = productAvailabilityRangeRepository; } #endregion #region Methods #region Delivery dates /// /// Get a delivery date /// /// The delivery date identifier /// /// A task that represents the asynchronous operation /// The task result contains the delivery date /// public virtual async Task GetDeliveryDateByIdAsync(int deliveryDateId) { return await _deliveryDateRepository.GetByIdAsync(deliveryDateId, cache => default); } /// /// Get all delivery dates /// /// /// A task that represents the asynchronous operation /// The task result contains the delivery dates /// public virtual async Task> GetAllDeliveryDatesAsync() { var deliveryDates = await _deliveryDateRepository.GetAllAsync(query => { return from dd in query orderby dd.DisplayOrder, dd.Id select dd; }, cache => default); return deliveryDates; } /// /// Insert a delivery date /// /// Delivery date /// A task that represents the asynchronous operation public virtual async Task InsertDeliveryDateAsync(DeliveryDate deliveryDate) { await _deliveryDateRepository.InsertAsync(deliveryDate); } /// /// Update the delivery date /// /// Delivery date /// A task that represents the asynchronous operation public virtual async Task UpdateDeliveryDateAsync(DeliveryDate deliveryDate) { await _deliveryDateRepository.UpdateAsync(deliveryDate); } /// /// Delete a delivery date /// /// The delivery date /// A task that represents the asynchronous operation public virtual async Task DeleteDeliveryDateAsync(DeliveryDate deliveryDate) { await _deliveryDateRepository.DeleteAsync(deliveryDate); } #endregion #region Product availability ranges /// /// Get a product availability range /// /// The product availability range identifier /// /// A task that represents the asynchronous operation /// The task result contains the product availability range /// public virtual async Task GetProductAvailabilityRangeByIdAsync(int productAvailabilityRangeId) { return productAvailabilityRangeId != 0 ? await _productAvailabilityRangeRepository.GetByIdAsync(productAvailabilityRangeId, cache => default) : null; } /// /// Get all product availability ranges /// /// /// A task that represents the asynchronous operation /// The task result contains the product availability ranges /// public virtual async Task> GetAllProductAvailabilityRangesAsync() { return await _productAvailabilityRangeRepository.GetAllAsync(query => { return from par in query orderby par.DisplayOrder, par.Id select par; }, cache => default); } /// /// Insert the product availability range /// /// Product availability range /// A task that represents the asynchronous operation public virtual async Task InsertProductAvailabilityRangeAsync(ProductAvailabilityRange productAvailabilityRange) { await _productAvailabilityRangeRepository.InsertAsync(productAvailabilityRange); } /// /// Update the product availability range /// /// Product availability range /// A task that represents the asynchronous operation public virtual async Task UpdateProductAvailabilityRangeAsync(ProductAvailabilityRange productAvailabilityRange) { await _productAvailabilityRangeRepository.UpdateAsync(productAvailabilityRange); } /// /// Delete the product availability range /// /// Product availability range /// A task that represents the asynchronous operation public virtual async Task DeleteProductAvailabilityRangeAsync(ProductAvailabilityRange productAvailabilityRange) { await _productAvailabilityRangeRepository.DeleteAsync(productAvailabilityRange); } #endregion #endregion }