public List <SeckillDto> GetSeckills(int timeId)
        {
            //1.秒杀活动
            List <Seckill> seckills = seckillTimeClient.GetSeckills(timeId);

            var configuration = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <Seckill, SeckillDto>();
            });

            IMapper mapper = configuration.CreateMapper();

            List <SeckillDto> seckillDtos = mapper.Map <List <Seckill>, List <SeckillDto> >(seckills);

            //查询秒活动信息
            foreach (var seckill in seckillDtos)
            {
                Product product = productClient.GetProduct(seckill.ProductId);
                seckill.ProductPrice       = product.ProductPrice;
                seckill.ProductDescription = product.ProductDescription;
                seckill.ProductTitle       = product.ProductTitle;
                // seckill.ProductStock = product.ProductStock;
                seckill.ProductUrl = product.ProductUrl;
            }
            return(seckillDtos);
        }
        public async Task <IActionResult> product(int id)
        {
            var user = await _accountClient.getProfile();

            //check if user currently login or not
            ViewData["username"] = user.Error == null ? user.Value.Username : string.Empty;
            ViewData["cart"]     = user.Error == null ? user.Value.Cart.Count : null;
            var product = await _productClient.GetProduct(id);

            return(View(product));
        }
        public Product GetProductDetail(User user, int productId)
        {
            // 1、查询商品
            Product product = productClient.GetProduct(productId);

            // 2、查询商品轮播图
            List <ProductImage> productImages = productImageClient.GetProductImages(productId);

            // 3、商品设置图片
            product.Images = productImages;
            return(product);
        }
        public async Task GetProductTest()
        {
            // Arrange
            var id = "product-id";

            _stripe.Get(Arg.Is <StripeRequest <Product> >(a => a.UrlPath == "products/" + id), _cancellationToken)
            .Returns(Task.FromResult(new StripeResponse <Product>()));

            // Act
            var response = await _client.GetProduct(id, _cancellationToken);

            // Assert
            response.Should().NotBeNull();
        }
        public async Task <ActionResult> GetProduct(int id)
        {
            var product = await productClient.GetProduct(id);

            var model = new ProductViewModel
            {
                ProductId   = product.Data.ProductId,
                Name        = product.Data.Name,
                Description = product.Data.Description,
                CreatedOn   = product.Data.CreatedOn.ToLongDateString() + " " + product.Data.CreatedOn.ToLongTimeString()
            };

            return(View(model));
        }
        public async Task <IActionResult> Detail(int id)
        {
            var product = await _productClient.GetProduct(id);

            ViewData[Constants.TYPE_BANNER]          = Constants.TYPE_BANNER_BRAND;
            ViewData[Constants.DATA_COMMENTS_CLIENT] = await _commentClient.GetCommentsByProduct(id);

            if (User.Identity.IsAuthenticated)
            {
                var    claimIdentity = User.Identity as ClaimsIdentity;
                string userid        = claimIdentity.FindFirst(ClaimTypes.NameIdentifier).Value;
                var    rating        = await _ratingClient.GetRating(userid, id);

                ViewData[Constants.DATA_RATING_CLIENT] = rating;
            }
            return(View(product));
        }
        public SeckillDto GetSeckill(int id)
        {
            // 1、秒杀活动
            Seckill seckill = seckillsClient.GetSeckill(id);

            var configuration = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <Seckill, SeckillDto>();
            });

            IMapper mapper = configuration.CreateMapper();

            SeckillDto seckillDto = mapper.Map <Seckill, SeckillDto>(seckill);
            // 2、查询秒杀商品信息
            Product product = productClient.GetProduct(seckill.ProductId);

            seckillDto.ProductPrice       = product.ProductPrice;
            seckillDto.ProductDescription = product.ProductDescription;
            seckillDto.ProductTitle       = product.ProductTitle;
            seckillDto.ProductUrl         = product.ProductUrl;

            return(seckillDto);
        }
Esempio n. 8
0
        public async Task <IActionResult> Index()
        {
            var products = await _productClient.GetProduct();

            return(View(products));
        }
Esempio n. 9
0
        public async Task <IActionResult> Detail(int id)
        {
            var product = await _productApiClient.GetProduct(id);

            return(View(product));
        }
Esempio n. 10
0
        public ActionResult Details(long id)
        {
            var product = _productClient.GetProduct(id);

            return(View(_mapper.Map <ProductViewModel>(product)));
        }
Esempio n. 11
0
        public async Task <IViewComponentResult> InvokeAsync(int productid)
        {
            var product = await _productClient.GetProduct(productid);

            return(View(product));
        }