public ProductsController()
 {
     _catalogService = ServiceProxy.Create <IProductCatalogService>(
         new Uri("fabric:/ECommerce/ECommerce.ProductCatalog"),
         new ServicePartitionKey(0)
         );
 }
Пример #2
0
        public async Task <CheckoutSummary> CheckoutAsync(string userId)
        {
            var result = new CheckoutSummary();

            result.Date     = DateTime.UtcNow;
            result.Products = new List <CheckoutProduct>();

            // Get the user basket
            IUserActor userActor = GetUserActor(userId);

            BasketItem[] basket = await userActor.GetBasket();

            IProductCatalogService catalogService = GetProductCatalogService();

            foreach (var item in basket)
            {
                var product = await catalogService.GetProduct(item.ProductId);

                var checkoutProduct = new CheckoutProduct()
                {
                    Product  = product,
                    Price    = product.Price,
                    Quantity = item.Quantity
                };

                result.Products.Add(checkoutProduct);
            }

            return(result);
        }
 public ProductCatalogBaseController(
                   ICookieStorageService cookieStorageService,
                   IProductCatalogService productCatalogService)
     : base(cookieStorageService)
 {
     _productCatalogService = productCatalogService;
 }
Пример #4
0
        public async Task <CheckoutSummary> Checkout(string userId)
        {
            var result = new CheckoutSummary();

            //call user actor to get the basket
            IUserActor             userActor = GetUserActor(userId);
            Dictionary <Guid, int> basket    = await userActor.GetBasket();

            //get catalog client
            IProductCatalogService catalogService = GetProductCatalogService();

            //constuct CheckoutProduct items by calling to the catalog
            foreach (KeyValuePair <Guid, int> basketLine in basket)
            {
                Product product = await catalogService.GetProduct(basketLine.Key);

                var checkoutProduct = new CheckoutProduct
                {
                    Product  = product,
                    Price    = product.Price,
                    Quantity = basketLine.Value
                };
                result.Products.Add(checkoutProduct);
            }

            //generate total price
            result.TotalPrice = result.Products.Sum(p => p.Price);

            //clear user basket
            await userActor.ClearBasket();

            await AddToHistory(result);

            return(result);
        }
Пример #5
0
 public ProductsController()
 {
     _productCatalogService = ServiceProxy.Create <IProductCatalogService>(
         serviceUri: new Uri("fabric:/ECommerce.Sf/ECommerce.ProductCatalog"),
         partitionKey: new ServicePartitionKey(0),
         listenerName: "ProductCatalog.Remoting.Listener");
 }
Пример #6
0
        public async Task <CheckoutSummary> CheckoutAsync(string userId)
        {
            var result = new CheckoutSummary()
            {
                Date     = DateTime.UtcNow,
                Products = new List <CheckoutProduct>()
            };

            IUserActor userActor = GetUserActor(userId);

            BasketItem[] basket = await userActor.GetBasket();

            IProductCatalogService catalogService = GetProductCatalogService();

            foreach (var basketItem in basket)
            {
                Product product = await catalogService.GetProductAsync(basketItem.ProductId);

                var checkoutProduct = new CheckoutProduct
                {
                    Product  = product,
                    Price    = product.Price,
                    Quantity = basketItem.Quantity
                };
                result.Products.Add(checkoutProduct);
            }
            result.TotalPrice = result.Products.Sum(p => p.Price * p.Quantity);
            //clear user basket
            await userActor.ClearBasket();

            await AddToHistoryAsync(result);

            return(result);
        }
Пример #7
0
        public ProductController()
        {
            var proxyFactory = new ServiceProxyFactory(c => new FabricTransportServiceRemotingClientFactory());

            _service = proxyFactory.CreateServiceProxy <IProductCatalogService>(
                new Uri("fabric:/ECommerce/ECommerce.ProductCatalog"), new ServicePartitionKey(0));
        }
Пример #8
0
        public async Task <CheckoutSummary> Checkout(string userId)
        {
            var result = new CheckoutSummary();

            result.Date     = DateTime.UtcNow;
            result.Products = new List <CheckoutProduct>();

            IUserActor             userActor = GetUserActor(userId);
            Dictionary <Guid, int> basket    = await userActor.GetBasket();

            IProductCatalogService catalogService = GetProductCatalogService();

            foreach (KeyValuePair <Guid, int> basketLine in basket)
            {
                Product product = await catalogService.GetProduct(basketLine.Key);

                var checkoutProduct = new CheckoutProduct
                {
                    Product  = product,
                    Price    = product.Price,
                    Quantity = basketLine.Value
                };
                result.Products.Add(checkoutProduct);
            }

            result.TotalPrice = result.Products.Sum(p => p.Price);

            await userActor.ClearBasket();

            await AddToHistory(result);

            return(result);
        }
Пример #9
0
        public async Task <CheckoutSummary> CheckoutAsync(string userId)
        {
            var result = new CheckoutSummary();

            result.Date     = DateTime.UtcNow;
            result.Products = new List <CheckoutProduct>();

            //get user basket
            var userActor = GetUserActor(userId);
            Dictionary <Guid, int> basket = await userActor.GetBasket();

            //get catalogClient
            IProductCatalogService catalogService = GetProductCatalogService();

            foreach (var item in basket)
            {
                Product product = await catalogService.GetProduct(item.Key);

                result.Products.Add(
                    new CheckoutProduct
                {
                    Product  = product,
                    Price    = product.Price,
                    Quantity = item.Value
                });
            }
            await userActor.ClearBasket();

            await AddToHistoryAsync(result);

            return(result);
        }
Пример #10
0
        public BasketController(IProductCatalogService productCatalogService, IBasketService basketService,
								ICookieStorageService cookieStorageService)
            : base(cookieStorageService, productCatalogService)
        {
            _basketService = basketService;
            _cookieStorageService = cookieStorageService;
        }
 public ProductCatalogBaseController(
     ICookieStorageService cookieStorageService,
     IProductCatalogService productCatalogService)
     : base(cookieStorageService)
 {
     _productCatalogService = productCatalogService;
 }
 public BasketController(IProductCatalogService productCatalogueService,
                         IBasketService basketService,
                         ICookieStorageService cookieStorageService) : base(cookieStorageService, productCatalogueService)
 {
     _basketService        = basketService;
     _cookieStorageService = cookieStorageService;
 }
Пример #13
0
        static CategoryProductPriceCollection GetProductsForCustomerId(int customerId)
        {
            CategoryProductPriceCollection cpp       = null;
            IProductCatalogService         pcService = ProductCatalogService;

            cpp = pcService.GetProductsForCustomerId(customerId);
            return(cpp);
        }
Пример #14
0
        public ProductsController(ILogger <ProductsController> logger)
        {
            _logger = logger;

            _catalogService = ServiceProxy.Create <IProductCatalogService>(
                new Uri("fabric:/ECommerce/ProductCatalog"),
                new ServicePartitionKey(0));
        }
Пример #15
0
        public ProductsController()
        {
            var proxyFactory = new ServiceProxyFactory((c) => new FabricTransportServiceRemotingClientFactory(
                                                           serializationProvider: new GenericDataProvider(new List <Type> {
                typeof(Product), typeof(List <Product>)
            })));

            _catalogService = proxyFactory.CreateServiceProxy <IProductCatalogService>(new Uri("fabric:/ECommerce/ECommerce.ProductCatalog"), new ServicePartitionKey(0));
        }
Пример #16
0
        public ProductsController(ILogger <ProductsController> logger)
        {
            _logger = logger;
            var proxyFactory = new ServiceProxyFactory(c => new FabricTransportServiceRemotingClientFactory());

            _productCatalogService = proxyFactory.CreateServiceProxy <IProductCatalogService>(
                new Uri("fabric:/ASFECommerce/ECommerce.ProductCatalog"),
                new ServicePartitionKey(0));
        }
Пример #17
0
        public ProductController()
        {
            var proxyFactory = new ServiceProxyFactory(context => new Microsoft.ServiceFabric.Services.Remoting.V2.FabricTransport.Client.FabricTransportServiceRemotingClientFactory());

            _productCatalogService = proxyFactory.CreateServiceProxy <IProductCatalogService>(
                new Uri("fabric:/E_Commerce/ECommerce.ProductCatalog"),
                new Microsoft.ServiceFabric.Services.Client.ServicePartitionKey(0)
                );
        }
Пример #18
0
        public ProductsController()
        {
            // Proxy factory creates proxies to other services
            var proxyFactory = new ServiceProxyFactory(
                c => new FabricTransportServiceRemotingClientFactory());

            _service = proxyFactory.CreateServiceProxy <IProductCatalogService>(
                new Uri("fabric:/ECommerce/ECommerce.ProductCatalog"),
                new Microsoft.ServiceFabric.Services.Client.ServicePartitionKey(0));
        }
 public CachedProductCatalogService(ICacheStorage cachStorage,
                                    IProductCatalogService realProductCatalogService,
                                    IProductTitleRepository productTitleRepository,
                                    IProductRepository productRepository)
 {
     _cachStorage = cachStorage;
     _realProductCatalogService = realProductCatalogService;
     _productTitleRepository    = productTitleRepository;
     _productRepository         = productRepository;
 }
        protected ProductCatalogBasePresenter(TView view, IProductCatalogService service)
            : base(view)
        {
            if (service == null)
            {
                throw new ArgumentNullException("service");
            }

            _service = service;
        }
        public ProductSearchPresenter(IProductCatalogService service, IProductSearchResultView view,
                                      IApplicationConfiguration configuration)
            : base(view, service)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            _configuration = configuration;
        }
        public ProductController(ILogger <ProductController> logger)
        {
            #region
            // SubModule Testing
            #endregion
            _logger = logger;

            var proxyFactory = new ServiceProxyFactory(
                c => new FabricTransportServiceRemotingClientFactory());

            _service = proxyFactory.CreateServiceProxy <IProductCatalogService>
                           (new Uri("fabric:/SF.ECommerce/SF.ECommerce.Products")
                           , new ServicePartitionKey(0));
        }
Пример #23
0
 /// <summary>
 /// 获取成品分类
 /// </summary>
 /// <param name="ProductCatalogService"></param>
 /// <param name="key">移除当前键,当为""或null不移除</param>
 /// <returns></returns>
 public static List<ChooseDictionary> ListAllProductCatalogInfo(IProductCatalogService ProductCatalogService, string key)
 {
     NameValueCollection nvc = new NameValueCollection();
     nvc.Add("isvalid", "1");
     NameValueCollection orderby = new NameValueCollection();
     orderby.Add("ProductCatalogname", "asc");
     List<ProductCatalogInfo> datalist = ProductCatalogService.ListAllByCondition(nvc, orderby);
     if (!string.IsNullOrEmpty(key))
     {
         datalist.Remove(datalist.Where(x => x.Id.Equals(key)).SingleOrDefault());
     }
     var dicProductCatalog = (from slist in datalist
                              select new ChooseDictionary { Text = slist.ProductCatalogName, Value = slist.Id, ParentId = slist.ParentId }).ToList();
     return dicProductCatalog;
 }
Пример #24
0
 public CachedProductCatalogService(ICacheStorage cacheStorage,
                                    IProductCatalogService productCatalogService,
                                    IProductTitleRepository productTitleRepository,
                                    IProductRepository productRepository,
                                    IMapper mapper)
 {
     _cacheStorage              = cacheStorage;
     _productCatalogService     = productCatalogService;
     _productTitleRepository    = productTitleRepository;
     _productRepository         = productRepository;
     _getTopSellingProductsLock = new object();
     _getAllProductTitlesLock   = new object();
     _getAllProductsLock        = new object();
     _getAllCategoriesLock      = new object();
     _mapper = mapper;
 }
Пример #25
0
        public async Task <CheckoutSummary> Checkout(string userId)
        {
            var result = new CheckoutSummary()
            {
                Date     = DateTime.UtcNow,
                Products = new List <CheckoutProduct>()
            };

            IUserActor actor = CreateUserActor(userId);
            var        cart  = await actor.GetCart();

            IProductCatalogService productCatalogService = GetProductCatalogService();
            var products = await productCatalogService.GetAllProducts();

            var totalCost = 0.0;

            foreach (var item in cart)
            {
                var productId = item.Key;
                var quantity  = item.Value;
                var product   = products.FirstOrDefault(p => p.Id == productId);
                if (product != null)
                {
                    result.Products.Add(new CheckoutProduct()
                    {
                        Product  = product,
                        Quantity = quantity,
                        Price    = product.Price * quantity
                    });
                    totalCost += (product.Price * quantity);
                }
            }
            result.TotalPrice = totalCost;

            //Clearing the cart since user has checkout all the products and add to history
            await actor.ClearCart();

            await AddToHistory(result);

            return(result);
        }
Пример #26
0
        public async Task <CheckoutSummary> Checkout(string userId)
        {
            var result = new CheckoutSummary();

            result.Date     = DateTime.UtcNow;
            result.Products = new List <CheckoutProduct>();

            //call user actor to get the basket
            var userActor = GetUserActor(userId);
            var basket    = await userActor.GetBasket();

            //get catalog client
            IProductCatalogService catalogService = GetProductCatalogService();

            //constuct CheckoutProduct items by calling to the catalog
            foreach (var basketLine in basket)
            {
                var product = await catalogService.GetProduct(basketLine.Key);

                if (product != null)
                {
                    var checkoutProduct = new CheckoutProduct
                    {
                        Product  = product,
                        Price    = product.Price,
                        Quantity = basketLine.Value
                    };
                    result.Products.Add(checkoutProduct);
                }
            }

            //generate total price
            result.TotalPrice = result.Products.Select(p => p.Quantity * p.Price).Sum();

            //clear user basket
            await userActor.ClearBasket();

            await AddToHistory(result);

            return(result);
        }
        public async Task <CheckoutSummary> CheckoutAsync(string userId)
        {
            //holds result of the checkout
            var result = new CheckoutSummary();

            result.Date     = DateTime.UtcNow;
            result.Products = new List <CheckoutProduct>();

            //call user actor to get the basket
            IUserActor userActor = GetUserActor(userId);

            BasketItem[] basket = await userActor.GetBasket();

            //get catalog client
            IProductCatalogService catalogService = GetProductCatalogService();

            //get detailed product information for each basket item by calling product service
            foreach (BasketItem basketLine in basket)
            {
                Product product = await catalogService.GetProductAsync(basketLine.ProductId);

                var checkoutProduct = new CheckoutProduct
                {
                    Product  = product,
                    Price    = product.Price,
                    Quantity = basketLine.Quantity
                };
                result.Products.Add(checkoutProduct);
            }

            //generate total price
            result.TotalPrice = result.Products.Sum(p => p.Price);

            //clear user basket
            await userActor.ClearBasket();

            await AddToHistoryAsync(result);

            return(result);
        }
Пример #28
0
        public async Task <CheckoutSummary> CheckoutAsync(string userId)
        {
            var checkoutSummary = new CheckoutSummary();

            checkoutSummary.Date     = DateTime.UtcNow;
            checkoutSummary.Products = new List <CheckoutProduct>();

            IUserActor userActor       = GetUserActor(userId);
            var        userBasketItems = await userActor.GetBasketAsync();

            var basket = new Dictionary <Guid, int>();

            foreach (var userBasketItem in userBasketItems)
            {
                basket.Add(userBasketItem.ProductId, userBasketItem.Quantity);
            }

            IProductCatalogService catalogService = GetProductCatalogService();

            foreach (KeyValuePair <Guid, int> basketLine in basket)
            {
                Product product = await catalogService.GetProductAsync(basketLine.Key);

                var checkoutProduct = new CheckoutProduct
                {
                    Product  = product,
                    Quantity = basketLine.Value,
                    SubTotal = product.Price * basketLine.Value
                };

                checkoutSummary.Products.Add(checkoutProduct);

                checkoutSummary.TotalPrice += checkoutProduct.SubTotal;
            }

            await AddToHistoryAsync(checkoutSummary);

            return(checkoutSummary);
        }
Пример #29
0
        public async Task <CheckoutSummary> CheckoutAsync(string userId)
        {
            CheckoutSummary result = new CheckoutSummary()
            {
                Date     = DateTime.UtcNow,
                Products = new List <CheckoutProduct>()
            };

            // get user basket
            IUserActor userActor = GetUserActor(userId);
            var        basket    = await userActor.GetBasket();

            IProductCatalogService catalogService = GetProductCatalogService();

            // build the products using the catalog service data and the basket line items
            foreach (var basketItem in basket)
            {
                Product product = await catalogService.GetProductAsync(basketItem.ProductId);

                if (product != null)
                {
                    var checkoutProduct = new CheckoutProduct()
                    {
                        Product  = product,
                        Price    = product.Price,
                        Quantity = basketItem.Quantity
                    };

                    result.Products.Add(checkoutProduct);
                }
            }

            // add the current checkout summary to history (for later retrieval)
            await AddToHistoryAsync(result);

            return(result);
        }
Пример #30
0
 public ProductsController()
 {
     this.productCatalogService = ServiceProxy.Create <IProductCatalogService>(
         new Uri("fabric:/ECommerce/ECommerce.ProductCatalog"),
         new Microsoft.ServiceFabric.Services.Client.ServicePartitionKey(0));
 }
 public ProductCatalogController(ILogger <ProductCatalogController> logger, IProductCatalogService service) : base(logger)
 {
     _service = service;
 }
Пример #32
0
 public ProductCatalogBaseController(IProductCatalogService productCatalogService)
 {
     _productCatalogService = productCatalogService;
 }
 public ProductCatalogController(IProductCatalogService iProductCatalogService)
 {
     _iProductCatalogService = iProductCatalogService;
 }
Пример #34
0
 //private string defaultUserRepository;
 public HomeController(IProductCatalogService service)
 {
     this.productCatalogservice = service;
 }
 public ProductCatalogRepository(IProductCatalogService productCatalogService, ICacheService cacheService)
 {
     _productCatalogService = productCatalogService;
     _cacheService = cacheService;
 }
Пример #36
0
 public HomeController(IProductCatalogService productCatalogService)
     : base(productCatalogService)
 {
     _productCatalogService = productCatalogService;
 }