private bool HasUserRatings(User user)
        {
            RatingServiceClient client = new RatingServiceClient();
            var ratings = client.GetAll().FindAll(r => r.User.Id == user.Id);

            return(ratings.Count != 0);
        }
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddStandardTemplate((svc, resolver) =>
            {
                var config = resolver.GetService <IConfiguration>();

                var cartChannel = new Channel(config["RpcClients:CartService"], ChannelCredentials.Insecure);
                var cartClient  = new CartServiceClient(cartChannel);

                var inventoryChannel = new Channel(config["RpcClients:InventoryService"], ChannelCredentials.Insecure);
                var inventoryClient  = new InventoryServiceClient(inventoryChannel);

                var reviewChannel = new Channel(config["RpcClients:ReviewService"], ChannelCredentials.Insecure);
                var reviewClient  = new ReviewServiceClient(reviewChannel);
                var pingClient    = new PingServiceClient(reviewChannel);

                var catalogChannel = new Channel(config["RpcClients:CatalogService"], ChannelCredentials.Insecure);
                var catalogClient  = new CatalogServiceClient(catalogChannel);

                var ratingChannel = new Channel(config["RpcClients:RatingService"], ChannelCredentials.Insecure);
                var ratingClient  = new RatingServiceClient(ratingChannel);

                services.AddSingleton(typeof(CartServiceClient), cartClient);
                services.AddSingleton(typeof(InventoryServiceClient), inventoryClient);
                services.AddSingleton(typeof(ReviewServiceClient), reviewClient);
                services.AddSingleton(typeof(PingServiceClient), pingClient);
                services.AddSingleton(typeof(CatalogServiceClient), catalogClient);
                services.AddSingleton(typeof(RatingServiceClient), ratingClient);
            });
        }
Exemple #3
0
        private void RegisterGrpcServices(IServiceCollection services)
        {
            var cartChannel = new Channel(Configuration["RpcClients:CartService"], ChannelCredentials.Insecure);
            var cartClient  = new CartServiceClient(cartChannel);

            var inventoryChannel = new Channel(Configuration["RpcClients:InventoryService"],
                                               ChannelCredentials.Insecure);
            var inventoryClient = new InventoryServiceClient(inventoryChannel);

            var reviewChannel = new Channel(Configuration["RpcClients:ReviewService"], ChannelCredentials.Insecure);
            var reviewClient  = new ReviewServiceClient(reviewChannel);
            var pingClient    = new PingServiceClient(reviewChannel);

            var catalogChannel =
                new Channel(Configuration["RpcClients:CatalogService"], ChannelCredentials.Insecure);
            var catalogClient = new CatalogServiceClient(catalogChannel);

            var ratingChannel = new Channel(Configuration["RpcClients:RatingService"], ChannelCredentials.Insecure);
            var ratingClient  = new RatingServiceClient(ratingChannel);

            services.AddSingleton(typeof(CartServiceClient), cartClient);
            services.AddSingleton(typeof(InventoryServiceClient), inventoryClient);
            services.AddSingleton(typeof(ReviewServiceClient), reviewClient);
            services.AddSingleton(typeof(PingServiceClient), pingClient);
            services.AddSingleton(typeof(CatalogServiceClient), catalogClient);
            services.AddSingleton(typeof(RatingServiceClient), ratingClient);
        }
 public CoolStoreResolverService(
     CatalogServiceClient catalogServiceClient,
     CartServiceClient cartServiceClient,
     InventoryServiceClient inventoryServiceClient,
     RatingServiceClient ratingServiceClient,
     ReviewServiceClient reviewServiceClient)
 {
     _catalogServiceClient   = catalogServiceClient;
     _cartServiceClient      = cartServiceClient;
     _inventoryServiceClient = inventoryServiceClient;
     _ratingServiceClient    = ratingServiceClient;
     _reviewServiceClient    = reviewServiceClient;
 }
 public CoolStoreResolverService(
     IHttpContextAccessor httpContext,
     CatalogServiceClient catalogServiceClient,
     CartServiceClient cartServiceClient,
     InventoryServiceClient inventoryServiceClient,
     RatingServiceClient ratingServiceClient)
 {
     _httpContext            = httpContext;
     _catalogServiceClient   = catalogServiceClient;
     _cartServiceClient      = cartServiceClient;
     _inventoryServiceClient = inventoryServiceClient;
     _ratingServiceClient    = ratingServiceClient;
 }
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddStandardTemplate((svc, resolver) =>
            {
                var cartChannel = new Channel(Configuration["RpcClients:CartService"], ChannelCredentials.Insecure);
                var cartClient  = new CartServiceClient(cartChannel);

                var inventoryChannel = new Channel(Configuration["RpcClients:InventoryService"],
                                                   ChannelCredentials.Insecure);
                var inventoryClient = new InventoryServiceClient(inventoryChannel);

                var reviewChannel = new Channel(Configuration["RpcClients:ReviewService"], ChannelCredentials.Insecure);
                var reviewClient  = new ReviewServiceClient(reviewChannel);
                var pingClient    = new PingServiceClient(reviewChannel);

                var catalogChannel =
                    new Channel(Configuration["RpcClients:CatalogService"], ChannelCredentials.Insecure);
                var catalogClient = new CatalogServiceClient(catalogChannel);

                var ratingChannel = new Channel(Configuration["RpcClients:RatingService"], ChannelCredentials.Insecure);
                var ratingClient  = new RatingServiceClient(ratingChannel);

                services.AddSingleton(typeof(CartServiceClient), cartClient);
                services.AddSingleton(typeof(InventoryServiceClient), inventoryClient);
                services.AddSingleton(typeof(ReviewServiceClient), reviewClient);
                services.AddSingleton(typeof(PingServiceClient), pingClient);
                services.AddSingleton(typeof(CatalogServiceClient), catalogClient);
                services.AddSingleton(typeof(RatingServiceClient), ratingClient);

                services.AddSingleton <ICoolStoreResolverService, CoolStoreResolverService>();
                services.AddSingleton <CoolStoreSchema>();
                services.AddSingleton(provider => provider.GetRequiredService <CoolStoreSchema>().CoolStore);

                services.AddSignalR(options => options.EnableDetailedErrors = true)
                .AddQueryStreamHubWithTracing();

                services.AddCors(options =>
                {
                    options.AddDefaultPolicy(policy =>
                    {
                        policy.WithOrigins("*");
                        policy.AllowAnyHeader();
                        policy.AllowAnyMethod();
                        policy.AllowCredentials();
                        policy.WithHeaders("X-Requested-With", "authorization");
                    });
                });

                services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            });
        }
Exemple #7
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddStandardTemplate((svc, resolver) =>
            {
                var cartChannel = new Channel(Configuration["RpcClients:CartService"], ChannelCredentials.Insecure);
                var cartClient  = new CartServiceClient(cartChannel);

                var inventoryChannel = new Channel(Configuration["RpcClients:InventoryService"],
                                                   ChannelCredentials.Insecure);
                var inventoryClient = new InventoryServiceClient(inventoryChannel);

                var reviewChannel = new Channel(Configuration["RpcClients:ReviewService"], ChannelCredentials.Insecure);
                var reviewClient  = new ReviewServiceClient(reviewChannel);
                var pingClient    = new PingServiceClient(reviewChannel);

                var catalogChannel =
                    new Channel(Configuration["RpcClients:CatalogService"], ChannelCredentials.Insecure);
                var catalogClient = new CatalogServiceClient(catalogChannel);

                var ratingChannel = new Channel(Configuration["RpcClients:RatingService"], ChannelCredentials.Insecure);
                var ratingClient  = new RatingServiceClient(ratingChannel);

                services.AddSingleton(typeof(CartServiceClient), cartClient);
                services.AddSingleton(typeof(InventoryServiceClient), inventoryClient);
                services.AddSingleton(typeof(ReviewServiceClient), reviewClient);
                services.AddSingleton(typeof(PingServiceClient), pingClient);
                services.AddSingleton(typeof(CatalogServiceClient), catalogClient);
                services.AddSingleton(typeof(RatingServiceClient), ratingClient);

                services.AddSingleton <ICoolStoreResolverService, CoolStoreResolverService>();
                services.AddSingleton <CoolStoreSchema>();
                services.AddSingleton(provider => provider.GetRequiredService <CoolStoreSchema>().CoolStore);

                services.AddCors(options =>
                {
                    options.AddPolicy("CorsPolicy",
                                      policy => policy
                                      .AllowAnyMethod()
                                      .AllowAnyHeader()
                                      /* https://github.com/aspnet/AspNetCore/issues/4457 */
                                      .SetIsOriginAllowed(host => true)
                                      .AllowCredentials());
                });

                services.AddSignalR(options => options.EnableDetailedErrors = true)
                .AddQueryStreamHubWithTracing();

                services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            });
        }
Exemple #8
0
 public RatingController(RatingServiceClient serviceClient)
 {
     _serviceClient = serviceClient;
 }