public virtual async Task <AggregateReRouteDto> CreateAsync(AggregateReRouteCreateDto input)
        {
            var aggregateNameExists = await _aggregateReRouteRepository
                                      .AggregateReRouteNameExistsAsync(input.Name);

            if (aggregateNameExists)
            {
                throw new UserFriendlyException(L["AggregateReRouteExists", input.Name]);
            }
            var aggregateRoute = ObjectMapper.Map <AggregateReRouteCreateDto, AggregateReRoute>(input);

            aggregateRoute.SetUpstream(input.UpstreamHost, input.UpstreamPathTemplate);
            foreach (var httpMethod in input.UpstreamHttpMethod)
            {
                aggregateRoute.AddUpstreamHttpMethod(httpMethod);
            }
            foreach (var routeKey in input.ReRouteKeys)
            {
                aggregateRoute.AddRouteKey(routeKey);
            }
            aggregateRoute = await _aggregateReRouteRepository.InsertAsync(aggregateRoute);

            await DistributedEventBus.PublishAsync(new ApigatewayConfigChangeEventData(aggregateRoute.AppId, "AggregateRoute", "Create"));

            return(ObjectMapper.Map <AggregateReRoute, AggregateReRouteDto>(aggregateRoute));
        }
Exemple #2
0
        public virtual async Task <AggregateReRouteDto> CreateAsync(AggregateReRouteCreateDto aggregateReRouteCreate)
        {
            var aggregateNameExists = await _aggregateReRouteRepository
                                      .AggregateReRouteNameExistsAsync(aggregateReRouteCreate.Name);

            if (aggregateNameExists)
            {
                throw new UserFriendlyException(L["AggregateReRouteExists", aggregateReRouteCreate.Name]);
            }
            var aggregateRoute = ObjectMapper.Map <AggregateReRouteCreateDto, AggregateReRoute>(aggregateReRouteCreate);

            aggregateRoute.SetUpstream(aggregateReRouteCreate.UpstreamHost, aggregateReRouteCreate.UpstreamPathTemplate);
            foreach (var httpMethod in aggregateReRouteCreate.UpstreamHttpMethod)
            {
                aggregateRoute.AddUpstreamHttpMethod(httpMethod);
            }
            foreach (var routeKey in aggregateReRouteCreate.ReRouteKeys)
            {
                aggregateRoute.AddRouteKey(routeKey);
            }
            aggregateRoute = await _aggregateReRouteRepository.InsertAsync(aggregateRoute);

            await _eventPublisher.PublishAsync(ApigatewayConfigChangeCommand.EventName,
                                               new ApigatewayConfigChangeCommand("AggregateRoute", "Create"));

            return(ObjectMapper.Map <AggregateReRoute, AggregateReRouteDto>(aggregateRoute));
        }
Exemple #3
0
 public async Task <AggregateReRouteDto> CreateAsync(AggregateReRouteCreateDto aggregateReRouteCreate)
 {
     return(await AggregateReRouteAppService.CreateAsync(aggregateReRouteCreate));
 }