Example #1
0
        public async Task DeleteAsync(string planId)
        {
            using (_unitOfWork)
            {
                Plan plan = await _planReadRepository.GetByIdAsync(planId);

                if (plan == null)
                {
                    throw new DomainServicesException("Plan not found.");
                }

                foreach (PlanArea planArea in _planAreaService.GetBy(plan))
                {
                    await _planAreaService.DeleteAsync(planArea.Id);
                }

                foreach (BotSubscription botSubscription in _botSubscriptionReadRepository.GetAll().Where(s => s.PlanId == planId))
                {
                    await _botSubscriptionWriteRepository.DeleteAsync(botSubscription);
                }

                await _planWriteRepository.DeleteAsync(plan);

                await _unitOfWork.CommitAsync();
            }
        }
        public async Task <IActionResult> Delete(string id)
        {
            var planArea = await _planAreaService.GetByIdAsync(id);

            ValidateUser(planArea.Plan.UserId);

            await _planAreaService.DeleteAsync(id);

            return(Ok());
        }
        public async Task DeleteAsync(string planId)
        {
            Plan plan = await _planObjectService.GetByIdAsync <Plan>(planId);

            if (plan == null)
            {
                throw new DomainServicesException("Plan not found.");
            }

            foreach (PlanArea planArea in _planAreaService.GetBy(plan))
            {
                await _planAreaService.DeleteAsync(planArea.Id);
            }

            foreach (BotSubscription botSubscription in _botSubscriptionObjectService.GetBotSubscriptionsByPlan(planId))
            {
                await _botSubscriptionObjectService.DeleteAsync(botSubscription);
            }

            await _planObjectService.DeleteAsync(plan);
        }