public ValidationResult ValidateUpdate(CampaignDetails newCampaign, CampaignDetails oldCampaign)
        {
            var validationResult = new ValidationResult();

            if (newCampaign.Conditions.Any())
            {
                validationResult.Add(_conditionValidationService.ValidateConditionsBonusTypes(newCampaign.Conditions));
                validationResult.Add(_conditionValidationService.ValidateConditionsPartnersIds(newCampaign.Conditions));
            }

            if (!validationResult.IsValid)
            {
                return(validationResult);
            }

            if (newCampaign.Contents.Any())
            {
                validationResult.Add(_contentValidationService
                                     .ValidateHaveInvalidOrEmptyIds(newCampaign.Contents.Select(c => c.Id).ToList(),
                                                                    oldCampaign.Contents.Select(c => c.Id).ToList()));
            }

            if (!validationResult.IsValid)
            {
                return(validationResult);
            }

            // Note: Removed old earn rules validation on edit allowing modification of the earn rule at any time
            //switch (oldCampaign.CampaignStatus)
            //{
            //    case CampaignStatus.Active:
            //        {
            //            validationResult.Add(ValidateUpdateForActiveCampaign(newCampaign, oldCampaign));
            //            break;
            //        }
            //    case CampaignStatus.Inactive:
            //        {
            //            validationResult.Add(ValidateUpdateForInactiveCampaign(newCampaign, oldCampaign));
            //            break;
            //        }
            //    case CampaignStatus.Completed:
            //        {
            //            validationResult.Add(ValidateUpdateForCompletedCampaigns(newCampaign, oldCampaign));
            //            break;
            //        }
            //    case CampaignStatus.Pending:
            //        {
            //            validationResult.Add(ValidateUpdateForPendingCampaigns(newCampaign, oldCampaign));
            //            break;
            //        }
            //    default:
            //        throw new ArgumentOutOfRangeException();
            //}

            return(validationResult);
        }
        public async Task UpdateAsync(BurnRuleModel burnRuleModel)
        {
            var oldEntity = await _burnRuleRepository.GetAsync(burnRuleModel.Id);

            if (oldEntity == null)
            {
                throw new EntityNotFoundException($"Burn rule with id {burnRuleModel.Id} does not exist.");
            }

            var response = _burnRuleContentValidation.
                           ValidateHaveInvalidOrEmptyIds(burnRuleModel.BurnRuleContents.Select(c => c.Id).ToList(),
                                                         oldEntity.BurnRuleContents.Select(c => c.Id).ToList());

            if (!response.IsValid)
            {
                throw new EntityNotValidException(string.Join(Environment.NewLine, response.ValidationMessages));
            }

            burnRuleModel.CreationDate = oldEntity.CreationDate;
            burnRuleModel.CreatedBy    = oldEntity.CreatedBy;

            if (burnRuleModel.UsePartnerCurrencyRate)
            {
                burnRuleModel.AmountInTokens   = null;
                burnRuleModel.AmountInCurrency = null;
            }

            var contentsToRemove = oldEntity.BurnRuleContents.Where(c1 => burnRuleModel.BurnRuleContents.All(c2 => c1.Id != c2.Id)).ToList();

            await _burnRuleContentRepository.DeleteAsync(contentsToRemove);

            foreach (var content in contentsToRemove)
            {
                if (content.RuleContentType == RuleContentType.UrlForPicture)
                {
                    await _fileService.DeleteAsync(content.Id);
                }
            }

            var partnersToRemove = oldEntity.PartnerIds.Where(c1 => burnRuleModel.PartnerIds.All(c2 => c1 != c2)).ToList();
            var partnersToAdd    = burnRuleModel.PartnerIds.Where(c1 => oldEntity.PartnerIds.All(c2 => c1 != c2)).ToList();

            await _burnRulePartnerRepository.DeleteAsync(partnersToRemove, burnRuleModel.Id);

            await _burnRulePartnerRepository.InsertAsync(partnersToAdd, burnRuleModel.Id);

            await _burnRuleRepository.UpdateAsync(burnRuleModel);

            await PublishSpendRuleChangeEvent(burnRuleModel, ActionType.Edited);
        }