public async Task <BonusDto> DeleteBonusAsync(Guid id, CancellationToken cancellationToken) { if (id == Guid.Empty) { throw new ArgumentNullException("", Resources.IdentifierIsNull); } var result = await _bonusRepository.RemoveAsync(id, cancellationToken); return(_mapper.Map <BonusDto>(result)); }
public async Task <BonusDto> DeleteBonusAsync(Guid id, CancellationToken cancellationToken) { if (id == Guid.Empty) { throw new ArgumentNullException("", Resources.IdentifierIsNull); } var histories = await _historyRepository.GetBonusHistoryByUsageDate(id, DateTime.MinValue, DateTime.MaxValue, cancellationToken); if (histories.Any()) { throw new ArgumentException(Resources.UnableToRemoveBonus); } var result = await _bonusRepository.RemoveAsync(id, cancellationToken); return(_mapper.Map <BonusDto>(result)); }