using Hotline.Orders;
using MapsterMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Hotline.Repository.SqlSugar.DataPermissions;
using SqlSugar;
using XF.Domain.Authentications;
using XF.Domain.Dependency;
using Hotline.Share.Dtos.Order;

namespace Hotline.Repository.SqlSugar.Orders
{
	public class RepeatableEventDetailRepository : BaseRepository<RepeatableEventDetail>, IRepeatableEventDetailRepository, IScopeDependency
	{
		private readonly ISessionContext _sessionContext;
		private readonly IMapper _mapper;
		public RepeatableEventDetailRepository(
			ISugarUnitOfWork<HotlineDbContext> uow,
			IDataPermissionFilterBuilder dataPermissionFilterBuilder,
			ISessionContext sessionContext,
			IMapper mapper, IServiceProvider serviceProvider
        ) : base(uow, dataPermissionFilterBuilder, serviceProvider)
		{
			_sessionContext = sessionContext;
			_mapper = mapper;
		}

		public async Task<int> DeleteAsync(string id, CancellationToken cancellationToken) { 
			return await Db.Deleteable<RepeatableEventDetail>().Where(x => x.RepeatableId == id).ExecuteCommandAsync(cancellationToken);
		}

		public async Task<int> DeleteAsync(List<RepeatableEventDetailOpDto> dto, CancellationToken cancellationToken)
		{
			var ids = dto.Select(x => x.Id).ToList();
			return await Db.Deleteable<RepeatableEventDetail>().In(x=>x.Id, ids).ExecuteCommandAsync(cancellationToken);
		}

	}
}
