public async Task <PlanServiceModel> CreateBotSubscriptionAsync(BotSubscriptionServiceModel model)
        {
            Plan plan = await _planReadRepository.GetByIdAsync(model.PlanId);

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

            if (_botSubscriptionReadRepository
                .GetAll().Count(x => x.PlanId == model.PlanId && x.ChatId == model.ChatId) > 0)
            {
                throw new DomainServicesException("You've already subscribed for this plan.");
            }

            await _botSubscriptionWriteRepository.CreateAsync(new BotSubscription
            {
                ChatId = model.ChatId,
                PlanId = model.PlanId
            });

            await _botSubscriptionWriteRepository.SaveChangesAsync();

            return(new PlanServiceModel
            {
                Id = plan.Id,
                Name = plan.Name
            });
        }
        public async Task <PlanServiceModel> CreateBotSubscriptionAsync(BotSubscriptionServiceModel model)
        {
            Plan plan = await _planObjectService.GetByIdAsync <Plan>(model.PlanId);

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

            if (_botSubscriptionObjectService.GetBotSubscriptionsByPlanAndChat(model.PlanId, model.ChatId).Any())
            {
                throw new DomainServicesException("You've already subscribed for this plan.");
            }

            await _botSubscriptionObjectService.CreateAsync(new BotSubscription
            {
                ChatId = model.ChatId,
                PlanId = model.PlanId
            });

            return(new PlanServiceModel
            {
                Id = plan.Id,
                Name = plan.Name
            });
        }